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

Update numpy requirement from 1.26.4 to 2.0.0 #656

Closed
wants to merge 14 commits into from

Conversation

dependabot[bot]
Copy link
Contributor

@dependabot dependabot bot commented on behalf of github Jul 8, 2024

Fixes #618

Updates the requirements on numpy to permit the latest version.

Release notes

Sourced from numpy's releases.

v2.0.0

NumPy 2.0.0 Release Notes

NumPy 2.0.0 is the first major release since 2006. It is the result of 11 months of development since the last feature release and is the work of 212 contributors spread over 1078 pull requests. It contains a large number of exciting new features as well as changes to both the Python and C APIs.

This major release includes breaking changes that could not happen in a regular minor (feature) release - including an ABI break, changes to type promotion rules, and API changes which may not have been emitting deprecation warnings in 1.26.x. Key documents related to how to adapt to changes in NumPy 2.0, in addition to these release notes, include:

Highlights

Highlights of this release include:

  • New features:
    • A new variable-length string dtype, numpy.dtypes.StringDType and a new numpy.strings namespace with performant ufuncs for string operations,
    • Support for float32 and longdouble in all numpy.fft functions,
    • Support for the array API standard in the main numpy namespace.
  • Performance improvements:
    • Sorting functions sort, argsort, partition, argpartition have been accelerated through the use of the Intel x86-simd-sort and Google Highway libraries, and may see large (hardware-specific) speedups,
    • macOS Accelerate support and binary wheels for macOS >=14, with significant performance improvements for linear algebra operations on macOS, and wheels that are about 3 times smaller,
    • numpy.char fixed-length string operations have been accelerated by implementing ufuncs that also support numpy.dtypes.StringDType in addition to the fixed-length string dtypes,
    • A new tracing and introspection API, numpy.lib.introspect.opt_func_info, to determine which hardware-specific kernels are available and will be dispatched to.
    • numpy.save now uses pickle protocol version 4 for saving arrays with object dtype, which allows for pickle objects larger than 4GB and improves saving speed by about 5% for large arrays.
  • Python API improvements:

... (truncated)

