-
Notifications
You must be signed in to change notification settings - Fork 620
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
Add support for numpy 2 #2421
base: master
Are you sure you want to change the base?
Add support for numpy 2 #2421
Conversation
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.
Woot for starting to get things ready for numpy 2. Did a quick review of the changes so far. Most look good.
@@ -108,7 +108,7 @@ def clebsch(j1, j2, j3, m1, m2, m3): | |||
C = np.sqrt((2.0 * j3 + 1.0)*_to_long(c_factor)) | |||
|
|||
s_factors = np.zeros(((vmax + 1 - vmin), (int(j1 + j2 + j3))), np.int32) | |||
sign = (-1) ** (vmin + j2 + m2) | |||
sign = int((-1) ** (vmin + j2 + m2)) |
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.
Why did this need to be wrapped with int
?
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.
clebsch
is computed using large integer over 32 and sometime 64 bits.
If the sign is a 0d numpy array it overflow.
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.
Ah. Perhaps add a comment above this line with that explanation?
Numpy is maintaining a list of project versions that support numpy 2 -- numpy/numpy#26191. They're waiting of downstream packages to be ready before release. We could add ourselves there if we liked. |
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.
Numpy 2.0 is scheduled to be released June 6th (see numpy/numpy#24300 (comment))
os: ubuntu-latest | ||
python-version: "3.12" | ||
scipy-requirement: "" | ||
numpy-requirement: "==2.0.0rc1" |
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.
numpy-requirement: "==2.0.0rc1" | |
numpy-requirement: "==2.0.0rc2" |
There is a new release candidate available
os: ubuntu-latest | ||
python-version: "3.10" | ||
scipy-requirement: "" | ||
numpy-requirement: "==2.0.0rc1" |
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.
numpy-requirement: "==2.0.0rc1" | |
numpy-requirement: "==2.0.0rc2" |
Description
Add support for the up comming numpy v2:
I did not update the requirement yet, it must be installed in
--no-build-isolation
.When it's officially released, we will need to update
pyproject.toml
andsetup.cfg
, and possibly add test for np2 on windows and mac.Here are the changes that affect us:
np.array(.., copy=False)
no longer mean copy only if needed.copy=None
was added for that.np.trapz
was replaced bynp.trapezoid
. Since there are no overlaps, I opted to usescipy.integrate.trapezoid
instead.np.array(1, np.int32) * 2**33
will enforce the integer type and overflow.Py_intptr_t
frompython.h
is no longer available through numpy cython interface.