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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions scipy/linalg/_testutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ def __init__(self, data):
self._data = data

def __array__(self, dtype=None, copy=None):
if copy:
return self._data.copy()
return self._data


Expand Down
3 changes: 2 additions & 1 deletion scipy/optimize/_nonlin.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import scipy.sparse.linalg
import scipy.sparse
from scipy.linalg import get_blas_funcs
from scipy._lib._util import copy_if_needed
from scipy._lib._util import getfullargspec_no_self as _getfullargspec
from ._linesearch import scalar_search_wolfe1, scalar_search_armijo

Expand Down Expand Up @@ -701,7 +702,7 @@ def __array__(self, dtype=None, copy=None):

def collapse(self):
"""Collapse the low-rank matrix to a full-rank one."""
self.collapsed = np.array(self)
self.collapsed = np.array(self, copy=copy_if_needed)
self.cs = None
self.ds = None
self.alpha = None
Expand Down