Skip to content

Commit

Permalink
Modify numpy's global print settings only when running tests
Browse files Browse the repository at this point in the history
`numpy.set_printoptions(legacy='1.13')` was added to `test_axographio.py` in commit ac7c96a to fix broken doctests when numpy >= 1.14 is installed (old style printing retained for backwards compatibility). This global setting was being activated every time axographio was imported, even if axographio's tests are not run. This created unexpected behavior in other packages that import axographio. This change delays modifying the global setting until axographio's tests are actually run.
  • Loading branch information
jpgill86 committed Aug 15, 2018
1 parent 0a890fd commit 4c21b34
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions axographio/tests/test_axographio.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@
'../include/axograph_readwrite/AxoGraph X File.axgx'),
}

# doctests need the array formatting used in numpy < 1.14
try:
np.set_printoptions(legacy='1.13')
except TypeError:
pass

class TestSampleFiles(unittest.TestCase):
"""Test the ability to read some sample data files.
Expand Down Expand Up @@ -186,6 +180,13 @@ def test_suite():

def run():
"""Run the test suite containing all of the tests for axographio"""

# doctests need the array formatting used in numpy < 1.14
try:
np.set_printoptions(legacy='1.13')
except TypeError:
pass

unittest.TextTestRunner(verbosity=2).run(test_suite())

#
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
MAJOR = 0 # increment for backwards-incompatible changes
MINOR = 3 # increment for backwards-compatible feature additions
MICRO = 0 # increment for backwards-compatible bug fixes
IS_RELEASED = True # determines whether version will be marked as development
IS_RELEASED = False # determines whether version will be marked as development
VERSION = '%d.%d.%d' % (MAJOR, MINOR, MICRO)


Expand Down

0 comments on commit 4c21b34

Please sign in to comment.