Skip to content

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.

@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))

@Ericgig Ericgig requested a review from hodgestar June 4, 2024 20:31
@Ericgig Ericgig merged commit fe5e416 into qutip:master Jun 5, 2024
@Ericgig Ericgig deleted the misc.np2 branch June 5, 2024 14:32
Ericgig added a commit to Ericgig/qutip that referenced this pull request Jun 20, 2024
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.

4 participants