Skip to content

Commit 2fe3c9a

Browse files
authored
Merge pull request #141 from asmeurer/release
1.7 release
2 parents 44bf2af + 87ba0d8 commit 2fe3c9a

File tree

9 files changed

+42
-21
lines changed

9 files changed

+42
-21
lines changed

array_api_compat/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
this implementation for the default when working with NumPy arrays.
1818
1919
"""
20-
__version__ = '1.6'
20+
__version__ = '1.7'
2121

2222
from .common import * # noqa: F401, F403

array_api_compat/common/_helpers.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def is_numpy_array(x):
5050
is_torch_array
5151
is_dask_array
5252
is_jax_array
53-
is_pydata_sparse
53+
is_pydata_sparse_array
5454
"""
5555
# Avoid importing NumPy if it isn't already
5656
if 'numpy' not in sys.modules:
@@ -80,7 +80,7 @@ def is_cupy_array(x):
8080
is_torch_array
8181
is_dask_array
8282
is_jax_array
83-
is_pydata_sparse
83+
is_pydata_sparse_array
8484
"""
8585
# Avoid importing NumPy if it isn't already
8686
if 'cupy' not in sys.modules:
@@ -107,7 +107,7 @@ def is_torch_array(x):
107107
is_cupy_array
108108
is_dask_array
109109
is_jax_array
110-
is_pydata_sparse
110+
is_pydata_sparse_array
111111
"""
112112
# Avoid importing torch if it isn't already
113113
if 'torch' not in sys.modules:
@@ -134,7 +134,7 @@ def is_dask_array(x):
134134
is_cupy_array
135135
is_torch_array
136136
is_jax_array
137-
is_pydata_sparse
137+
is_pydata_sparse_array
138138
"""
139139
# Avoid importing dask if it isn't already
140140
if 'dask.array' not in sys.modules:
@@ -161,7 +161,7 @@ def is_jax_array(x):
161161
is_cupy_array
162162
is_torch_array
163163
is_dask_array
164-
is_pydata_sparse
164+
is_pydata_sparse_array
165165
"""
166166
# Avoid importing jax if it isn't already
167167
if 'jax' not in sys.modules:
@@ -172,7 +172,7 @@ def is_jax_array(x):
172172
return isinstance(x, jax.Array) or _is_jax_zero_gradient_array(x)
173173

174174

175-
def is_pydata_sparse(x) -> bool:
175+
def is_pydata_sparse_array(x) -> bool:
176176
"""
177177
Return True if `x` is an array from the `sparse` package.
178178
@@ -219,7 +219,7 @@ def is_array_api_obj(x):
219219
or is_torch_array(x) \
220220
or is_dask_array(x) \
221221
or is_jax_array(x) \
222-
or is_pydata_sparse(x) \
222+
or is_pydata_sparse_array(x) \
223223
or hasattr(x, '__array_namespace__')
224224

225225
def _check_api_version(api_version):
@@ -288,7 +288,7 @@ def your_function(x, y):
288288
is_torch_array
289289
is_dask_array
290290
is_jax_array
291-
is_pydata_sparse
291+
is_pydata_sparse_array
292292
293293
"""
294294
if use_compat not in [None, True, False]:
@@ -348,7 +348,7 @@ def your_function(x, y):
348348
# not have a wrapper submodule for it.
349349
import jax.experimental.array_api as jnp
350350
namespaces.add(jnp)
351-
elif is_pydata_sparse(x):
351+
elif is_pydata_sparse_array(x):
352352
if use_compat is True:
353353
_check_api_version(api_version)
354354
raise ValueError("`sparse` does not have an array-api-compat wrapper")
@@ -451,7 +451,7 @@ def device(x: Array, /) -> Device:
451451
return x.device()
452452
else:
453453
return x.device
454-
elif is_pydata_sparse(x):
454+
elif is_pydata_sparse_array(x):
455455
# `sparse` will gain `.device`, so check for this first.
456456
x_device = getattr(x, 'device', None)
457457
if x_device is not None:
@@ -583,7 +583,7 @@ def to_device(x: Array, device: Device, /, *, stream: Optional[Union[int, Any]]
583583
# This import adds to_device to x
584584
import jax.experimental.array_api # noqa: F401
585585
return x.to_device(device, stream=stream)
586-
elif is_pydata_sparse(x) and device == _device(x):
586+
elif is_pydata_sparse_array(x) and device == _device(x):
587587
# Perform trivial check to return the same array if
588588
# device is same instead of err-ing.
589589
return x
@@ -613,7 +613,7 @@ def size(x):
613613
"is_jax_array",
614614
"is_numpy_array",
615615
"is_torch_array",
616-
"is_pydata_sparse",
616+
"is_pydata_sparse_array",
617617
"size",
618618
"to_device",
619619
]

