Skip to content

Commit eba9b25

Browse files
committed
clarify docs
1 parent 9d1a6bc commit eba9b25

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

tests/conftest.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,16 @@ class NumPyReadOnly:
4646
"""
4747
Variant of array_api_compat.numpy producing read-only arrays.
4848
49+
Read-only numpy arrays fail on `__iadd__` etc., whereas read-only libraries such as
50+
JAX and Sparse simply don't define those methods, which makes calls to `+=` fall
51+
back to `__add__`.
52+
4953
Note that this is not a full read-only Array API library. Notably,
50-
array_namespace(x) returns array_api_compat.numpy, and as a consequence array
51-
creation functions invoked internally by the tested functions will return
52-
writeable arrays, as long as you don't explicitly pass xp=xp.
53-
For this reason, tests that do pass xp=xp may misbehave and should be skipped
54-
for NUMPY_READONLY.
54+
`array_namespace(x)` returns array_api_compat.numpy. This is actually the desired
55+
behaviour, so that when a tested function internally calls `xp =
56+
array_namespace(*args) or xp`, it will internally create writeable arrays.
57+
For this reason, tests that explicitly pass xp=xp to the tested functions may
58+
misbehave and should be skipped for NUMPY_READONLY.
5559
"""
5660

5761
def __getattr__(self, name: str) -> object: # numpydoc ignore=PR01,RT01

0 commit comments

Comments
 (0)