Skip to content

Commit 063d3d0

Browse files
committed
Add migration guide and PyTest fixes.
1 parent 1f1f205 commit 063d3d0

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

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/*

sparse/numba_backend/_coo/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ 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

sparse/numba_backend/_sparse_array.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ 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

0 commit comments

Comments
 (0)