Skip to content
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

Merged
merged 15 commits into from
Jun 5, 2024
Merged

Add support for numpy 2 #2421

merged 15 commits into from
Jun 5, 2024

Conversation

Ericgig
Copy link
Member

@Ericgig Ericgig commented May 8, 2024

Description
Add support for the up comming numpy v2:

  • Allows qutip to be compiled with numpy 2, and pass tests.
  • Test that binaries compiled with numpy 2 are compatible with numpy 1 at runtime.

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 and setup.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 by np.trapezoid. Since there are no overlaps, I opted to use scipy.integrate.trapezoid instead.
  • np.array(1, np.int32) * 2**33 will enforce the integer type and overflow.
  • Py_intptr_t from python.h is no longer available through numpy cython interface.

@coveralls
Copy link

coveralls commented May 8, 2024

Coverage Status

coverage: 86.293% (+0.03%) from 86.267%
when pulling cbd9f91 on Ericgig:misc.np2
into 4acc9f1 on qutip:master.

Copy link
Contributor

@hodgestar hodgestar left a 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.

qutip/core/data/make.py Outdated Show resolved Hide resolved
qutip/utilities.py Show resolved Hide resolved
qutip/utilities.py Outdated Show resolved Hide resolved
@hodgestar
Copy link
Contributor

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.

Copy link
Contributor

@eendebakpt eendebakpt left a 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 16th (see numpy/numpy#24300 (comment))

.github/workflows/tests.yml Outdated Show resolved Hide resolved
.github/workflows/tests.yml Outdated Show resolved Hide resolved
Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
@Ericgig Ericgig requested a review from hodgestar June 4, 2024 20:31
@Ericgig Ericgig merged commit fe5e416 into qutip:master Jun 5, 2024
13 checks passed
@Ericgig Ericgig deleted the misc.np2 branch June 5, 2024 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants