Skip to content

Commit 1215a2c

Browse files
authored
Migration guide (#898)
* Drop Py3.10, test Py3.13. * Add migration guide and PyTest fixes. * `pre-commit autoupdate`
1 parent 6c7c9b5 commit 1215a2c

File tree

8 files changed

+40
-15
lines changed

8 files changed

+40
-15
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@ jobs:
1111
strategy:
1212
matrix:
1313
os: ['ubuntu-latest']
14-
python: ['3.10', '3.11', '3.12']
14+
python: ['3.11', '3.12', '3.13']
1515
pip_opts: ['']
1616
numba_boundscheck: [0]
1717
include:
1818
- os: macos-latest
19-
python: '3.10'
19+
python: '3.11'
2020
- os: windows-latest
21-
python: '3.10'
21+
python: '3.11'
2222
- os: ubuntu-latest
23-
python: '3.10'
23+
python: '3.11'
2424
numba_boundscheck: 1
2525
- os: ubuntu-latest
26-
python: '3.10'
26+
python: '3.11'
2727
pip_opts: 'numpy<2'
2828
fail-fast: false
2929
runs-on: ${{ matrix.os }}

.pre-commit-config.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v5.0.0
3+
rev: v6.0.0
44
hooks:
55
- id: check-yaml
66
- id: end-of-file-fixer
77
- id: trailing-whitespace
88
- id: fix-byte-order-marker
99
- id: destroyed-symlinks
10-
- id: fix-encoding-pragma
11-
args: ["--remove"]
1210
- id: mixed-line-ending
1311
- id: name-tests-test
1412
args: ["--pytest-test-first"]
@@ -18,7 +16,7 @@ repos:
1816
exclude: ".ipynb"
1917

2018
- repo: https://github.com/astral-sh/ruff-pre-commit
21-
rev: v0.12.7
19+
rev: v0.13.1
2220
hooks:
2321
- id: ruff-check
2422
args: ["--fix"]

docs/migration-jl.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Migration to the Finch Julia backend
2+
To switch to the Finch Julia backend, set the environment variable `SPARSE_BACKEND="Finch"`, then continue using.
3+
4+
While this is largely compatible with the Array API, support for some functions may not be present, and API compatibility isn't strictly preserved with the default (Numba) backend.
5+
6+
However, the new backend has a large performance benefit over the default backend. Below, you will find a table of common invocations, with their equivalents in the Finch Julia backend. The most common change is a standard API for construction of arrays.
7+
8+
| Numba Backend<br>(`SPARSE_BACKEND="Numba"`) | Finch Julia Backend<br>(`SPARSE_BACKEND="Finch"`) | Notes |
9+
|---------------------------------------------|----------------------------------------------------|-------|
10+
| `sparse.COO.from_numpy(arr, fill_value=fv)`<br>`sparse.COO.from_scipy(arr)`<br>`sparse.COO(x)` | `sparse.asarray(x, format="coo", [fill_value=fv])` | Doesn't support pulling out individual arrays |
11+
| `sparse.GCXS.from_numpy(arr, fill_value=fv)`<br>`sparse.GCXS.from_scipy(arr)`<br>`sparse.GCXS(x)` | `sparse.asarray(x, format="csf", [fill_value=fv])` | Format might not be a 1:1 match |
12+
| `sparse.DOK.from_numpy(arr, fill_value=fv)`<br>`sparse.DOK.from_scipy(arr)`<br>`sparse.DOK(x)` | `sparse.asarray(x, format="dok", [fill_value=fv])` | Format might not be a 1:1 match |
13+
14+
Most things work as expected, with the following exceptions, which aren't defined yet for Finch:
15+
16+
* `sparse.broadcast_to`
17+
* `sparse.solve`
18+
* Statistical functions: `mean`, `std`, `var`
19+
* `sparse.isdtype`
20+
* `sparse.reshape`
21+
* Some elementwise functions
22+
* Manipulation functions: `concat`, `expand_dims`, `squeeze`, `flip`, `roll`, `stack`
23+
* `arg*` functions: `argmin`, `argmax`
24+
* Sorting functions: `sort`, `argsort`
25+
26+
IEEE-754 compliance is hard to maintain with sparse arrays in general. This is now even more true of the Julia backend, which trades off performance for IEEE-754 compatibility.

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ nav:
9191
- quickstart.md
9292
- construct.md
9393
- operations.md
94+
- migration-jl.md
9495
- API:
9596
- api.md
9697
- api/*

pixi.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ numba = ">=0.49"
1010
numpy = ">=1.17"
1111

1212
[dependencies]
13-
python = ">=3.10,<3.13"
13+
python = ">=3.11,<3.14"
1414

1515
[feature.extra.pypi-dependencies]
1616
dask = { version = ">=2024", extras = ["array"] }

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ description = "Sparse n-dimensional arrays for the PyData ecosystem"
99
readme = "README.md"
1010
dependencies = ["numpy>=1.17", "numba>=0.49"]
1111
maintainers = [{ name = "Hameer Abbasi", email = "hameerabbasi@yahoo.com" }]
12-
requires-python = ">=3.10"
12+
requires-python = ">=3.11"
1313
license = { file = "LICENSE" }
1414
keywords = ["sparse", "numpy", "scipy", "dask"]
1515
classifiers = [

sparse/numba_backend/_coo/core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -596,12 +596,12 @@ def nnz(self):
596596
--------
597597
>>> x = np.array([0, 0, 1, 0, 1, 2, 0, 1, 2, 3, 0, 0])
598598
>>> np.count_nonzero(x)
599-
6
599+
np.int64(6)
600600
>>> s = COO.from_numpy(x)
601601
>>> s.nnz
602602
6
603603
>>> np.count_nonzero(x) == s.nnz
604-
True
604+
np.True_
605605
"""
606606
return self.coords.shape[1]
607607

sparse/numba_backend/_sparse_array.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,12 @@ def nnz(self):
8282
>>> from sparse import COO
8383
>>> x = np.array([0, 0, 1, 0, 1, 2, 0, 1, 2, 3, 0, 0])
8484
>>> np.count_nonzero(x)
85-
6
85+
np.int64(6)
8686
>>> s = COO.from_numpy(x)
8787
>>> s.nnz
8888
6
8989
>>> np.count_nonzero(x) == s.nnz
90-
True
90+
np.True_
9191
"""
9292

9393
@property

0 commit comments

Comments
 (0)