Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 34 additions & 38 deletions pixi.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ hypothesis = ">=6.155.7"
dask-core = ">=2026.7.1" # No distributed, tornado, etc.
dprint = ">=0.50.0,<0.51"
lefthook = ">=2.1.10,<3"
ruff = ">=0.15.22,<0.16"
ruff = ">=0.16.0,<0.17"
typos = ">=1.48.0,<2"
actionlint = ">=1.7.12,<2"
blacken-docs = ">=1.20.0,<2"
Expand Down
4 changes: 2 additions & 2 deletions src/array_api_extra/_delegation.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,10 +655,10 @@ def kron(


def nan_to_num(
x: Array | float | complex,
x: Array | complex,
/,
*,
fill_value: int | float = 0.0,
fill_value: float = 0.0,
xp: ArrayNamespace | None = None,
) -> Array:
"""
Expand Down
2 changes: 1 addition & 1 deletion src/array_api_extra/_lib/_at.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def _op(
" at(x)[idx].set(value)\n"
"(same for all other methods)."
)
raise ValueError(msg)
raise ValueError(msg) # noqa: TRY004

if copy not in (True, False, None):
msg = f"copy must be True, False, or None; got {copy!r}"
Expand Down
6 changes: 3 additions & 3 deletions src/array_api_extra/_lib/_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def _apply_where( # numpydoc ignore=PR01,RT01
cond: Array,
f1: Callable[..., Array],
f2: Callable[..., Array] | None,
fill_value: Array | int | float | complex | bool | None,
fill_value: Array | complex | bool | None,
*args: Array,
kwkeys: list[str],
xp: ArrayNamespace,
Expand Down Expand Up @@ -514,15 +514,15 @@ def kron(
def nan_to_num( # numpydoc ignore=PR01,RT01
x: Array,
/,
fill_value: int | float = 0.0,
fill_value: float = 0.0,
*,
xp: ArrayNamespace,
) -> Array:
"""See docstring in `array_api_extra._delegation.py`."""

def perform_replacements( # numpydoc ignore=PR01,RT01
x: Array,
fill_value: int | float,
fill_value: float,
xp: ArrayNamespace,
) -> Array:
"""Internal function to perform the replacements."""
Expand Down
1 change: 0 additions & 1 deletion src/array_api_extra/_lib/_utils/_compat.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Static type stubs for `_compat.py`."""

# https://github.com/scikit-learn/scikit-learn/pull/27910#issuecomment-2568023972
from __future__ import annotations

from typing import Any, TypeGuard

Expand Down
4 changes: 2 additions & 2 deletions src/array_api_extra/_lib/_utils/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ class Pickler(pickle.Pickler): # numpydoc ignore=GL08
@override
def persistent_id(
self, obj: object
) -> Literal[0, 1, None]: # numpydoc ignore=GL08
) -> Literal[0, 1] | None: # numpydoc ignore=GL08
if isinstance(obj, cls):
instances.append(obj)
return 0
Expand All @@ -445,7 +445,7 @@ def persistent_id(
# Note: a class that defines __slots__ without defining __getstate__
# cannot be pickled with __reduce__(), but can with __reduce_ex__(5)
_ = obj.__reduce_ex__(pickle.HIGHEST_PROTOCOL)
except Exception: # pylint: disable=broad-exception-caught
except Exception: # pylint: disable=broad-exception-caught # noqa: BLE001
rest.append(obj)
return 1

Expand Down
9 changes: 3 additions & 6 deletions src/array_api_extra/_lib/_utils/_typing.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
"""Static typing helpers."""

from __future__ import annotations

from types import EllipsisType, ModuleType
from typing import Protocol, TypeAlias

Expand Down Expand Up @@ -92,16 +90,15 @@ class Array(Protocol): # pylint: disable=missing-class-docstring
# def to_device(device: Device, /, *, stream: int | Any | None = None) -> Array: ...

class DType(Protocol): # pylint: disable=missing-class-docstring
pass

...
class Device(Protocol): # pylint: disable=missing-class-docstring
pass
...

SetIndex: TypeAlias = (
int | slice | EllipsisType | Array | tuple[int | slice | EllipsisType | Array, ...]
)
GetIndex: TypeAlias = (
SetIndex | None | tuple[int | slice | EllipsisType | None | Array, ...]
SetIndex | tuple[int | slice | EllipsisType | Array | None, ...] | None
)

__all__ = ["Array", "ArrayNamespace", "DType", "Device", "GetIndex", "SetIndex"]
4 changes: 2 additions & 2 deletions tests/test_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1412,7 +1412,7 @@ def test_fill_value_success(
self,
xp: ArrayNamespace,
in_vals: Array,
fill_value: int | float,
fill_value: float,
out_vals: Array,
) -> None:
a = xp.asarray(in_vals)
Expand Down Expand Up @@ -1664,7 +1664,7 @@ def test_simple(self, xp: ArrayNamespace):
assert_close(w, xp.flip(w, axis=0))

@pytest.mark.parametrize("x", [0, 1 + 3j])
def test_dtype(self, xp: ArrayNamespace, x: int | complex):
def test_dtype(self, xp: ArrayNamespace, x: complex):
with pytest.raises(ValueError, match="real floating data type"):
_ = sinc(xp.asarray(x))

Expand Down
2 changes: 1 addition & 1 deletion tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ def test_static_hashable(self, jnp: ArrayNamespace):

class C:
def __reduce__(self) -> object: # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride,reportImplicitOverride]
raise Exception()
raise Exception() # noqa: TRY002

@jax_autojit
def f(x: object) -> object:
Expand Down