Skip to content

DOCTEST: Use legacy float array printing for now #556

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 6 commits into from
Oct 5, 2017

Conversation

effigies
Copy link
Member

In numpy's pre-release, float arrays now have different printing strategies. Adding #doctest: +NORMALIZE_WHITESPACE doesn't resolve the issue, so for the moment we need to use their option to revert printing behavior to keep doctests from breaking.

Using .. testsetup:: should avoid visual changes to the docs.

Introduced in numpy/numpy@710e032

@coveralls
Copy link

Coverage Status

Coverage remained the same at 96.271% when pulling a2bc501 on effigies:fix/numpy_print_doctests into dbe74e1 on nipy:master.

@codecov-io
Copy link

codecov-io commented Sep 27, 2017

Codecov Report

Merging #556 into master will decrease coverage by <.01%.
The diff coverage is 80%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #556      +/-   ##
==========================================
- Coverage   94.34%   94.33%   -0.01%     
==========================================
  Files         177      177              
  Lines       24670    24680      +10     
  Branches     2634     2635       +1     
==========================================
+ Hits        23275    23283       +8     
- Misses        920      921       +1     
- Partials      475      476       +1
Impacted Files Coverage Δ
nibabel/__init__.py 90.69% <100%> (+0.22%) ⬆️
nibabel/nicom/dwiparams.py 71.69% <100%> (+0.54%) ⬆️
nibabel/affines.py 100% <100%> (ø) ⬆️
nibabel/quaternions.py 98.05% <100%> (+0.01%) ⬆️
nibabel/nifti1.py 91.14% <100%> (+0.01%) ⬆️
nibabel/casting.py 85.83% <100%> (+0.06%) ⬆️
nibabel/testing/__init__.py 94.79% <50%> (-1.95%) ⬇️

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 dbe74e1...70afacb. Read the comment docs.

@effigies
Copy link
Member Author

@matthew-brett I think you'll know more about how to deal with this error than I do. Is this an issue on matplotlib's end, or some buildbot that needs fixing?

THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE. If you have updated the package versions, please update the hashes. Otherwise, examine the package contents carefully; someone may have tampered with them.
    matplotlib from https://7933911d6844c6c53a7d-47bd50c35cd79bd838daf386af554a83.ssl.cf2.rackcdn.com/matplotlib-2.1.0rc1+104.g4792425-cp27-cp27mu-manylinux1_x86_64.whl#sha256=0b50fa1925772cf0b6d7a386774c9f7671c758bdc3c2472e06f0e319da841848:
        Expected sha256 0b50fa1925772cf0b6d7a386774c9f7671c758bdc3c2472e06f0e319da841848
             Got        b49660821b0a93fd9c1dd8c0aafd5489b86524edd907e032f9347eebb84f47f1

Copy link
Member

@matthew-brett matthew-brett left a comment

Choose a reason for hiding this comment

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

Some hopeful suggestions.

@@ -9,6 +9,12 @@
''' Read / write access to NIfTI1 image format

NIfTI1 format defined at http://nifti.nimh.nih.gov/nifti-1/

Copy link
Member

Choose a reason for hiding this comment

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

Can we make this two separate strings, so the user doesn't get this testsetup in the docstring help?

@@ -18,6 +18,11 @@

B ~ (q_est . q_est.T) / norm(q_est)

.. testsetup::
Copy link
Member

Choose a reason for hiding this comment

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

Can we put this in a separate docstring? See comment below.

@@ -23,6 +23,12 @@
>>> M = quat2mat(q) # from this module
>>> vec = np.array([1, 2, 3]).reshape((3,1)) # column vector
>>> tvec = np.dot(M, vec)

Copy link
Member

Choose a reason for hiding this comment

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

Ditto.

@effigies
Copy link
Member Author

Hopefully this works. I don't know all the rules to doctests.

@effigies effigies force-pushed the fix/numpy_print_doctests branch from b803ac6 to dab6331 Compare September 27, 2017 17:40
@coveralls
Copy link

Coverage Status

Coverage remained the same at 96.271% when pulling dab6331 on effigies:fix/numpy_print_doctests into dbe74e1 on nipy:master.

@effigies
Copy link
Member Author

Is there some way to do a package-wide pre-doctest setup so we can have this in one place? Hard to google.

@matthew-brett
Copy link
Member

I don't know how to set up project wide doctest initialization - other than writing a specific nibabel plugin for the doctests / nose.

@effigies effigies force-pushed the fix/numpy_print_doctests branch from dab6331 to 600f7f2 Compare October 2, 2017 23:47
@effigies
Copy link
Member Author

effigies commented Oct 3, 2017

I think I've resolved this. If there's a setup_test() function, that will get run before doctests (see doctest fixtures). At least locally, I was able to write this function in one place nibabel.testing and import it in others. We'll see if it does what we want with the pre-release installed.

@effigies effigies force-pushed the fix/numpy_print_doctests branch from b72634f to 26dfee3 Compare October 3, 2017 01:53
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.003%) to 96.268% when pulling b72634f on effigies:fix/numpy_print_doctests into dbe74e1 on nipy:master.

@effigies effigies force-pushed the fix/numpy_print_doctests branch from b27efce to 70afacb Compare October 3, 2017 02:09
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.003%) to 96.268% when pulling 70afacb on effigies:fix/numpy_print_doctests into dbe74e1 on nipy:master.

@effigies
Copy link
Member Author

effigies commented Oct 4, 2017

@matthew-brett Does this look reasonable?

@matthew-brett
Copy link
Member

Thanks - looks good - in it goes.

@matthew-brett matthew-brett merged commit fa76141 into nipy:master Oct 5, 2017
@effigies effigies deleted the fix/numpy_print_doctests branch October 6, 2017 16:01
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.

4 participants