Skip to content

Use correct NumPy version comparison in pytest configuration - #2975

Merged
jni merged 2 commits into
scikit-image:masterfrom
soupault:conftest
Mar 4, 2018
Merged

jni merged 2 commits into
scikit-image:masterfrom
soupault:conftest

Conversation

@soupault

@soupault soupault commented Mar 1, 2018 •

Copy link
Copy Markdown
Member

Description

Implements the fix proposed by @Borda in this review - #2935 (comment) . I've decided to use [:2] to properly handle also the release candidate versions.

Checklist

[It's fine to submit PRs which are a work in progress! But before they are merged, all PRs should provide:]

[For detailed information on these and other aspects see scikit-image contribution guidelines]

References

#2935 (comment)

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.

@soupault soupault added 🔧 type: Maintenance Refactoring and maintenance of internals ⏩ type: Enhancement Improve existing features labels Mar 1, 2018
@soupault soupault added this to the 0.14 milestone Mar 1, 2018
@soupault
soupault requested a review from jni March 1, 2018 10:49
@jni jni changed the title Use proper version comparison in pytest conftest.py Use correct NumPy version comparison in pytest configuration Mar 2, 2018

@jni jni left a comment

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

jni commented Mar 2, 2018

Copy link
Copy Markdown
Member

@scikit-image/core this is a a quick merge, ripe for the taking! ;)

@stefanv

stefanv commented Mar 2, 2018

Copy link
Copy Markdown
Member

Should we save version parsing for tools that know how to do it?

from distutils.version import LooseVersion as Version

if Version(np.__version__) > Version('1.14'):
    ....

@jni

jni commented Mar 2, 2018

Copy link
Copy Markdown
Member

@stefanv that seems to be The Correct Way.

@grlee77

grlee77 commented Mar 2, 2018

Copy link
Copy Markdown
Contributor

In PyWavelets/pywt#344 I was advised that a most robust way to do NumPy version comparisons is to use the NumpyVersion function from numpy itself

np.lib.NumpyVersion(np.__version__) >= '1.14.0'

I think in practice LooseVersion probably works fine here, but apparently there are some corner cases

@Borda

Borda commented Mar 2, 2018

Copy link
Copy Markdown
Contributor
>>> numpy.__version__
'1.8.1'
>>> numpy.lib.NumpyVersion(numpy.__version__) >= '1.14.0'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'NumpyVersion'

@codecov-io

Copy link
Copy Markdown

Codecov Report

Merging #2975 into master will increase coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2975      +/-   ##
==========================================
+ Coverage   86.05%   86.05%   +<.01%     
==========================================
  Files         336      336              
  Lines       27143    27143              
==========================================
+ Hits        23357    23358       +1     
+ Misses       3786     3785       -1
Impacted Files Coverage Δ
skimage/draw/_random_shapes.py 96.29% <0%> (+1.23%) ⬆️

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 e367014...8506a8c. Read the comment docs.

@soupault

soupault commented Mar 3, 2018

Copy link
Copy Markdown
Member Author

from distutils.version import LooseVersion as Version

Of course, that's a thing 😄.
Thanks for the comments, I've switched to @stefanv 's implementation.

@jni
jni merged commit 9af017f into scikit-image:master Mar 4, 2018
@soupault
soupault deleted the conftest branch March 7, 2018 12:18
@soupault soupault mentioned this pull request Jun 8, 2018
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

⏩ type: Enhancement Improve existing features 🔧 type: Maintenance Refactoring and maintenance of internals

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants