Skip to content

Commit 50eb62f

Browse files
crusaderkyNeilGirdhar
authored andcommitted
MAINT: capitalization nits
1 parent c0e672c commit 50eb62f

File tree

8 files changed

+25
-25
lines changed

8 files changed

+25
-25
lines changed

src/array_api_extra/_lib/_at.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ class at: # pylint: disable=invalid-name # numpydoc ignore=PR02
187187
188188
>>> x = x.at[1].add(2)
189189
190-
If x is a read-only numpy array, they are the same as::
190+
If x is a read-only NumPy array, they are the same as::
191191
192192
>>> x = x.copy()
193193
>>> x[1] += 2
@@ -430,7 +430,7 @@ def min(
430430
"""Apply ``x[idx] = minimum(x[idx], y)`` and return the updated array."""
431431
# On Dask, this function runs on the chunks, so we need to determine the
432432
# namespace that Dask is wrapping.
433-
# Note that da.minimum _incidentally_ works on numpy, cupy, and sparse
433+
# Note that da.minimum _incidentally_ works on NumPy, CuPy, and sparse
434434
# thanks to all these meta-namespaces implementing the __array_ufunc__
435435
# interface, but there's no guarantee that it will work for other
436436
# wrapped libraries in the future.

src/array_api_extra/_lib/_funcs.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ def broadcast_shapes(*shapes: tuple[float | None, ...]) -> tuple[int | None, ...
260260
(4, 2, 3)
261261
"""
262262
if not shapes:
263-
return () # Match numpy output
263+
return () # Match NumPy output
264264

265265
ndim = max(len(shape) for shape in shapes)
266266
out: list[int | None] = []
@@ -538,7 +538,7 @@ def isclose(
538538
a_inexact = xp.isdtype(a.dtype, ("real floating", "complex floating"))
539539
b_inexact = xp.isdtype(b.dtype, ("real floating", "complex floating"))
540540
if a_inexact or b_inexact:
541-
# prevent warnings on numpy and dask on inf - inf
541+
# prevent warnings on NumPy and Dask on inf - inf
542542
mxp = meta_namespace(a, b, xp=xp)
543543
out = apply_where(
544544
xp.isinf(a) | xp.isinf(b),

src/array_api_extra/_lib/_lazy.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def lazy_apply( # type: ignore[valid-type] # numpydoc ignore=GL07,SA04
8686
One or more Array API compliant arrays, Python scalars, or None's.
8787
8888
If `as_numpy=True`, you need to be able to apply :func:`numpy.asarray` to
89-
non-None args to convert them to numpy; read notes below about specific
89+
non-None args to convert them to NumPy; read notes below about specific
9090
backends.
9191
shape : tuple[int | None, ...] | Sequence[tuple[int | None, ...]], optional
9292
Output shape or sequence of output shapes, one for each output of `func`.
@@ -97,7 +97,7 @@ def lazy_apply( # type: ignore[valid-type] # numpydoc ignore=GL07,SA04
9797
Default: infer the result type(s) from the input arrays.
9898
as_numpy : bool, optional
9999
If True, convert the input arrays to NumPy before passing them to `func`.
100-
This is particularly useful to make numpy-only functions, e.g. written in Cython
100+
This is particularly useful to make NumPy-only functions, e.g. written in Cython
101101
or Numba, work transparently with array API-compliant arrays.
102102
Default: False.
103103
xp : array_namespace, optional
@@ -143,8 +143,8 @@ def lazy_apply( # type: ignore[valid-type] # numpydoc ignore=GL07,SA04
143143
<https://sparse.pydata.org/en/stable/operations.html#package-configuration>`_.
144144
145145
Dask
146-
This allows applying eager functions to dask arrays.
147-
The dask graph won't be computed.
146+
This allows applying eager functions to Dask arrays.
147+
The Dask graph won't be computed.
148148
149149
`lazy_apply` doesn't know if `func` reduces along any axes; also, shape
150150
changes are non-trivial in chunked Dask arrays. For these reasons, all inputs

src/array_api_extra/testing.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ def lazy_xp_function( # type: ignore[explicit-any]
6363
Number of times `func` is allowed to internally materialize the Dask graph. This
6464
is typically triggered by ``bool()``, ``float()``, or ``np.asarray()``.
6565
66-
Set to 1 if you are aware that `func` converts the input parameters to numpy and
66+
Set to 1 if you are aware that `func` converts the input parameters to NumPy and
6767
want to let it do so at least for the time being, knowing that it is going to be
6868
extremely detrimental for performance.
6969
7070
If a test needs values higher than 1 to pass, it is a canary that the conversion
71-
to numpy/bool/float is happening multiple times, which translates to multiple
71+
to NumPy/bool/float is happening multiple times, which translates to multiple
7272
computations of the whole graph. Short of making the function fully lazy, you
7373
should at least add explicit calls to ``np.asarray()`` early in the function.
7474
*Note:* the counter of `allow_dask_compute` resets after each call to `func`, so

tests/conftest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class NumPyReadOnly:
5555
"""
5656
Variant of array_api_compat.numpy producing read-only arrays.
5757
58-
Read-only numpy arrays fail on `__iadd__` etc., whereas read-only libraries such as
58+
Read-only NumPy arrays fail on `__iadd__` etc., whereas read-only libraries such as
5959
JAX and Sparse simply don't define those methods, which makes calls to `+=` fall
6060
back to `__add__`.
6161

tests/test_at.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ def test_gh134(xp: ModuleType, bool_mask: bool, copy: bool | None):
318318
"""
319319
x = xp.zeros(1)
320320

321-
# In numpy, we have a writeable np.ndarray in input and a read-only np.generic in
321+
# In NumPy, we have a writeable np.ndarray in input and a read-only np.generic in
322322
# output. As both are Arrays, this behaviour is Array API compliant.
323323
# In Dask, we have a writeable da.Array on both sides, and if you call __setitem__
324324
# on it all seems fine, but when you compute() your graph is corrupted.

tests/test_lazy.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def f(x: Array) -> Array:
4747
assert xp2 is xp
4848

4949
y = xp2.broadcast_to(xp2.astype(x + 1, getattr(xp2, dtype)), shape)
50-
return xp2.asarray(y, copy=True) # Torch: ensure writeable numpy array
50+
return xp2.asarray(y, copy=True) # PyTorch: ensure writeable NumPy array
5151

5252
x = xp.asarray([1, 2], dtype=xp.int16)
5353
expect = xp.broadcast_to(xp.astype(x + 1, getattr(xp, dtype)), shape)
@@ -74,7 +74,7 @@ def f(x: Array) -> tuple[Array, Array]:
7474
xp2 = array_namespace(x)
7575
y = x + xp2.asarray(2, dtype=xp2.int8) # Sparse: bad dtype propagation
7676
z = xp2.broadcast_to(xp2.astype(x + 1, xp2.int16), (3, 2))
77-
z = xp2.asarray(z, copy=True) # Torch: ensure writeable numpy array
77+
z = xp2.asarray(z, copy=True) # PyTorch: ensure writeable NumPy array
7878
return y, z
7979

8080
x = xp.asarray([1, 2], dtype=xp.int8)
@@ -166,8 +166,8 @@ def f(x: Array) -> Array:
166166

167167

168168
def test_lazy_apply_dask_non_numpy_meta(da: ModuleType):
169-
"""Test dask wrapping around a meta-namespace other than numpy."""
170-
# At the moment of writing, of all Array API namespaces cupy is
169+
"""Test Dask wrapping around a meta-namespace other than numpy."""
170+
# At the moment of writing, of all Array API namespaces CuPy is
171171
# the only one that Dask supports.
172172
# For this reason, we can only test as_numpy=False since
173173
# np.asarray(cp.Array) is blocked by the transfer guard.

tests/test_testing.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def test_assert_close_tolerance(xp: ModuleType):
7474
@param_assert_equal_close
7575
@pytest.mark.xfail_xp_backend(Backend.SPARSE, reason="index by sparse array")
7676
def test_assert_close_equal_none_shape(xp: ModuleType, func: Callable[..., None]): # type: ignore[explicit-any]
77-
"""On dask and other lazy backends, test that a shape with NaN's or None's
77+
"""On Dask and other lazy backends, test that a shape with NaN's or None's
7878
can be compared to a real shape.
7979
"""
8080
a = xp.asarray([1, 2])
@@ -99,18 +99,18 @@ def test_assert_close_equal_none_shape(xp: ModuleType, func: Callable[..., None]
9999

100100

101101
def good_lazy(x: Array) -> Array:
102-
"""A function that behaves well in dask and jax.jit"""
102+
"""A function that behaves well in Dask and jax.jit"""
103103
return x * 2.0
104104

105105

106106
def non_materializable(x: Array) -> Array:
107107
"""
108108
This function materializes the input array, so it will fail when wrapped in jax.jit
109-
and it will trigger an expensive computation in dask.
109+
and it will trigger an expensive computation in Dask.
110110
"""
111111
xp = array_namespace(x)
112112
# Crashes inside jax.jit
113-
# On dask, this triggers two computations of the whole graph
113+
# On Dask, this triggers two computations of the whole graph
114114
if xp.any(x < 0.0) or xp.any(x > 10.0):
115115
msg = "Values must be in the [0, 10] range"
116116
raise ValueError(msg)
@@ -217,20 +217,20 @@ def test_lazy_xp_function_static_params(xp: ModuleType, func: Callable[..., Arra
217217
erf = None
218218

219219

220-
@pytest.mark.filterwarnings("ignore:__array_wrap__:DeprecationWarning") # torch
220+
@pytest.mark.filterwarnings("ignore:__array_wrap__:DeprecationWarning") # PyTorch
221221
def test_lazy_xp_function_cython_ufuncs(xp: ModuleType, library: Backend):
222222
pytest.importorskip("scipy")
223223
assert erf is not None
224224
x = xp.asarray([6.0, 7.0])
225225
if library in (Backend.ARRAY_API_STRICT, Backend.JAX):
226-
# array-api-strict arrays are auto-converted to numpy
226+
# array-api-strict arrays are auto-converted to NumPy
227227
# which results in an assertion error for mismatched namespaces
228-
# eager jax arrays are auto-converted to numpy in eager jax
228+
# eager JAX arrays are auto-converted to NumPy in eager JAX
229229
# and fail in jax.jit (which lazy_xp_function tests here)
230230
with pytest.raises((TypeError, AssertionError)):
231231
xp_assert_equal(cast(Array, erf(x)), xp.asarray([1.0, 1.0]))
232232
else:
233-
# cupy, dask and sparse define __array_ufunc__ and dispatch accordingly
233+
# CuPy, Dask and sparse define __array_ufunc__ and dispatch accordingly
234234
# note that when sparse reduces to scalar it returns a np.generic, which
235235
# would make xp_assert_equal fail.
236236
xp_assert_equal(cast(Array, erf(x)), xp.asarray([1.0, 1.0]))
@@ -271,7 +271,7 @@ def test_lazy_xp_function_eagerly_raises(da: ModuleType):
271271

272272
def f(x: Array) -> Array:
273273
xp = array_namespace(x)
274-
# Crash in jax.jit and trigger compute() on dask
274+
# Crash in jax.jit and trigger compute() on Dask
275275
if not xp.all(x):
276276
msg = "Values must be non-zero"
277277
raise ValueError(msg)

0 commit comments

Comments
 (0)