Skip to content

Commit

Permalink
update conftest.py to resolve doctest issue.
Browse files Browse the repository at this point in the history
- newer version numpy has a different print format for arrays and scalars that would potentially break the doctests.
  • Loading branch information
BowenBao committed Aug 24, 2018
1 parent 28ada96 commit a26e542
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions bindings/python/cntk/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@ def pytest_generate_tests(metafunc):
import numpy
# Because of difference in precision across platforms, we restrict the output
# precision and don't write in scientific notation
# Also, due to the change of how arrays and numbers are printed which was introduced in numpy v1.14.0,
# we need to set printoptions to legacy to have consistent doctests.
def version(v):
return tuple(map(int, v.split('.')))
numpy.set_printoptions(precision=6, suppress=True)
if version(numpy.__version__) >= version('1.14'):
numpy.set_printoptions(legacy="1.13")

import cntk.debugging
cntk.debugging.set_checked_mode(True)
Expand Down
6 changes: 3 additions & 3 deletions bindings/python/doc/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ def pytest_generate_tests(metafunc):
# we need to set printoptions to legacy to have consistent doctests.
def version(v):
return tuple(map(int, v.split('.')))
numpy.set_printoptions(precision=6, suppress=True)
if version(numpy.__version__) >= version('1.14'):
numpy.set_printoptions(precision=6, suppress=True, legacy="1.13")
else:
numpy.set_printoptions(precision=6, suppress=True)
numpy.set_printoptions(legacy="1.13")

import cntk


Expand Down

0 comments on commit a26e542

Please sign in to comment.