Skip to content

pytest: Numpy 1 15 warnings#3242

Merged
jni merged 11 commits intoscikit-image:masterfrom
hmaarrfk:numpy_1_15_warnings
Aug 1, 2018
Merged

pytest: Numpy 1 15 warnings#3242
jni merged 11 commits intoscikit-image:masterfrom
hmaarrfk:numpy_1_15_warnings

Conversation

@hmaarrfk
Copy link
Copy Markdown
Member

@hmaarrfk hmaarrfk commented Jul 3, 2018

This PR splits the warning checking from #3238 to allow for a more focused discussion.

  • Goes in an catches the warnings from dependencies that don't follow numpy 1.15
  • Locks the expected warnings to a specific version

@soupault said

Also, the warnings conditional on package versions should be considered for further refactoring.

I replied:

@soupault plans for deprecacting the logic behind the conditional warnings:

Well, the plan for removing it is so long term that I didn't know if it makes sense. I'll add some words about it.

I assume that scipy (and pywavelets) will eventually fix these warnings on their side too. at which point, some version of scipy, higher than 1.1.6, will eventually not have these warnings by default. But until then, this is just a very explicit way ensuring warning are

Finally, I was testing out avoiding the use of |\A\Z since it isn't really explicit as to what conditions might trigger the warning.

Even without instructions, somebody 10 years from now would be able to go through the code, find that a certain combinations of packages can't exist in their supported versions, and rip out the logic if they want to.

That said, I don't know when pywavelets and scipy will address their warnings, maybe it is for us to send in the PR, and the tests might fail once or twice until they get around to fixing their codebase. We would require version bumps on the logic at that point.

The matrix subclass warning should definitely be broadened, as that would require a major change on scipy's end.

I just updated the scipy dependency to not depend on the minor version number for the sparse matrix warning.

For reviewers

