Skip to content

Commit 39c5712

Browse files
committed
wip: N-D LinearOperator
[skip ci]
1 parent c176cad commit 39c5712

File tree

4 files changed

+118
-71
lines changed

4 files changed

+118
-71
lines changed

scipy/sparse/_sputils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,14 +369,14 @@ def isintlike(x) -> bool:
369369
return True
370370

371371

372-
def isshape(x, nonneg=False, *, allow_nd=(2,)) -> bool:
372+
def isshape(x, nonneg=False, *, allow_nd=(2,), check_nd=True) -> bool:
373373
"""Is x a valid tuple of dimensions?
374374
375375
If nonneg, also checks that the dimensions are non-negative.
376376
Shapes of length in the tuple allow_nd are allowed.
377377
"""
378378
ndim = len(x)
379-
if ndim not in allow_nd:
379+
if check_nd and ndim not in allow_nd:
380380
return False
381381

382382
for d in x:

scipy/sparse/linalg/_eigen/_svds.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ def _iv(A, k, ncv, tol, which, v0, maxiter,
3434
if math.prod(A.shape) == 0:
3535
message = "`A` must not be empty."
3636
raise ValueError(message)
37+
if len(A.shape) != 2:
38+
raise ValueError("Only 2-D input is supported for `A` (a single matrix)")
3739

3840
# input validation/standardization for `k`
3941
kmax = min(A.shape) if solver == 'propack' else min(A.shape) - 1

scipy/sparse/linalg/_eigen/tests/test_svds.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ class SVDSCommonTests:
133133
_A_empty_msg = "`A` must not be empty."
134134
_A_dtype_msg = "`A` must be of numeric data type"
135135
_A_type_msg = "type not understood"
136-
_A_ndim_msg = "array must have ndim <= 2"
136+
_A_ndim_msg = "Only 2-D input"
137137
_A_validation_inputs = [
138138
(np.asarray([[]]), ValueError, _A_empty_msg),
139139
(np.array([['a', 'b'], ['c', 'd']], dtype='object'), ValueError, _A_dtype_msg),

0 commit comments

Comments
 (0)