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
5 changes: 5 additions & 0 deletions src/array_api_extra/_delegation.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,26 @@
from ._lib._utils._typing import Array, Device, DType

__all__ = [
"argpartition",
"atleast_nd",
"broadcast_shapes",
"cov",
"create_diagonal",
"diag_indices",
"expand_dims",
"isclose",
"isin",
"kron",
"nan_to_num",
"one_hot",
"pad",
"partition",
"searchsorted",
"setdiff1d",
"sinc",
"tril_indices",
"triu_indices",
"union1d",
"unravel_index",
]

Expand Down
9 changes: 9 additions & 0 deletions src/array_api_extra/_lib/_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,29 @@
__all__ = [
"angle",
"apply_where",
"argpartition",
"atleast_nd",
"broadcast_shapes",
"cov",
"create_diagonal",
"default_dtype",
"diag_indices",
"expand_dims",
"isclose",
"isin",
"kron",
"nan_to_num",
"nunique",
"one_hot",
"pad",
"partition",
"searchsorted",
"setdiff1d",
"sinc",
"tril_indices",
"triu_indices",
"union1d",
"unravel_index",
]


Expand Down
26 changes: 26 additions & 0 deletions tests/test_funcs.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import inspect
import math
import warnings
from collections.abc import Callable
Expand All @@ -12,6 +13,7 @@
from hypothesis import strategies as st
from typing_extensions import override

import array_api_extra._delegation as delegated_func
from array_api_extra import (
angle,
apply_where,
Expand Down Expand Up @@ -42,6 +44,7 @@
from array_api_extra import (
searchsorted as xpx_searchsorted,
)
from array_api_extra._lib import _funcs as functions
from array_api_extra._lib._backends import NUMPY_VERSION, Backend
from array_api_extra._lib._funcs import searchsorted as _funcs_searchsorted
from array_api_extra._lib._utils._compat import (
Expand Down Expand Up @@ -80,6 +83,29 @@
lazy_xp_function(_funcs_searchsorted)


def test_all_contains_all_public_functions():
public_functions = {
name
for name, obj in inspect.getmembers(functions, inspect.isfunction)
if not name.startswith("_") and obj.__module__ == functions.__name__
}
missing = sorted(public_functions - set(functions.__all__))
extra = sorted(set(functions.__all__) - public_functions)
assert public_functions == set(functions.__all__), (
f"Missing from __all__: {missing}\tExtra in __all__: {extra}"
)
public_functions = {
name
for name, obj in inspect.getmembers(delegated_func, inspect.isfunction)
if not name.startswith("_") and obj.__module__ == delegated_func.__name__
}
missing = sorted(public_functions - set(delegated_func.__all__))
extra = sorted(set(delegated_func.__all__) - public_functions)
assert public_functions == set(delegated_func.__all__), (
f"Missing from __all__: {missing}\tExtra in __all__: {extra}"
)


class TestApplyWhere:
@staticmethod
def f1(x: Array, y: Array | int = 10) -> Array:
Expand Down