(Don't remove the checklist below.)

  • Check that the PR title is short, concise, and will make sense 1 year
    later.
  • Check that new functions are imported in corresponding __init__.py.
  • Check that new features, API changes, and deprecations are mentioned in
    doc/release/release_dev.rst.
  • Consider backporting the PR with @meeseeksdev backport to v0.14.x

Copy link
Copy Markdown
Member

@soupault soupault left a comment

Choose a reason for hiding this comment

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

There are few extra places where you need to update the format of extected_warnings input argument (see CI).


# SNR is improved less with 1 wavelet level than with the default.
denoised_1 = restoration.denoise_wavelet(noisy,
with expected_warnings([None]):
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.

The benefit of using none is that under certain build conditions, where we don't expect warnings, None can be passed in.

What is, basically, the same thing as with expected_warnings([]): 🤔

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Sorry, this one was a rememnent of me testing my None function. I'll rebase and sqaush this.


# Verify that SNR is improved with internally estimated sigma
denoised = restoration.denoise_wavelet(noisy, method=method)
# I don't know why this logic for the warnings is correct
Copy link
Copy Markdown
Member

@soupault soupault Jul 3, 2018

Choose a reason for hiding this comment

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

🤣 This comment shouldn't be here.

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.

No, really, this should be removed 🙂 . Or, at least, refactored.

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.

@grlee77 do you have an insight of this?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@soupault I added a little more information that I could gain.

@soupault soupault added the 🔧 type: Maintenance Refactoring and maintenance of internals label Jul 3, 2018
@soupault soupault added this to the 0.14.1 milestone Jul 3, 2018
@hmaarrfk hmaarrfk force-pushed the numpy_1_15_warnings branch from 1d092da to 4211ecd Compare July 3, 2018 22:50
@hmaarrfk
Copy link
Copy Markdown
Member Author

hmaarrfk commented Jul 3, 2018

@soupault I'll wait until #3238 is merged in. Some of the fixes needed to happen together.
We get to 0 warnings once we fix that dask deprecation too.

@hmaarrfk
Copy link
Copy Markdown
Member Author

hmaarrfk commented Jul 4, 2018

Just a note: scipy will likely silence the matrix 1.2.0

@hmaarrfk
Copy link
Copy Markdown
Member Author

hmaarrfk commented Jul 4, 2018

And tuple indexing for scipy seems to be a WIP: scipy/scipy#8944

@codecov-io
Copy link
Copy Markdown

codecov-io commented Jul 27, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@dc8b56f). Click here to learn what that means.
The diff coverage is 95.74%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #3242   +/-   ##
=========================================
  Coverage          ?   86.76%           
=========================================
  Files             ?      339           
  Lines             ?    27363           
  Branches          ?        0           
=========================================
  Hits              ?    23741           
  Misses            ?     3622           
  Partials          ?        0
Impacted Files Coverage Δ
skimage/measure/tests/test_simple_metrics.py 100% <100%> (ø)
skimage/color/tests/test_colorconv.py 100% <100%> (ø)
skimage/util/tests/test_dtype.py 100% <100%> (ø)
skimage/io/tests/test_imageio.py 68.75% <100%> (ø)
skimage/_shared/_warnings.py 90.9% <75%> (ø)
skimage/segmentation/tests/test_random_walker.py 98.43% <95.65%> (ø)
skimage/filters/tests/test_lpi_filter.py 87.5% <95.83%> (ø)
skimage/restoration/tests/test_denoise.py 99.47% <97.36%> (ø)

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 dc8b56f...71041da. Read the comment docs.

@hmaarrfk
Copy link
Copy Markdown
Member Author

hmaarrfk commented Jul 27, 2018

@soupault I don't get it, I swear this should have passed once the other numpy 1.15 was pulled in.

Unfortunately, it seems that there are some formatting errors now.
This is for some doctests that don't look like they have been touched in a while.

@pep8speaks
Copy link
Copy Markdown

pep8speaks commented Jul 27, 2018

Hello @hmaarrfk! Thanks for updating the PR.

Line 410:80: E501 line too long (84 > 79 characters)

Line 185:80: E501 line too long (80 > 79 characters)

Comment last updated on August 01, 2018 at 00:14 Hours UTC

@hmaarrfk hmaarrfk force-pushed the numpy_1_15_warnings branch from 24fdc0b to 3741ce3 Compare July 27, 2018 15:59
@hmaarrfk
Copy link
Copy Markdown
Member Author

@soupault, sorry for bundling the fix for matplotlib/PyQt5.11 incompatibility.
The goal of this PR is really to re-obtain testing functionality. The commit history is pretty clean and I feel like the temporary fix is also well documented in the script.

Let me know if you disagree, I would gladly separate it as a different PR, but with the builds failing, it is really difficult to ensure correctness.

Copy link
Copy Markdown
Member

@soupault soupault left a comment

Choose a reason for hiding this comment

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

@hmaarrfk I'm positive on this PR. Thanks for investigating the remaining issues! Just a couple of simple remarks, otherwise LGTM.

SCIPY_ND_INDEXING = 'non-tuple sequence for multidimensional'
else:
SCIPY_ND_INDEXING = None

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

done.



if (Version(np.__version__) >= '1.15.0' and
Version(scipy.__version__) <= '1.1.0'):
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.

Please, fix the indentation here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

How would you like it to be fixed. Pep8 doesn't specify the "correct" way

# No extra indentation.
if (this_is_one_thing and
    that_is_another_thing):
    do_something()

# Add a comment, which will provide some distinction in editors
# supporting syntax highlighting.
if (this_is_one_thing and
    that_is_another_thing):
    # Since both conditions are true, we can frobnicate.
    do_something()

# Add some extra indentation on the conditional continuation line.
if (this_is_one_thing
        and that_is_another_thing):
    do_something()

I picked the bottom one.


# Verify that SNR is improved with internally estimated sigma
denoised = restoration.denoise_wavelet(noisy, method=method)
# I don't know why this logic for the warnings is correct
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.

No, really, this should be removed 🙂 . Or, at least, refactored.


# Verify that SNR is improved with internally estimated sigma
denoised = restoration.denoise_wavelet(noisy, method=method)
# I don't know why this logic for the warnings is correct
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.

@grlee77 do you have an insight of this?


for convert2ycbcr in [True, False]:
for multichannel in [True, False]:
expected = (PYWAVELET_ND_INDEXING if multichannel else None)
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.

I'd refrain from using name expected. Usually, it is assigned to an expected result of the function-under-test.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I called it anticipated_warnings.

PYAMG_SCIPY_EXPECTED = SCIPY_EXPECTED + '|' + PYAMG_EXPECTED_WARNING

if (Version(np.__version__) >= '1.15.0' and
Version(scipy.__version__) <= '1.1.0'):
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.

Indentation here as well.

# Now configure Matplotlib to use Qt5
if [[ "${QT}" == "PyQt5" ]]; then
pip install --retries 3 -q $PIP_FLAGS pyqt5
# Matplotlib 2.2.2 doesn't support pyqt5 5.11 until this commit
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.

Could you add this to TODO as well?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

  • Monitor when matplotlib releases a version greater than 2.2.2 and test
    to see if it becomes compatible with PyQt5.11. If it is compatible,
    remove the version limiting logic in tools/travis/install_qt.sh.

@hmaarrfk hmaarrfk force-pushed the numpy_1_15_warnings branch 3 times, most recently from 3c73db4 to 9a3d38a Compare July 28, 2018 22:40
@hmaarrfk hmaarrfk force-pushed the numpy_1_15_warnings branch 2 times, most recently from 415a996 to c60ae9a Compare July 30, 2018 03:13
@hmaarrfk hmaarrfk force-pushed the numpy_1_15_warnings branch 2 times, most recently from aedca22 to cb74435 Compare July 30, 2018 15:44
Copy link
Copy Markdown
Member

@soupault soupault left a comment

Choose a reason for hiding this comment

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

Actually, nvm about indentation :). Thanks!

