Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions pixi.lock

Large diffs are not rendered by default.

16 changes: 11 additions & 5 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ solve-group = "default"

[environments.ipython]
# tasks: ipython
features = ["run-deps", "test-deps", "ipython"]
features = ["run-deps", "test-deps", "ipython-dep", "ipython-task"]
solve-group = "default"

[environments.build-debug]
Expand Down Expand Up @@ -77,8 +77,8 @@ features = ["run-deps", "test-deps", "mkl", "torch-cpu", "torch-cpu-tasks"]
solve-group = "array-api-cpu"

[environments.array-api-cpu]
# tasks: test-cpu
features = ["run-deps", "test-deps", "test-cpu", "mkl", "array_api_strict", "dask", "jax-cpu", "marray", "torch-cpu"]
# tasks: test-cpu, ipython-cpu
features = ["run-deps", "test-deps", "test-cpu", "mkl", "array_api_strict", "dask", "jax-cpu", "marray", "torch-cpu", "ipython-dep", "ipython-cpu-task"]
solve-group = "array-api-cpu"

[environments.build-cuda]
Expand Down Expand Up @@ -221,14 +221,20 @@ description = "Build the documentation"

### IPython ###

[feature.ipython.dependencies]
[feature.ipython-dep.dependencies]
ipython = "*"

[feature.ipython.tasks.ipython]
[feature.ipython-task.tasks.ipython]
cmd = "spin ipython --no-build"
depends-on = "build"
description = "Launch IPython"

[feature.ipython-cpu-task.tasks.ipython-cpu]
cmd = "spin ipython --build-dir=build-cpu --no-build"
depends-on = "build-cpu"
env.SCIPY_ARRAY_API = "1"
description = "Launch IPython"


### Debugging ###

Expand Down
4 changes: 4 additions & 0 deletions scipy/_lib/_array_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1028,3 +1028,7 @@ def xp_device_type(a: Array) -> Literal["cpu", "cuda", None]:
return xp_device_type(a._meta)
# array-api-strict is a stand-in for unknown libraries; don't special-case it
return None


def xp_isscalar(x):
return np.isscalar(x) or (is_array_api_obj(x) and x.ndim == 0)
4 changes: 2 additions & 2 deletions scipy/sparse/_sputils.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,14 +369,14 @@ def isintlike(x) -> bool:
return True


def isshape(x, nonneg=False, *, allow_nd=(2,)) -> bool:
def isshape(x, nonneg=False, *, allow_nd=(2,), check_nd=True) -> bool:
"""Is x a valid tuple of dimensions?

If nonneg, also checks that the dimensions are non-negative.
Shapes of length in the tuple allow_nd are allowed.
"""
ndim = len(x)
if ndim not in allow_nd:
if check_nd and ndim not in allow_nd:
return False

for d in x:
Expand Down
2 changes: 2 additions & 0 deletions scipy/sparse/linalg/_eigen/_svds.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def _iv(A, k, ncv, tol, which, v0, maxiter,
if math.prod(A.shape) == 0:
message = "`A` must not be empty."
raise ValueError(message)
if len(A.shape) != 2:
raise ValueError("Only 2-D input is supported for `A` (a single matrix)")

# input validation/standardization for `k`
kmax = min(A.shape) if solver == 'propack' else min(A.shape) - 1
Expand Down
2 changes: 1 addition & 1 deletion scipy/sparse/linalg/_eigen/tests/test_svds.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class SVDSCommonTests:
_A_empty_msg = "`A` must not be empty."
_A_dtype_msg = "`A` must be of numeric data type"
_A_type_msg = "type not understood"
_A_ndim_msg = "array must have ndim <= 2"
_A_ndim_msg = "Only 2-D input"
_A_validation_inputs = [
(np.asarray([[]]), ValueError, _A_empty_msg),
(np.array([['a', 'b'], ['c', 'd']], dtype='object'), ValueError, _A_dtype_msg),
Expand Down
Loading