Skip to content

Legacy array printing for NumPy 1.14+#2810

Merged
dschult merged 1 commit intonetworkx:masterfrom
jarrodmillman:numpy-changes-to-array-printing
Jan 3, 2018
Merged

Legacy array printing for NumPy 1.14+#2810
dschult merged 1 commit intonetworkx:masterfrom
jarrodmillman:numpy-changes-to-array-printing

Conversation

@jarrodmillman
Copy link
Copy Markdown
Member

https://github.com/numpy/numpy/blob/master/doc/release/1.14.0-notes.rst

This fixes a bunch of failures like:

File "/home/travis/venv/lib/python2.7/site-packages/networkx/convert_matrix.py", line 1053, in networkx.convert_matrix.to_numpy_array
Failed example:
    A
Expected:
    array([[ 1.]])
Got:
    array([[1.]])

@jarrodmillman jarrodmillman added this to the networkx-2.1 milestone Jan 2, 2018
@jarrodmillman jarrodmillman force-pushed the numpy-changes-to-array-printing branch 2 times, most recently from 66f9204 to eae8ffc Compare January 3, 2018 00:36
@jarrodmillman
Copy link
Copy Markdown
Member Author

jarrodmillman commented Jan 3, 2018

I first tried to put the following

# FIXME remove next 3 lines once 1.14 is minimum NumPy requirement
# and fix printing doctests to use new format.
from distutils.version import LooseVersion
if LooseVersion(np.__version__) >  LooseVersion("1.13.3"):
    np.set_printoptions(legacy="1.13")

after every

import numpy as np

But decided that

try:
    np.set_printoptions(legacy="1.13")
except TypeError:
    pass

was a cleaner solution.

Unfortunately, I am still getting errors. I believe these errors are not related to the changes in how NumPy prints arrays, but are due to changes between pydot 1.2.3 and pydot 1.2.4. If that seems correct, I would like to merge this and then fix the pydot 1.2.4 issue. I haven't looked into what it takes to fix the 1.2.4 (vs. 1.2.3 of pydot).

@dschult Any thoughts about this?

@jarrodmillman jarrodmillman force-pushed the numpy-changes-to-array-printing branch from eae8ffc to 8e00464 Compare January 3, 2018 05:30
@jarrodmillman jarrodmillman force-pushed the numpy-changes-to-array-printing branch from 8e00464 to cc07974 Compare January 3, 2018 05:37
@jarrodmillman jarrodmillman requested a review from dschult January 3, 2018 06:05
@jarrodmillman jarrodmillman self-assigned this Jan 3, 2018
@dschult dschult merged commit 63c4ada into networkx:master Jan 3, 2018
@jarrodmillman jarrodmillman deleted the numpy-changes-to-array-printing branch January 3, 2018 20:17
@dschult dschult changed the title WIP: Legacy array printing for NumPy 1.14+ Legacy array printing for NumPy 1.14+ Jan 8, 2018
@dschult
Copy link
Copy Markdown
Member

dschult commented Jan 8, 2018

This PR allowed all tests to pass for many days. But now it has changed again so that the error shows when the documentation build process tests the doctests. In Travis it is the first config that produces the error in e.g. #2816 . Not sure why the legacy print options would not work in this environment.

jarrodmillman added a commit to jarrodmillman/networkx that referenced this pull request Jan 8, 2018
See Legacy array printing for NumPy 1.14+ (networkx#2810)

That fix worked for nose, but doesn't seem to work for sphinx.
jarrodmillman added a commit that referenced this pull request Jan 8, 2018
See Legacy array printing for NumPy 1.14+ (#2810)

That fix worked for nose, but doesn't seem to work for sphinx.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants