Skip to content

Commit 319cb87

Browse files
committed
docs
1 parent 80171a3 commit 319cb87

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

docs/conf.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,11 @@
4848
numpy=("https://numpy.org/doc/stable/", None),
4949
python=("https://docs.python.org/3", None),
5050
scipy=("https://docs.scipy.org/doc/scipy/", None),
51+
zarr=("https://zarr.readthedocs.io/en/stable/", None),
5152
)
5253
# Try overriding type paths
5354
qualname_overrides = autodoc_type_aliases = {
55+
"np.bool_": ("py:data", "numpy.bool_"),
5456
"np.dtype": "numpy.dtype",
5557
"np.number": "numpy.number",
5658
"np.integer": "numpy.integer",
@@ -62,15 +64,16 @@
6264
"CupySparseMatrix": "cupyx.scipy.sparse.spmatrix",
6365
"DaskArray": "dask.array.Array",
6466
"H5Dataset": "h5py.Dataset",
67+
"ZarrArray": "zarr.Array",
6568
}
6669
# If that doesn’t work, ignore them
6770
nitpick_ignore = {
68-
("py:class", "DT_co"),
6971
("py:class", "fast_array_utils.types.T_co"),
7072
# sphinx bugs, should be covered by `autodoc_type_aliases` above
7173
("py:class", "ArrayLike"),
7274
("py:class", "DTypeLike"),
7375
("py:class", "NDArray"),
76+
("py:class", "np.bool_"),
7477
}
7578

7679
# Options for HTML output

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ lint.flake8-type-checking.strict = true
9191
lint.isort.known-first-party = [ "fast_array_utils" ]
9292
lint.isort.lines-after-imports = 2
9393
lint.isort.required-imports = [ "from __future__ import annotations" ]
94+
lint.pydocstyle.convention = "numpy"
9495

9596
[tool.pytest.ini_options]
9697
addopts = [

src/fast_array_utils/stats/_is_constant.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,26 @@
1313

1414
if TYPE_CHECKING:
1515
from collections.abc import Callable
16-
from typing import Any, Literal, TypeAlias, TypeVar
16+
from typing import Any, Literal, TypeVar
1717

1818
from numpy.typing import NDArray
1919

20-
_Array: TypeAlias = NDArray[Any] | CSBase | H5Dataset | ZarrArray | DaskArray
21-
2220
C = TypeVar("C", bound=Callable[..., Any])
2321

2422

2523
@overload
26-
def is_constant(a: _Array, axis: None = None) -> bool: ...
24+
def is_constant(
25+
a: NDArray[Any] | CSBase | H5Dataset | ZarrArray | DaskArray, axis: None = None
26+
) -> bool: ...
2727
@overload
28-
def is_constant(a: _Array, axis: Literal[0, 1]) -> NDArray[np.bool_]: ...
28+
def is_constant(
29+
a: NDArray[Any] | CSBase | H5Dataset | ZarrArray | DaskArray, axis: Literal[0, 1]
30+
) -> NDArray[np.bool_]: ...
2931

3032

31-
def is_constant(a: _Array, axis: Literal[0, 1] | None = None) -> bool | NDArray[np.bool_]:
33+
def is_constant(
34+
a: NDArray[Any] | CSBase | H5Dataset | ZarrArray | DaskArray, axis: Literal[0, 1] | None = None
35+
) -> bool | NDArray[np.bool_]:
3236
"""Check whether values in array are constant.
3337
3438
Params
@@ -38,12 +42,11 @@ def is_constant(a: _Array, axis: Literal[0, 1] | None = None) -> bool | NDArray[
3842
axis
3943
Axis to reduce over.
4044
41-
42-
Returns:
45+
Returns
4346
-------
4447
Boolean array, True values were constant.
4548
46-
Example:
49+
Example
4750
-------
4851
>>> a = np.array([[0, 1], [0, 0]])
4952
>>> a
@@ -69,7 +72,9 @@ def is_constant(a: _Array, axis: Literal[0, 1] | None = None) -> bool | NDArray[
6972

7073

7174
@singledispatch
72-
def _is_constant(a: _Array, axis: Literal[0, 1] | None = None) -> bool | NDArray[np.bool_]:
75+
def _is_constant(
76+
a: NDArray[Any] | CSBase | H5Dataset | ZarrArray | DaskArray, axis: Literal[0, 1] | None = None
77+
) -> bool | NDArray[np.bool_]:
7378
raise NotImplementedError
7479

7580

0 commit comments

Comments
 (0)