Commits
  • 1d49c7f Merge pull request #26698 from charris/prepare-2.0.0
  • 2103511 DOC: Remove duplicate in author list.
  • db8030e BUG: Change cibuildwheel version [wheel build]
  • 1a68264 REL: Prepare for the NumPy 2.0.0 release [wheel build]
  • c8665ba Merge pull request #26696 from charris/backport-26582
  • 103f4dd Merge pull request #26697 from charris/backport-25963
  • c193dcd Merge pull request #26695 from charris/backport-26667
  • 8fa8191 BUG: Fix bug in numpy.pad() (#25963)
  • ece3559 BUG: weighted nanpercentile, nanquantile and multi-dim q (#26582)
  • b31e195 BUG: Adds asanyarray to start of linalg.cross (#26667)
  • Additional commits viewable in compare view

You can trigger a rebase of this PR by commenting @dependabot rebase.


Dependabot commands and options

You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot merge will merge this PR after your CI passes on it
  • @dependabot squash and merge will squash and merge this PR after your CI passes on it
  • @dependabot cancel merge will cancel a previously requested merge and block automerging
  • @dependabot reopen will reopen this PR if it is closed
  • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
  • @dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency
  • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

Note
Automatic rebases have been disabled on this pull request as it has been open for over 30 days.

@dependabot dependabot bot added dependencies Pull requests that update a dependency file python Pull requests that update Python code labels Jul 8, 2024
Copy link

codecov bot commented Jul 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.7%. Comparing base (b1c109e) to head (fe61b1a).

Additional details and impacted files
@@          Coverage Diff           @@
##           master    #656   +/-   ##
======================================
  Coverage    97.7%   97.7%           
======================================
  Files         166     166           
  Lines        3247    3247           
  Branches      795     795           
======================================
  Hits         3174    3174           
  Misses         48      48           
  Partials       25      25           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dependabot dependabot bot force-pushed the dependabot/pip/numpy-2.0.0 branch from 3acde1f to a26db37 Compare July 8, 2024 11:39
@purva-thakre purva-thakre marked this pull request as draft July 8, 2024 13:06
@purva-thakre
Copy link
Collaborator

@dependabot rebase

@purva-thakre purva-thakre marked this pull request as ready for review July 15, 2024 00:13
@purva-thakre purva-thakre self-requested a review July 15, 2024 00:13
@dependabot dependabot bot force-pushed the dependabot/pip/numpy-2.0.0 branch from a26db37 to 39cddac Compare July 15, 2024 00:14
@purva-thakre
Copy link
Collaborator

The doc examples in this PR are still failing because the expected output is 4 but doctest calculates it as np.float64(4). Why don't we see similar failures in pytest workflows?

@purva-thakre purva-thakre marked this pull request as draft July 15, 2024 00:19
@purva-thakre purva-thakre self-assigned this Jul 15, 2024
@purva-thakre
Copy link
Collaborator

purva-thakre commented Jul 15, 2024

The failures are due to newer print options in numpy. So, it's understandable they don't appear as failures in pytest workflows as we don't use print to compare the calculated and expected outputs.

image

https://numpy.org/neps/nep-0051-scalar-representation.html

My suggestion is to change the expected outputs in docstring examples to be consistent with the new print options. WDYT @vprusso ?

We could set the print option to use an earlier version of numpy. But this does not make sense as a user will see the newer scalar representations pop up if they print something locally.

@purva-thakre
Copy link
Collaborator

purva-thakre commented Jul 15, 2024

This PR is very close. The only failure that we have to deal with is below:

File "autoapi/state_opt/symmetric_extension_hierarchy/index.rst", line 164, in default
Failed example:
    np.around(symmetric_extension_hierarchy(states=states, probs=None, level=2), decimals=2)
Exception raised:
    Traceback (most recent call last):
      File "/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/doctest.py", line 1355, in __run
        exec(compile(example.source, filename, "single",
      File "<doctest default[12]>", line 1, in <module>
        np.around(symmetric_extension_hierarchy(states=states, probs=None, level=2), decimals=2)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/runner/work/toqito/toqito/toqito/state_opt/symmetric_extension_hierarchy.py", line 197, in symmetric_extension_hierarchy
        sol_default = problem.solve()
                      ^^^^^^^^^^^^^^^
      File "/home/runner/.cache/pypoetry/virtualenvs/toqito-QfgmswsN-py3.11/lib/python3.11/site-packages/cvxpy/problems/problem.py", line 503, in solve
        return solve_func(self, *args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/runner/.cache/pypoetry/virtualenvs/toqito-QfgmswsN-py3.11/lib/python3.11/site-packages/cvxpy/problems/problem.py", line 1073, in _solve
        data, solving_chain, inverse_data = self.get_problem_data(
                                            ^^^^^^^^^^^^^^^^^^^^^^
      File "/home/runner/.cache/pypoetry/virtualenvs/toqito-QfgmswsN-py3.11/lib/python3.11/site-packages/cvxpy/problems/problem.py", line 696, in get_problem_data
        data, inverse_data = solving_chain.apply(self, verbose)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/runner/.cache/pypoetry/virtualenvs/toqito-QfgmswsN-py3.11/lib/python3.11/site-packages/cvxpy/reductions/chain.py", line 76, in apply
        problem, inv = r.apply(problem)
                       ^^^^^^^^^^^^^^^^
      File "/home/runner/.cache/pypoetry/virtualenvs/toqito-QfgmswsN-py3.11/lib/python3.11/site-packages/cvxpy/reductions/solvers/conic_solvers/scs_conif.py", line 214, in apply
        return super(SCS, self).apply(problem)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/runner/.cache/pypoetry/virtualenvs/toqito-QfgmswsN-py3.11/lib/python3.11/site-packages/cvxpy/reductions/solvers/conic_solvers/conic_solver.py", line 355, in apply
        problem, data, inv_data = self._prepare_data_and_inv_data(problem)
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/runner/.cache/pypoetry/virtualenvs/toqito-QfgmswsN-py3.11/lib/python3.11/site-packages/cvxpy/reductions/solvers/conic_solvers/conic_solver.py", line 332, in _prepare_data_and_inv_data
        problem = self.format_constraints(problem, self.EXP_CONE_ORDER)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/runner/.cache/pypoetry/virtualenvs/toqito-QfgmswsN-py3.11/lib/python3.11/site-packages/cvxpy/reductions/solvers/conic_solvers/conic_solver.py", line 264, in format_constraints
        unspecified, remainder = divmod(problem.A.shape[0] *
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    OverflowError: Python integer 2313073664 out of bounds for int32

https://github.com/vprusso/toqito/actions/runs/9933035887/job/27435221058#step:5:3171

I think it's better to disable this for now and create a separate issue for the error. It will take me a while to dig into the source of the raised error.

Copy link
Owner

@vprusso vprusso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I agree with your comment about the symmetric_extension_hierarchy function and saw that you raised another issue to capture that. Modulo that though, glad to have numpy==2.0 supported! Nice work!


Calculate the purity of the Werner state:

>>> from toqito.states import werner
>>> rho = werner(2, 1 / 4)
>>> '%.4f' % purity(rho)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch, I missed this one from before!

@vprusso
Copy link
Owner

vprusso commented Jul 15, 2024

Looks great, @purva-thakre. Once the merge conflict with the poetry.lock file is resolved, I think it should be good to go!

@purva-thakre
Copy link
Collaborator

@dependabot rebase

Copy link
Contributor Author

dependabot bot commented on behalf of github Jul 15, 2024

Looks like this PR has been edited by someone other than Dependabot. That means Dependabot can't rebase it - sorry!

If you're happy for Dependabot to recreate it from scratch, overwriting any edits, you can request @dependabot recreate.

dependabot bot and others added 4 commits July 15, 2024 07:26
Updates the requirements on [numpy](https://github.com/numpy/numpy) to permit the latest version.
- [Release notes](https://github.com/numpy/numpy/releases)
- [Changelog](https://github.com/numpy/numpy/blob/main/doc/RELEASE_WALKTHROUGH.rst)
- [Commits](numpy/numpy@v1.26.4...v2.0.0)

---
updated-dependencies:
- dependency-name: numpy
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
@purva-thakre
Copy link
Collaborator

purva-thakre commented Jul 15, 2024

Will check on what the installation issues mean later.

https://github.com/vprusso/toqito/actions/runs/9939417469/job/27454339453?pr=656#step:4:283

Copy link
Contributor Author

dependabot bot commented on behalf of github Jul 15, 2024

OK, I won't notify you again about this release, but will get in touch when a new version is available. If you'd rather skip all updates until the next major or minor version, let me know by commenting @dependabot ignore this major version or @dependabot ignore this minor version. You can also ignore all major, minor, or patch releases for a dependency by adding an ignore condition with the desired update_types to your config file.

If you change your mind, just re-open this PR and I'll resolve any conflicts on it.

@dependabot dependabot bot deleted the dependabot/pip/numpy-2.0.0 branch July 15, 2024 13:21
@purva-thakre purva-thakre mentioned this pull request Jul 15, 2024
6 tasks
@purva-thakre purva-thakre restored the dependabot/pip/numpy-2.0.0 branch July 15, 2024 13:39
@purva-thakre purva-thakre reopened this Jul 15, 2024
@purva-thakre purva-thakre marked this pull request as draft July 15, 2024 13:39
@purva-thakre
Copy link
Collaborator

purva-thakre commented Jul 15, 2024

  1. If 8a1283b does not work, try doing what the error message says https://stackoverflow.com/a/64172202
  2. Or use conda to install cvxopt https://stackoverflow.com/a/67500504

We are already doing what the top voted answer recommends.

There are two different errors. cvxopt and pep 517 related SO links are above.

The other one is error: command '/usr/bin/gcc' failed with exit code 1: https://stackoverflow.com/questions/19955775/error-command-gcc-failed-with-exit-status-1-on-centos

Why do we see these failures for python 3.12 on ubuntu and macos only?

@purva-thakre
Copy link
Collaborator

Not the same error we are getting but similar pep517 messages were fixed by downgrading poetry.

python-poetry/poetry#7611

@purva-thakre
Copy link
Collaborator

purva-thakre commented Jul 17, 2024

307e798 might have worked except that cvxopt is being installed as a dependency again through poetry install.

Need to create a better dependency group.

@purva-thakre
Copy link
Collaborator

Copy link
Contributor Author

dependabot bot commented on behalf of github Jul 22, 2024

A newer version of numpy exists, but since this PR has been edited by someone other than Dependabot I haven't updated it. You'll get a PR for the updated version as normal once this PR is merged.

@purva-thakre
Copy link
Collaborator

@dependabot recreate

Copy link
Contributor Author

dependabot bot commented on behalf of github Aug 22, 2024

Superseded by #752.

@dependabot dependabot bot closed this Aug 22, 2024
@dependabot dependabot bot deleted the dependabot/pip/numpy-2.0.0 branch August 22, 2024 18:11
This was referenced Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file python Pull requests that update Python code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Numpy 2.0 will have breaking changes
2 participants