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

Already on GitHub? Sign in to your account

Fix numpy version comparisons #2998

Closed
rgommers opened this Issue Oct 16, 2013 · 15 comments

Comments

Projects
None yet
5 participants
Owner

rgommers commented Oct 16, 2013

In many places we're checking the numpy version by comparing strings. This will break when numpy gets to 1.10. Need to fix this all over the codebase for the next release.

Member

jakevdp commented Oct 16, 2013

oops... duplicate of #2999

Owner

rgommers commented Oct 16, 2013

Should probably use LooseVersion.

Owner

rgommers commented Nov 17, 2013

LooseVersion is brain-damaged:

In [13]: LooseVersion('1.7.0-rc1') > LooseVersion('1.7.0')
Out[13]: True

Following PEP 386 by taking over part of https://bitbucket.org/tarek/distutilsversion/src as private utils in scipy.lib is the way to go I think.

Member

josef-pkt commented Nov 17, 2013

maybe numpy and scipy should follow the standard for alpha to rc version numbers that LooseVersion understand.

IIRC from last time I looked. (I had problems in statsmodels with a scipy 0.12-xxx)

Owner

rgommers commented Nov 17, 2013

It doesn't understand any version scheme. From PEP 386:

This class makes any version string valid, and provides an algorithm
to sort them numerically then lexically.

StrictVersion makes an attempt, but chokes on version strings of dev versions.

Owner

rgommers commented Dec 23, 2013

This tripped me up again today. Fix in progress.

Contributor

Juanlu001 commented Dec 23, 2013

I saw you were fast and went to distutils2 :) there's also distlib:

https://bitbucket.org/pypa/distlib/src/ff84b9881e6d23d2e327f507f124b7cd45e57829/distlib/version.py

which, in theory, is what evolved from distutils2.

Owner

rgommers commented Dec 24, 2013

Thanks for the link. I already figured out that NormalizedVersion also doesn't work (doesn't recognize dev version strings). So I went with writing one myself: https://github.com/rgommers/scipy/compare/version-compare

Contributor

Juanlu001 commented Dec 24, 2013

Really? I haven't tried the code myself, but in theory 'dev' is present in the possible prerelase tags:

https://bitbucket.org/pypa/distlib/src/ff84b9881e6d23d2e327f507f124b7cd45e57829/distlib/version.py#cl-268

Contributor

Juanlu001 commented Dec 24, 2013

Fair enough, apparently it has to be [.devN]. so .dev, .dev-f1234afa and .dev-Unknown won't work. Too bad.

Member

WarrenWeckesser commented Dec 24, 2013

@rgommers: Is your version code part of a pull request, or still work-in-progress? Is it too early for comments yet?

Owner

rgommers commented Dec 24, 2013

Still WIP, needs some refactoring and still has one bug. Ran out of time for now, time for Christmas.

Owner

rgommers commented Dec 24, 2013

Happy holidays by the way!

Contributor

Juanlu001 commented Dec 24, 2013

Merry Christmas to everyone 🎄

Owner

rgommers commented Dec 25, 2013

Now it's ready for review, PR sent.

@argriffing argriffing closed this in #3170 Dec 26, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment