diff --git a/xarray/namedarray/_array_api/__init__.py b/xarray/namedarray/_array_api/__init__.py index da66bc620a2..9bce7c05c7a 100644 --- a/xarray/namedarray/_array_api/__init__.py +++ b/xarray/namedarray/_array_api/__init__.py @@ -4,15 +4,15 @@ __all__ += ["__array_api_version__"] -from .array_object import Array +from xarray.namedarray._array_api.array_object import Array __all__ += ["Array"] -from .constants import e, inf, nan, newaxis, pi +from xarray.namedarray._array_api.constants import e, inf, nan, newaxis, pi __all__ += ["e", "inf", "nan", "newaxis", "pi"] -from .creation_functions import ( +from xarray.namedarray._array_api.creation_functions import ( arange, asarray, empty, @@ -48,11 +48,18 @@ "zeros_like", ] -from .data_type_functions import astype, can_cast, finfo, iinfo, isdtype, result_type +from xarray.namedarray._array_api.data_type_functions import ( + astype, + can_cast, + finfo, + iinfo, + isdtype, + result_type, +) __all__ += ["astype", "can_cast", "finfo", "iinfo", "isdtype", "result_type"] -from .dtypes import ( +from xarray.namedarray._array_api.dtypes import ( bool, complex64, complex128, @@ -84,7 +91,7 @@ "uint64", ] -from .elementwise_functions import ( +from xarray.namedarray._array_api.elementwise_functions import ( abs, acos, acosh, @@ -208,15 +215,21 @@ "trunc", ] -from .indexing_functions import take +from xarray.namedarray._array_api.indexing_functions import take __all__ += ["take"] -from .linear_algebra_functions import matmul, matrix_transpose, outer, tensordot, vecdot +from xarray.namedarray._array_api.linear_algebra_functions import ( + matmul, + matrix_transpose, + outer, + tensordot, + vecdot, +) __all__ += ["matmul", "matrix_transpose", "outer", "tensordot", "vecdot"] -from .manipulation_functions import ( +from xarray.namedarray._array_api.manipulation_functions import ( broadcast_arrays, broadcast_to, concat, @@ -244,14 +257,14 @@ "stack", ] -from .searching_functions import argmax, argmin, where +from xarray.namedarray._array_api.searching_functions import argmax, argmin, where __all__ += ["argmax", "argmin", "where"] -from .statistical_functions import max, mean, min, prod, sum +from xarray.namedarray._array_api.statistical_functions import max, mean, min, prod, sum __all__ += ["max", "mean", "min", "prod", "sum"] -from .utility_functions import all, any +from xarray.namedarray._array_api.utility_functions import all, any -__all__ += ["all", "any"] \ No newline at end of file +__all__ += ["all", "any"] diff --git a/xarray/namedarray/_array_api/_utils.py b/xarray/namedarray/_array_api/_utils.py index 23275e5041d..445012b3059 100644 --- a/xarray/namedarray/_array_api/_utils.py +++ b/xarray/namedarray/_array_api/_utils.py @@ -1,10 +1,9 @@ -from typing import Any, ModuleType, TYPE_CHECKING +from typing import TYPE_CHECKING, Any, ModuleType import numpy as np from xarray.namedarray._typing import _arrayapi, _dtype - if TYPE_CHECKING: from xarray.namedarray.core import NamedArray diff --git a/xarray/namedarray/_array_api/creation_functions.py b/xarray/namedarray/_array_api/creation_functions.py index 012b9dd0166..957f11e6940 100644 --- a/xarray/namedarray/_array_api/creation_functions.py +++ b/xarray/namedarray/_array_api/creation_functions.py @@ -1,6 +1,5 @@ from __future__ import annotations -from types import ModuleType from typing import Any, overload import numpy as np @@ -8,29 +7,17 @@ from xarray.namedarray._array_api._utils import _maybe_default_namespace from xarray.namedarray._typing import ( Default, - _arrayapi, _arrayfunction_or_api, _ArrayLike, - _Axes, - _Axis, - _AxisLike, _default, - _Dim, - _Dims, _DimsLike, _DType, - _dtype, - _ScalarType, _Shape, _ShapeType, - _SupportsImag, - _SupportsReal, duckarray, ) from xarray.namedarray.core import ( NamedArray, - _dims_to_axis, - _get_remaining_dims, ) from xarray.namedarray.utils import ( to_0d_object_array, diff --git a/xarray/namedarray/_array_api/data_type_functions.py b/xarray/namedarray/_array_api/data_type_functions.py index fc0c1be4abc..fbfaaca0d0e 100644 --- a/xarray/namedarray/_array_api/data_type_functions.py +++ b/xarray/namedarray/_array_api/data_type_functions.py @@ -1,42 +1,19 @@ from __future__ import annotations -from types import ModuleType -from typing import Any, overload - -import numpy as np +from typing import Any from xarray.namedarray._array_api._utils import ( _get_data_namespace, _get_namespace_dtype, ) from xarray.namedarray._typing import ( - Default, _arrayapi, - _arrayfunction_or_api, - _ArrayLike, - _Axes, - _Axis, - _AxisLike, - _default, - _Dim, - _Dims, - _DimsLike, _DType, _dtype, - _ScalarType, - _Shape, _ShapeType, - _SupportsImag, - _SupportsReal, - duckarray, ) from xarray.namedarray.core import ( NamedArray, - _dims_to_axis, - _get_remaining_dims, -) -from xarray.namedarray.utils import ( - to_0d_object_array, ) diff --git a/xarray/namedarray/_array_api/dtypes.py b/xarray/namedarray/_array_api/dtypes.py index 016db30ff95..c796400329a 100644 --- a/xarray/namedarray/_array_api/dtypes.py +++ b/xarray/namedarray/_array_api/dtypes.py @@ -1,40 +1,6 @@ from __future__ import annotations -from types import ModuleType -from typing import Any, overload - -import numpy as np - from xarray.namedarray._array_api._utils import _maybe_default_namespace -from xarray.namedarray._typing import ( - Default, - _arrayapi, - _arrayfunction_or_api, - _ArrayLike, - _Axes, - _Axis, - _AxisLike, - _default, - _Dim, - _Dims, - _DimsLike, - _DType, - _dtype, - _ScalarType, - _Shape, - _ShapeType, - _SupportsImag, - _SupportsReal, - duckarray, -) -from xarray.namedarray.core import ( - NamedArray, - _dims_to_axis, - _get_remaining_dims, -) -from xarray.namedarray.utils import ( - to_0d_object_array, -) _xp = _maybe_default_namespace() int8 = _xp.int8 diff --git a/xarray/namedarray/_array_api/elementwise_functions.py b/xarray/namedarray/_array_api/elementwise_functions.py index 6a53a8b844b..acdd4dc5c48 100644 --- a/xarray/namedarray/_array_api/elementwise_functions.py +++ b/xarray/namedarray/_array_api/elementwise_functions.py @@ -1,39 +1,16 @@ from __future__ import annotations -from types import ModuleType -from typing import Any, overload - import numpy as np from xarray.namedarray._array_api._utils import _get_data_namespace from xarray.namedarray._typing import ( - Default, - _arrayapi, - _arrayfunction_or_api, - _ArrayLike, - _Axes, - _Axis, - _AxisLike, - _default, - _Dim, - _Dims, - _DimsLike, - _DType, - _dtype, _ScalarType, - _Shape, _ShapeType, _SupportsImag, _SupportsReal, - duckarray, ) from xarray.namedarray.core import ( NamedArray, - _dims_to_axis, - _get_remaining_dims, -) -from xarray.namedarray.utils import ( - to_0d_object_array, ) diff --git a/xarray/namedarray/_array_api/manipulation_functions.py b/xarray/namedarray/_array_api/manipulation_functions.py index e38f12373d0..3da92b76fa9 100644 --- a/xarray/namedarray/_array_api/manipulation_functions.py +++ b/xarray/namedarray/_array_api/manipulation_functions.py @@ -1,38 +1,19 @@ from __future__ import annotations -from types import ModuleType -from typing import Any, overload - -import numpy as np +from typing import Any from xarray.namedarray._typing import ( Default, _arrayapi, - _arrayfunction_or_api, - _ArrayLike, _Axes, _Axis, - _AxisLike, _default, _Dim, - _Dims, - _DimsLike, _DType, - _dtype, - _ScalarType, _Shape, - _ShapeType, - _SupportsImag, - _SupportsReal, - duckarray, ) from xarray.namedarray.core import ( NamedArray, - _dims_to_axis, - _get_remaining_dims, -) -from xarray.namedarray.utils import ( - to_0d_object_array, ) diff --git a/xarray/namedarray/_array_api/statistical_functions.py b/xarray/namedarray/_array_api/statistical_functions.py index 19e84126c2d..8aa1db92a7f 100644 --- a/xarray/namedarray/_array_api/statistical_functions.py +++ b/xarray/namedarray/_array_api/statistical_functions.py @@ -1,40 +1,20 @@ from __future__ import annotations -from types import ModuleType -from typing import Any, overload - -import numpy as np +from typing import Any from xarray.namedarray._array_api._utils import _get_data_namespace from xarray.namedarray._typing import ( Default, - _arrayapi, - _arrayfunction_or_api, - _ArrayLike, - _Axes, - _Axis, _AxisLike, _default, - _Dim, _Dims, - _DimsLike, _DType, - _dtype, - _ScalarType, - _Shape, - _ShapeType, - _SupportsImag, - _SupportsReal, - duckarray, ) from xarray.namedarray.core import ( NamedArray, _dims_to_axis, _get_remaining_dims, ) -from xarray.namedarray.utils import ( - to_0d_object_array, -) def mean( diff --git a/xarray/namedarray/_array_api/utility_functions.py b/xarray/namedarray/_array_api/utility_functions.py index 849e13233b2..86eb34c4d9c 100644 --- a/xarray/namedarray/_array_api/utility_functions.py +++ b/xarray/namedarray/_array_api/utility_functions.py @@ -1,40 +1,20 @@ from __future__ import annotations -from types import ModuleType -from typing import Any, overload - -import numpy as np +from typing import Any from xarray.namedarray._array_api._utils import _get_data_namespace from xarray.namedarray._typing import ( Default, - _arrayapi, - _arrayfunction_or_api, - _ArrayLike, - _Axes, - _Axis, _AxisLike, _default, - _Dim, _Dims, - _DimsLike, _DType, - _dtype, - _ScalarType, - _Shape, - _ShapeType, - _SupportsImag, - _SupportsReal, - duckarray, ) from xarray.namedarray.core import ( NamedArray, _dims_to_axis, _get_remaining_dims, ) -from xarray.namedarray.utils import ( - to_0d_object_array, -) def all(