vprusso / toqito

|toqito> (Theory of Quantum Information Toolkit) in Python :snake:
https://toqito.readthedocs.io/en/latest/
MIT License
141 stars 57 forks source link

Update numpy requirement from 1.26.4 to 2.0.0 #656

Closed dependabot[bot] closed 1 month ago

dependabot[bot] commented 3 months ago

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 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.

codecov[bot] commented 3 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

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

Additional details and impacted files ```diff @@ 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 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

purva-thakre commented 2 months ago

@dependabot rebase

purva-thakre commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

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.

vprusso commented 2 months ago

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 commented 2 months ago

@dependabot rebase

dependabot[bot] commented 2 months ago

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.

purva-thakre commented 2 months ago

Will check on what the installation issues mean later.

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

purva-thakre commented 2 months ago

Closing this for a new PR. I can't figure out the source of the build error.

I don't see similar errors locally. 🤷🏾‍♀️

dependabot[bot] commented 2 months ago

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.

purva-thakre commented 2 months ago
  1. If https://github.com/vprusso/toqito/pull/656/commits/8a1283bd94a2d123073a39883c242e66db7865bc 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 commented 2 months ago

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

https://github.com/python-poetry/poetry/issues/7611

purva-thakre commented 2 months ago

https://github.com/vprusso/toqito/pull/656/commits/307e79830bcb7e595f496b3ade99cdb63daf9184 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 commented 2 months ago

https://github.com/python-poetry/poetry/issues/7583#issuecomment-1453161741

dependabot[bot] commented 2 months ago

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 commented 1 month ago

@dependabot recreate

dependabot[bot] commented 1 month ago

Superseded by #752.