Skip to content

Conversation

@edoaltamura
Copy link
Collaborator

Summary

Updates the argument definitions for the optimisers to match those in SciPy 1.16, similarly to qiskit-community/qiskit-algorithms#234

Fixes #957

@edoaltamura edoaltamura added the dependencies 🔗 Involves external dependency libraries label Jul 18, 2025
@edoaltamura edoaltamura added the stable backport potential The bug might be minimal and/or import enough to be port to stable label Jul 18, 2025
@edoaltamura
Copy link
Collaborator Author

Now the .ravel() imposes gradients (jac) passed to optimisers like SLSQP to be strictly 1D arrays, required for compatibility with SciPy ≥1.16. Previously, we only wrapped gradients for the l-bfgs-b method and sometimes returned lists or higher-dimensional arrays, leading to errors. The fix generalises gradient wrapping for all methods and updates _wrap_gradient to always return a flattened 1D NumPy array via .ravel(), ensuring consistent behaviour across optimisers. This resolves test failures, and remains fully backwards-compatible with earlier SciPy versions.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 17434461518

Details

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.04%) to 90.597%

Totals Coverage Status
Change from base Build 17430028152: 0.04%
Covered Lines: 4625
Relevant Lines: 5105

💛 - Coveralls

@OkuyanBoga OkuyanBoga merged commit 8fce265 into qiskit-community:main Sep 3, 2025
28 of 29 checks passed
mergify bot pushed a commit that referenced this pull request Sep 3, 2025
* Set scipy>=1.16

* Release pinned scipy and change x0 for cobyla

* Enforces 1D arrays in all jac modes as per scipy 1.16

* Fix formatting

* Fix copyright

---------

Co-authored-by: M. Emre Sahin <40424147+OkuyanBoga@users.noreply.github.com>
(cherry picked from commit 8fce265)

# Conflicts:
#	test/datasets/test_entanglement_concentration.py
@edoaltamura edoaltamura deleted the scipy1p16 branch September 3, 2025 14:12
@edoaltamura edoaltamura restored the scipy1p16 branch September 3, 2025 14:58
@edoaltamura edoaltamura added stable backport potential The bug might be minimal and/or import enough to be port to stable and removed stable backport potential The bug might be minimal and/or import enough to be port to stable labels Sep 3, 2025
@edoaltamura edoaltamura deleted the scipy1p16 branch September 3, 2025 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies 🔗 Involves external dependency libraries stable backport potential The bug might be minimal and/or import enough to be port to stable

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nightly actions failing due to Scipy 1.16

4 participants