Skip to content

Commit 4c8dd10

Browse files
Remove generic utils import (#6764)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent ce40b93 commit 4c8dd10

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

xarray/core/indexing.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,19 @@
1414
import pandas as pd
1515
from packaging.version import Version
1616

17-
from . import duck_array_ops, nputils, utils
17+
from . import duck_array_ops
1818
from .npcompat import DTypeLike
19+
from .nputils import NumpyVIndexAdapter
1920
from .options import OPTIONS
2021
from .pycompat import dask_version, integer_types, is_duck_dask_array, sparse_array_type
2122
from .types import T_Xarray
22-
from .utils import either_dict_or_kwargs, get_valid_numpy_dtype
23+
from .utils import (
24+
NDArrayMixin,
25+
either_dict_or_kwargs,
26+
get_valid_numpy_dtype,
27+
safe_cast_to_index,
28+
to_0d_array,
29+
)
2330

2431
if TYPE_CHECKING:
2532
from .indexes import Index
@@ -431,15 +438,15 @@ class ExplicitlyIndexed:
431438
__slots__ = ()
432439

433440

434-
class ExplicitlyIndexedNDArrayMixin(utils.NDArrayMixin, ExplicitlyIndexed):
441+
class ExplicitlyIndexedNDArrayMixin(NDArrayMixin, ExplicitlyIndexed):
435442
__slots__ = ()
436443

437444
def __array__(self, dtype=None):
438445
key = BasicIndexer((slice(None),) * self.ndim)
439446
return np.asarray(self[key], dtype=dtype)
440447

441448

442-
class ImplicitToExplicitIndexingAdapter(utils.NDArrayMixin):
449+
class ImplicitToExplicitIndexingAdapter(NDArrayMixin):
443450
"""Wrap an array, converting tuples into the indicated explicit indexer."""
444451

445452
__slots__ = ("array", "indexer_cls")
@@ -1234,7 +1241,7 @@ def _indexing_array_and_key(self, key):
12341241
array = self.array
12351242
key = _outer_to_numpy_indexer(key, self.array.shape)
12361243
elif isinstance(key, VectorizedIndexer):
1237-
array = nputils.NumpyVIndexAdapter(self.array)
1244+
array = NumpyVIndexAdapter(self.array)
12381245
key = key.tuple
12391246
elif isinstance(key, BasicIndexer):
12401247
array = self.array
@@ -1363,7 +1370,7 @@ class PandasIndexingAdapter(ExplicitlyIndexedNDArrayMixin):
13631370
__slots__ = ("array", "_dtype")
13641371

13651372
def __init__(self, array: pd.Index, dtype: DTypeLike = None):
1366-
self.array = utils.safe_cast_to_index(array)
1373+
self.array = safe_cast_to_index(array)
13671374

13681375
if dtype is None:
13691376
self._dtype = get_valid_numpy_dtype(array)
@@ -1406,7 +1413,7 @@ def _convert_scalar(self, item):
14061413

14071414
# as for numpy.ndarray indexing, we always want the result to be
14081415
# a NumPy array.
1409-
return utils.to_0d_array(item)
1416+
return to_0d_array(item)
14101417

14111418
def __getitem__(
14121419
self, indexer

0 commit comments

Comments
 (0)