Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix numpy version comparisons #2998

Closed
rgommers opened this Issue · 15 comments

5 participants

Ralf Gommers Jake Vanderplas Josef Perktold Juan Luis Cano Rodríguez Warren Weckesser
Ralf Gommers
Owner

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.

Jake Vanderplas
Collaborator

oops... duplicate of #2999

Ralf Gommers
Owner

Should probably use LooseVersion.

Ralf Gommers
Owner

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.

Josef Perktold
Collaborator

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)

Ralf Gommers
Owner

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.

Ralf Gommers
Owner

This tripped me up again today. Fix in progress.

Juan Luis Cano Rodríguez

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.

Ralf Gommers
Owner

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

Juan Luis Cano Rodríguez

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

Juan Luis Cano Rodríguez

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

Warren Weckesser
Collaborator

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

Ralf Gommers
Owner

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

Ralf Gommers rgommers referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
Ralf Gommers
Owner

Happy holidays by the way!

Juan Luis Cano Rodríguez

Merry Christmas to everyone :christmas_tree:

Ralf Gommers
Owner

Now it's ready for review, PR sent.

argriffing argriffing closed this in #3170
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.