Skip to content

force legacy numpy repr for doctests - #344

Merged
grlee77 merged 4 commits into
PyWavelets:masterfrom
grlee77:np114_doctest_fix
Feb 21, 2018
Merged

grlee77 merged 4 commits into
PyWavelets:masterfrom
grlee77:np114_doctest_fix

Conversation

@grlee77

@grlee77 grlee77 commented Jan 16, 2018

Copy link
Copy Markdown
Contributor

Many doctests rely on the numpy <=1.13 format array printing. This PR forces this older representation to be used in the docstring examples when numpy >= 1.14.

In the future, once the minimum numpy version supported has been bumped to >=1.14, the doctests should be regenerated with the new representation and these lines can be removed.

@grlee77

grlee77 commented Jan 16, 2018

Copy link
Copy Markdown
Contributor Author

On second thought, we probably don't want to do it this way as this will cause import pywt to change the user's print options.

@grlee77 grlee77 changed the title force legacy numpy repr for doctests WIP: force legacy numpy repr for doctests Jan 16, 2018
@grlee77

grlee77 commented Jan 16, 2018

Copy link
Copy Markdown
Contributor Author

Rebased to only make the np.set_printoptions call in conf.py for the doctests rather than in any of the other source files themselves.

@grlee77 grlee77 changed the title WIP: force legacy numpy repr for doctests force legacy numpy repr for doctests Jan 17, 2018
@grlee77

grlee77 commented Jan 17, 2018

Copy link
Copy Markdown
Contributor Author

The current approach seems to now be working (OS X still pending on Travis), and should not be globally changing the user's print options. I used an approach borrowed from nilearn where the print options are changed upon module import only if it is detected that nose is running.

@rgommers

Copy link
Copy Markdown
Member

This still messes with global state of tests of other packages, e.g. scikit-image. Wasn't the change in conf.py enough?

@rgommers

Copy link
Copy Markdown
Member

Hmm, I see the old test output, wasn't enough indeed.

@rgommers

Copy link
Copy Markdown
Member

The alternative is to isolate the doctests and run them only on the latest numpy version. That's in general a better approach, exactly because of the kinds of failures we get now. The only purpose of doctests are to check that the examples are not broken (not code coverage), so testing on 1 test run is enough.

We can merge this now though to get things unbroken, and fix it up later before the next release.

Comment thread pywt/__init__.py Outdated
from pywt.version import version as __version__

import numpy as np
if LooseVersion(np.__version__) >= LooseVersion("1.14"):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LooseVersion doesn't work correctly in some cases (and neither does StrictVersion), better to use

np.lib.NumpyVersion(np.__version__) < '1.14.0'

Comment thread pywt/_utils.py Outdated
"""Returns whether we are running the nose test loader
"""
if 'nose' not in sys.modules:
return

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

return False

@grlee77

grlee77 commented Jan 17, 2018

Copy link
Copy Markdown
Contributor Author

The alternative is to isolate the doctests and run them only on the latest numpy version. That's in general a better approach, exactly because of the kinds of failures we get now.

That sounds good. I will open a separate PR to try that approach instead.

@grlee77

grlee77 commented Feb 20, 2018

Copy link
Copy Markdown
Contributor Author

I made the requested changes here. I was hoping the alternative approach in #345 would work, but so far no luck.

@grlee77

grlee77 commented Feb 21, 2018 •

Copy link
Copy Markdown
Contributor Author

Finally all green here. no idea why the same fix for 1.14 didn't work on OS X. As a workaround, I just force numpy 1.13 on Travis for the OS X test case. <- nevermind the problem was having '<' rather than '>=' in a prior commit. I have resolved the problem and rebased, squashing some extraneous commits.

@codecov-io

Copy link
Copy Markdown

Codecov Report

Merging #344 into master will decrease coverage by 0.11%.
The diff coverage is 68%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #344      +/-   ##
=========================================
- Coverage   83.72%   83.6%   -0.12%     
=========================================
  Files          21      21              
  Lines        3300    3325      +25     
  Branches      558     564       +6     
=========================================
+ Hits         2763    2780      +17     
- Misses        477     482       +5     
- Partials       60      63       +3
Impacted Files Coverage Δ
pywt/_utils.py 84.61% <62.5%> (-9.83%) ⬇️
pywt/__init__.py 93.1% <77.77%> (-6.9%) ⬇️
pywt/_wavelet_packets.py 78.12% <0%> (ø) ⬆️

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 142cb9a...b6dc67f. Read the comment docs.

@grlee77

grlee77 commented Feb 21, 2018

Copy link
Copy Markdown
Contributor Author

The comments were addressed so I am going to go ahead and merge this so that CI is in a working state again. Feel free to open an new issue or PR if there is anything remaining to address.

@grlee77 grlee77 closed this Feb 21, 2018
@grlee77 grlee77 reopened this Feb 21, 2018
@grlee77
grlee77 merged commit f3c510a into PyWavelets:master Feb 21, 2018
@rgommers

Copy link
Copy Markdown
Member

Thanks @grlee77

@grlee77
grlee77 deleted the np114_doctest_fix branch July 20, 2018 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants