Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: lazy_apply #86

Merged
merged 10 commits into from
Mar 18, 2025
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
15 changes: 15 additions & 0 deletions docs/api-lazy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Tools for lazy backends

These additional functions are meant to be used to support compatibility with
lazy backends, e.g. Dask or JAX:

```{eval-rst}
.. currentmodule:: array_api_extra
.. autosummary::
:nosignatures:
:toctree: generated

lazy_apply
testing.lazy_xp_function
testing.patch_lazy_xp_functions
```
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
:hidden:
self
api-reference.md
testing-utils.md
api-lazy.md
contributing.md
contributors.md
```
Expand Down
14 changes: 0 additions & 14 deletions docs/testing-utils.md

This file was deleted.

5,459 changes: 2,508 additions & 2,951 deletions pixi.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ sphinx-autodoc-typehints = "*"
dask-core = "*"
pytest = "*"
typing-extensions = "*"
numpy = "*"

[tool.pixi.feature.docs.tasks]
docs = { cmd = "sphinx-build . build/", cwd = "docs" }
Expand Down
2 changes: 2 additions & 0 deletions src/array_api_extra/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
setdiff1d,
sinc,
)
from ._lib._lazy import lazy_apply

__version__ = "0.7.0.dev0"

Expand All @@ -29,6 +30,7 @@
"expand_dims",
"isclose",
"kron",
"lazy_apply",
"nunique",
"pad",
"setdiff1d",
Expand Down
10 changes: 5 additions & 5 deletions src/array_api_extra/_lib/_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@


@overload
def apply_where( # type: ignore[no-any-explicit,no-any-decorated] # numpydoc ignore=GL08
def apply_where( # type: ignore[explicit-any,decorated-any] # numpydoc ignore=GL08
cond: Array,
args: Array | tuple[Array, ...],
f1: Callable[..., Array],
Expand All @@ -48,7 +48,7 @@ def apply_where( # type: ignore[no-any-explicit,no-any-decorated] # numpydoc ig


@overload
def apply_where( # type: ignore[no-any-explicit,no-any-decorated] # numpydoc ignore=GL08
def apply_where( # type: ignore[explicit-any,decorated-any] # numpydoc ignore=GL08
cond: Array,
args: Array | tuple[Array, ...],
f1: Callable[..., Array],
Expand All @@ -59,7 +59,7 @@ def apply_where( # type: ignore[no-any-explicit,no-any-decorated] # numpydoc ig
) -> Array: ...


def apply_where( # type: ignore[no-any-explicit] # numpydoc ignore=PR01,PR02
def apply_where( # type: ignore[explicit-any] # numpydoc ignore=PR01,PR02
cond: Array,
args: Array | tuple[Array, ...],
f1: Callable[..., Array],
Expand Down Expand Up @@ -145,7 +145,7 @@ def apply_where( # type: ignore[no-any-explicit] # numpydoc ignore=PR01,PR02
return _apply_where(cond, f1, f2, fill_value, *args_, xp=xp)


def _apply_where( # type: ignore[no-any-explicit] # numpydoc ignore=PR01,RT01
def _apply_where( # type: ignore[explicit-any] # numpydoc ignore=PR01,RT01
cond: Array,
f1: Callable[..., Array],
f2: Callable[..., Array] | None,
Expand Down Expand Up @@ -743,7 +743,7 @@ def pad(
pad_width_seq = cast(list[tuple[int, int]], list(pad_width))

# https://github.com/python/typeshed/issues/13376
slices: list[slice] = [] # type: ignore[no-any-explicit]
slices: list[slice] = [] # type: ignore[explicit-any]
newshape: list[int] = []
for ax, w_tpl in enumerate(pad_width_seq):
if len(w_tpl) != 2:
Expand Down
Loading
Loading