-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updates for NumPy 2 and Matplotlib 3.9 #382
Conversation
Thanks Mikhail! I suppose one option would be to switch to |
But it also seems to me that the |
Oh, yeah, good point. We shouldn't mess with the integration. It's annoying that numpy changed the name somewhat suddenly, requiring that we include extra code to check the numpy version. But, what you have seems like the best solution. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All good for me. Thanks @MikhailRyazanov
BTW, as a separate issue, on my Ubuntu 24.04 (Dell OptiPlex 7070) direct_C
quietly does not build. I am not sure how to force the compile.
@@ -5,6 +5,10 @@ | |||
from __future__ import unicode_literals | |||
|
|||
import numpy as np | |||
if hasattr(np, 'trapezoid'): # numpy >= 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with this code. However, IMO support for python2 should be dropped.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the numpy version, not python version. In this case, v2 is the upcoming version. (But otherwise I agree with you. No need to support Py2 anymore. It, and my beloved print statement without parentheses, are dead.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opps! I must be getting old.
beloved print statement without parentheses
It tried to make a come back:
LWN: The (non-)return of the Python print statement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OMG! Guido has returned to bring us back our print statement :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dropping Py2 is planned (#221), but not for right now. Basically, it will allow simplifying the code (and adding type annotations), but I don't think that just declaring that we don't support Py2 anymore without actually doing any improvements is a good thing. :–)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed!
@@ -5,6 +5,10 @@ | |||
from __future__ import unicode_literals | |||
|
|||
import numpy as np | |||
if hasattr(np, 'trapezoid'): # numpy >= 2 | |||
trapezoid = np.trapezoid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function name change is similar to what occurred for scipy.integrate.simp
to simpson
. Makes more sense to use the full name.
Sorry, I have no recollection of any of this anymore. |
NumPy is planning to release v2.0 soon (conda already wanted to rebuild for it, see conda-forge/pyabel-feedstock#27). I've tested locally with
numpy 2.0.0rc2
(from PyPI) and found that small modifications are needed to ensure compatibility with it:numpy.trapz()
was renamed tonumpy.trapezoid()
, so we'll need to use the one that is available (numpy.trapezoid()
isn't available in current versions, so we can't just switch to it;scipy.integrate.trapezoid()
wasn't present inscipy 1.2
— the last available for Python 2).numpy.NaN
(used only in one documentation figure) was removed, sonumpy.nan
should be used instead.The newest Matplotlib (v3.6.0) also complains about
plt.colorbar()
called from wrong axes (in another documentation figure), so this is also corrected here.The rest still looks fine.
I suspect that when
numpy 2.0.0
is released, we'll also have to make a minor maintenance release...