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

TST: Adapt to __array__(copy=True) #20533

Merged
merged 1 commit into from Apr 19, 2024
Merged

Conversation

thalassemia
Copy link
Contributor

Fixes test failures pointed out in #20510 (comment) due to numpy enforcing __array__(copy=True) in numpy/numpy#26215.

@github-actions github-actions bot added scipy.linalg scipy.optimize maintenance Items related to regular maintenance tasks labels Apr 19, 2024
@tylerjereddy tylerjereddy added this to the 1.14.0 milestone Apr 19, 2024
@tylerjereddy
Copy link
Contributor

Indeed, the patch below the fold does the trick for me locally, with both runtime versions of NumPy

--- a/scipy/optimize/_nonlin.py
+++ b/scipy/optimize/_nonlin.py
@@ -13,6 +13,7 @@ import scipy.sparse.linalg
 import scipy.sparse
 from scipy.linalg import get_blas_funcs
 from scipy._lib._util import getfullargspec_no_self as _getfullargspec
+from scipy._lib._util import copy_if_needed
 from ._linesearch import scalar_search_wolfe1, scalar_search_armijo
 
 
@@ -701,7 +702,7 @@ class LowRankMatrix:
 
     def collapse(self):
         """Collapse the low-rank matrix to a full-rank one."""
-        self.collapsed = np.array(self, copy=None)
+        self.collapsed = np.array(self, copy=copy_if_needed)
         self.cs = None
         self.ds = None
         self.alpha = None

@tylerjereddy tylerjereddy merged commit b4f3037 into scipy:main Apr 19, 2024
29 of 30 checks passed
@tylerjereddy tylerjereddy added the backport-candidate This fix should be ported by a maintainer to previous SciPy versions. label May 16, 2024
@tylerjereddy tylerjereddy modified the milestones: 1.14.0, 1.13.1 May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-candidate This fix should be ported by a maintainer to previous SciPy versions. maintenance Items related to regular maintenance tasks scipy.linalg scipy.optimize
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants