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
10,188 changes: 2,063 additions & 8,125 deletions pixi.lock

Large diffs are not rendered by default.

245 changes: 142 additions & 103 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,115 +26,120 @@ 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]
# tasks: build-debug
features = ["build-deps", "build-debug"]
solve-group = "debug"

[environments.lldb]
# tasks: lldb
features = ["run-deps", "test-deps", "lldb"]
solve-group = "debug"

[environments.gdb]
# tasks: gdb
features = ["run-deps", "test-deps", "gdb"]
solve-group = "debug"

[environments.lint]
# tasks: lint, check-python-h
features = ["lint"]

# TODO(lucascolley): merge the `default` and `array-api-cpu` solve groups,
# and create a non-default solve group with minimal dependencies
# to more reliably test the very latest versions of core dependencies
[environments.build-cpu]
# tasks: build-cpu
features = ["build-deps", "build-cpu"]
solve-group = "array-api-cpu"

[environments.array-api-strict]
# tasks: test-strict
features = ["run-deps", "test-deps", "array_api_strict", "array_api_strict-tasks"]
solve-group = "array-api-cpu"

[environments.dask-cpu]
# tasks: test-dask
features = ["run-deps", "test-deps", "dask", "dask-tasks"]
solve-group = "array-api-cpu"

[environments.jax-cpu]
# tasks: test-jax
features = ["run-deps", "test-deps", "mkl", "jax-cpu", "jax-cpu-tasks"]
solve-group = "array-api-cpu"

[environments.torch-cpu]
# tasks: test-torch, test-torch-float32
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"]
solve-group = "array-api-cpu"

[environments.build-cuda]
# tasks: build-cuda
# note: py-cuda feature aims to ensure compatibility with both cuda12 and cuda13 solve groups
features = ["build-deps", "build-cuda", "py-cuda"]

[environments.cupy]
# tasks: test-cupy
features = ["run-deps", "test-deps", "cuda13", "py-cuda", "cupy"]
solve-group = "cuda13"

[environments.jax-cuda]
# tasks: test-jax-cuda
features = ["run-deps", "test-deps", "cuda12", "py-cuda", "mkl", "jax-cuda"]
solve-group = "cuda12"

[environments.torch-cuda]
# tasks: test-torch-cuda
features = ["run-deps", "test-deps", "cuda12", "py-cuda", "mkl", "torch-cuda"]
solve-group = "cuda12"

[environments.build-accelerate-lp64]
# tasks: build-accelerate-lp64
features = ["build-deps", "accelerate", "build-accelerate-lp64"]
solve-group = "accelerate-lp64"

[environments.accelerate-lp64]
# tasks: test-accelerate-lp64
features = ["run-deps", "test-deps", "accelerate", "accelerate-lp64"]
solve-group = "accelerate-lp64"

[environments.build-accelerate-ilp64]
# tasks: build-accelerate-ilp64
features = ["build-deps", "accelerate", "build-accelerate-ilp64"]
solve-group = "accelerate-ilp64"

[environments.accelerate-ilp64]
# tasks: test-accelerate-ilp64
features = ["run-deps", "test-deps", "accelerate", "accelerate-ilp64"]
solve-group = "accelerate-ilp64"

[environments.py311-system-libs-osx]
# tasks: build-system-libs, test-system-libs
features = ["build-deps", "run-deps", "test-deps", "py311", "umfpack", "scikit-sparse", "system-libs"]

[environments.scipy-openblas]
# tasks: build-scipy-openblas, test-scipy-openblas
features = ["build-deps", "run-deps", "test-deps", "scipy-openblas"]
[environments.profile]
# tasks: profile-shell
features = ["run-deps", "profile"]
solve-group = "default"

# [environments.build-debug]
# # tasks: build-debug
# features = ["build-deps", "build-debug"]
# solve-group = "debug"

# [environments.lldb]
# # tasks: lldb
# features = ["run-deps", "test-deps", "lldb"]
# solve-group = "debug"

# [environments.gdb]
# # tasks: gdb
# features = ["run-deps", "test-deps", "gdb"]
# solve-group = "debug"

# [environments.lint]
# # tasks: lint, check-python-h
# features = ["lint"]

# # TODO(lucascolley): merge the `default` and `array-api-cpu` solve groups,
# # and create a non-default solve group with minimal dependencies
# # to more reliably test the very latest versions of core dependencies
# [environments.build-cpu]
# # tasks: build-cpu
# features = ["build-deps", "build-cpu"]
# solve-group = "array-api-cpu"

# [environments.array-api-strict]
# # tasks: test-strict
# features = ["run-deps", "test-deps", "array_api_strict", "array_api_strict-tasks"]
# solve-group = "array-api-cpu"

# [environments.dask-cpu]
# # tasks: test-dask
# features = ["run-deps", "test-deps", "dask", "dask-tasks"]
# solve-group = "array-api-cpu"

# [environments.jax-cpu]
# # tasks: test-jax
# features = ["run-deps", "test-deps", "mkl", "jax-cpu", "jax-cpu-tasks"]
# solve-group = "array-api-cpu"

# [environments.torch-cpu]
# # tasks: test-torch, test-torch-float32
# features = ["run-deps", "test-deps", "mkl", "torch-cpu", "torch-cpu-tasks"]
# solve-group = "array-api-cpu"

# [environments.array-api-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]
# # tasks: build-cuda
# # note: py-cuda feature aims to ensure compatibility with both cuda12 and cuda13 solve groups
# features = ["build-deps", "build-cuda", "py-cuda"]

# [environments.cupy]
# # tasks: test-cupy
# features = ["run-deps", "test-deps", "cuda13", "py-cuda", "cupy"]
# solve-group = "cuda13"

# [environments.jax-cuda]
# # tasks: test-jax-cuda
# features = ["run-deps", "test-deps", "cuda12", "py-cuda", "mkl", "jax-cuda"]
# solve-group = "cuda12"

# [environments.torch-cuda]
# # tasks: test-torch-cuda
# features = ["run-deps", "test-deps", "cuda12", "py-cuda", "mkl", "torch-cuda"]
# solve-group = "cuda12"

# [environments.build-accelerate-lp64]
# # tasks: build-accelerate-lp64
# features = ["build-deps", "accelerate", "build-accelerate-lp64"]
# solve-group = "accelerate-lp64"

# [environments.accelerate-lp64]
# # tasks: test-accelerate-lp64
# features = ["run-deps", "test-deps", "accelerate", "accelerate-lp64"]
# solve-group = "accelerate-lp64"

# [environments.build-accelerate-ilp64]
# # tasks: build-accelerate-ilp64
# features = ["build-deps", "accelerate", "build-accelerate-ilp64"]
# solve-group = "accelerate-ilp64"

# [environments.accelerate-ilp64]
# # tasks: test-accelerate-ilp64
# features = ["run-deps", "test-deps", "accelerate", "accelerate-ilp64"]
# solve-group = "accelerate-ilp64"

# [environments.py311-system-libs-osx]
# # tasks: build-system-libs, test-system-libs
# features = ["build-deps", "run-deps", "test-deps", "py311", "umfpack", "scikit-sparse", "system-libs"]

# [environments.scipy-openblas]
# # tasks: build-scipy-openblas, test-scipy-openblas
# features = ["build-deps", "run-deps", "test-deps", "scipy-openblas"]


### Default dependencies (included in all environments) ###

[dependencies]
spin = "*"
python = "*"
python = "3.13.*"


### Default run dependencies (for environments which run SciPy itself) ###
Expand Down Expand Up @@ -221,14 +226,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 Expand Up @@ -265,6 +276,34 @@ depends-on = "build-debug"
description = "Debug with gdb"


### Profiling ###

[feature.profile.dependencies]
py-spy = "*"

[feature.profile.pypi-dependencies]
flamegraph.git = "https://github.com/nickodell/python-flamegraph.git"

[feature.profile.tasks._log_flamegraph]
cmd = "spin run 'cd tools && python -m flamegraph -o {{ log_name }}.log {{ script_name }}.py'"
args = ["script_name", "log_name"]
depends-on = "build"

[feature.profile.tasks.flamegraph]
cmd = "./flamegraph.pl {{ log_name }}.log > {{ log_name }}.svg"
args = ["script_name", "log_name"]
cwd = "tools"
depends-on = [{ task = "_log_flamegraph", args = ["{{ script_name }}", "{{ log_name }}"]}]
description = "Generate a flamegraph {{ log_name }}.svg from {{ script_name }}.py"

[feature.profile.tasks.py-spy]
cmd = "sudo py-spy record -o {{ log_name }}.svg -- python {{ script_name }}.py"
args = ["script_name", "log_name"]
cwd = "tools"
depends-on = "build"
description = "Generate a py-spy flamegraph {{ log_name }}.svg from {{ script_name }}.py"


### Linting ###

[feature.lint]
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