expected = ['scipy.sparse.sparsetools|%s' % PYAMG_SCIPY_EXPECTED,
NUMPY_MATRIX_EXPECTED]
with expected_warnings(expected):
anticipated_warnings = [
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I thought i caught that one too :/ thanks!

@hmaarrfk
Copy link
Copy Markdown
Member Author

Artifact limit?

'`dynamic_range` has been deprecated in favor of '
'`data_range`. The `dynamic_range` keyword argument '
'will be removed in v0.14'):
'will be removed in v0.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.

Erm, why is this still here???? But anyway, I'll leave a fix to a later PR. @soupault?

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.

@jni My bad. :) I'll take care of this.

@jni jni merged commit 259ea05 into scikit-image:master Aug 1, 2018
@jni
Copy link
Copy Markdown
Member

jni commented Aug 1, 2018

Thanks @hmaarrfk! Good stuff. Personally I like expected_warnings to allow a single string (though that wasn't what was happening!), but now it does what the docs always said and anyway it's a matter of debate whether it should accept different input types. Certainly the ability to pass None is very good.

@jni
Copy link
Copy Markdown
Member

jni commented Aug 1, 2018

@meeseeksdev backport to v0.14.x

@lumberbot-app
Copy link
Copy Markdown

lumberbot-app bot commented Aug 1, 2018

There seem to be a conflict, please backport manually

@lumberbot-app lumberbot-app bot added the Still Needs Manual Backport MrMeeseeks-managed label label Aug 1, 2018
jni added a commit to jni/scikit-image that referenced this pull request Aug 1, 2018
@hmaarrfk
Copy link
Copy Markdown
Member Author

hmaarrfk commented Aug 1, 2018

@jni, that is certainly a good idea, a single string was convenient. The check could have

if isinstance(matching, str):
   matching = [matching]

I'm not the best at API design, but definitely good at finding places where things aren't working as intended :D

jni added a commit to jni/scikit-image that referenced this pull request Aug 15, 2018
soupault added a commit that referenced this pull request Aug 15, 2018
Backport #3242: handle NumPy 1.15 warnings in dependencies
@hmaarrfk hmaarrfk deleted the numpy_1_15_warnings branch November 4, 2018 13:34
@jni jni mentioned this pull request Dec 1, 2018
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Still Needs Manual Backport MrMeeseeks-managed label 🔧 type: Maintenance Refactoring and maintenance of internals

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants