Skip to content

TEST: Use package-wide setup and teardown to adjust numpy print options #785

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 2, 2019

Conversation

effigies
Copy link
Member

Fixes #784.

if LooseVersion(numpy.__version__) >= LooseVersion('1.14'):
numpy.set_printoptions(legacy="1.13")
if nb._save_printopts is None:
nb._save_printopts = np.get_printoptions().get('legacy')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so it is not "printopts" really but a "legacyprintopt", right?

FWIW -- ATM it is just a single variable here. In DataLad we setup/teardown a few, so I just made a _test_states dict variable: https://github.com/datalad/datalad/blob/master/datalad/__init__.py#L92 to store all those in without breeding them at the top module level.

@yarikoptic
Copy link
Member

FWIW doctest is passing for me locally with this change
$> python -m nose -s -v --with-doctest nibabel/brikhead.py
Doctest: nibabel.brikhead.AFNIHeader.__init__ ... ok
Doctest: nibabel.brikhead.AFNIHeader.get_affine ... ok
Doctest: nibabel.brikhead.AFNIHeader.get_data_scaling ... ok
Doctest: nibabel.brikhead.AFNIHeader.get_volume_labels ... ok
Doctest: nibabel.brikhead.AFNIImage ... ok
Doctest: nibabel.brikhead._unpack_var ... ok
Doctest: nibabel.brikhead.parse_AFNI_header ... ok

----------------------------------------------------------------------
Ran 7 tests in 0.015s

OK

@effigies
Copy link
Member Author

In DataLad we setup/teardown a few, so I just made a _test_states dict variable: https://github.com/datalad/datalad/blob/master/datalad/__init__.py#L92 to store all those in without breeding them at the top module level.

Nice. I went ahead and copied that approach. I think it looks cleaner overall,

@effigies
Copy link
Member Author

Any further comments?

@effigies effigies added this to the 2.5.0 milestone Jul 31, 2019
Co-Authored-By: Yaroslav Halchenko <[email protected]>
@codecov
Copy link

codecov bot commented Jul 31, 2019

Codecov Report

Merging #785 into master will decrease coverage by <.01%.
The diff coverage is 91.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #785      +/-   ##
==========================================
- Coverage   89.99%   89.98%   -0.01%     
==========================================
  Files          94       94              
  Lines       12009    12012       +3     
  Branches     2133     2135       +2     
==========================================
+ Hits        10807    10809       +2     
  Misses        859      859              
- Partials      343      344       +1
Impacted Files Coverage Δ
nibabel/nicom/dwiparams.py 71.15% <ø> (-0.55%) ⬇️
nibabel/casting.py 87.23% <ø> (-0.06%) ⬇️
nibabel/quaternions.py 99.01% <ø> (-0.01%) ⬇️
nibabel/affines.py 100% <ø> (ø) ⬆️
nibabel/nifti1.py 91.47% <ø> (-0.02%) ⬇️
nibabel/__init__.py 92.85% <91.66%> (-0.9%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b356a64...4cccd86. Read the comment docs.

@codecov
Copy link

codecov bot commented Jul 31, 2019

Codecov Report

Merging #785 into master will decrease coverage by <.01%.
The diff coverage is 90.9%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #785      +/-   ##
==========================================
- Coverage   89.99%   89.98%   -0.01%     
==========================================
  Files          94       94              
  Lines       12009    12011       +2     
  Branches     2133     2135       +2     
==========================================
+ Hits        10807    10808       +1     
  Misses        859      859              
- Partials      343      344       +1
Impacted Files Coverage Δ
nibabel/nicom/dwiparams.py 71.15% <ø> (-0.55%) ⬇️
nibabel/casting.py 87.23% <ø> (-0.06%) ⬇️
nibabel/quaternions.py 99.01% <ø> (-0.01%) ⬇️
nibabel/affines.py 100% <ø> (ø) ⬆️
nibabel/nifti1.py 91.47% <ø> (-0.02%) ⬇️
nibabel/__init__.py 92.72% <90.9%> (-1.03%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b356a64...4cccd86. Read the comment docs.

@effigies
Copy link
Member Author

effigies commented Aug 2, 2019

Thanks for the review.

@effigies effigies merged commit 65c7ff6 into nipy:master Aug 2, 2019
@effigies effigies deleted the fix/doctest_teardown branch August 2, 2019 00:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

doctest AFNIHeader.get_data_scaling fails if ran "alone"
2 participants