docs/changelog.md

+18-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Changelog
22

3-
## 1.6 (2024-03-29)
3+
## 1.7 (2024-05-24)
44

55
## Major Changes
66

@@ -10,7 +10,23 @@
1010
`array_api_compat.sparse` submodule, and
1111
`array_namespace(<pydata/sparse array>)` returns the `sparse` module.
1212

13-
- Added the function `is_pydata_sparse(x)`.
13+
- Added the function `is_pydata_sparse_array(x)`.
14+
15+
## Minor Changes
16+
17+
- Fix JAX `float0` arrays. See https://github.com/google/jax/issues/20620.
18+
([@NeilGirdhar](https://github.com/NeilGirdhar))
19+
20+
- Fix `torch.linalg.vector_norm()` when `axis=()`.
21+
22+
- Fix `torch.linalg.solve()` to apply the array API standard rules for when
23+
`x2` should be treated as a vector vs. a matrix.
24+
25+
- Fix PyTorch test failures on CI by skipping uint16, uint32, uint64 tests.
26+
27+
## 1.6 (2024-03-29)
28+
29+
## Major Changes
1430

1531
- Drop support for Python 3.8.
1632

docs/dev/tests.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ dependencies from `requirements-dev.txt` (array-api-compat has [no hard
1111
runtime dependencies](no-dependencies)).
1212

1313
array-api-tests is run against all supported libraries are tested on CI
14-
([except for JAX](jax-support)). This is achieved by a [reusable GitHub Actions
14+
([except for JAX](jax-support) and [Sparse](sparse-support)). This is achieved
15+
by a [reusable GitHub Actions
1516
Workflow](https://github.com/data-apis/array-api-compat/blob/main/.github/workflows/array-api-tests.yml).
1617
Most libraries have tests that must be xfailed or skipped for various reasons.
1718
These are defined in specific `<library>-xfails.txt` files and are

docs/helper-functions.rst

+1
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,4 @@ yet.
4949
.. autofunction:: is_torch_array
5050
.. autofunction:: is_dask_array
5151
.. autofunction:: is_jax_array
52+
.. autofunction:: is_pydata_sparse_array

docs/index.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
This is a small wrapper around common array libraries that is compatible with
44
the [Array API standard](https://data-apis.org/array-api/latest/). Currently,
5-
NumPy, CuPy, PyTorch, Dask, and JAX are supported. If you want support for other array
6-
libraries, or if you encounter any issues, please [open an
5+
NumPy, CuPy, PyTorch, Dask, JAX, and Sparse are supported. If you want support
6+
for other array libraries, or if you encounter any issues, please [open an
77
issue](https://github.com/data-apis/array-api-compat/issues).
88

99
Note that some of the functionality in this library is backwards incompatible

docs/supported-array-libraries.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -133,5 +133,7 @@ Other methods may only be partially implemented or return incorrect results at t
133133

134134
The minimum supported Dask version is 2023.12.0.
135135

136-
## [`sparse`](https://sparse.pydata.org/en/stable/)
136+
(sparse-support)=
137+
## [Sparse](https://sparse.pydata.org/en/stable/)
138+
137139
Similar to JAX, `sparse` Array API support is contained directly in `sparse`.

setup.py

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"jax": "jax",
2222
"pytorch": "pytorch",
2323
"dask": "dask",
24+
"sprase": "sparse >=0.15.1",
2425
},
2526
classifiers=[
2627
"Programming Language :: Python :: 3",

tests/test_common.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from array_api_compat import (is_numpy_array, is_cupy_array, is_torch_array, # noqa: F401
2-
is_dask_array, is_jax_array, is_pydata_sparse)
2+
is_dask_array, is_jax_array, is_pydata_sparse_array)
33

44
from array_api_compat import is_array_api_obj, device, to_device
55

@@ -16,7 +16,7 @@
1616
'torch': 'is_torch_array',
1717
'dask.array': 'is_dask_array',
1818
'jax.numpy': 'is_jax_array',
19-
'sparse': 'is_pydata_sparse',
19+
'sparse': 'is_pydata_sparse_array',
2020
}
2121

2222
@pytest.mark.parametrize('library', is_functions.keys())

0 commit comments

Comments
 (0)