|
14 | 14 | import pandas as pd
|
15 | 15 | from packaging.version import Version
|
16 | 16 |
|
17 |
| -from . import duck_array_ops, nputils, utils |
| 17 | +from . import duck_array_ops |
18 | 18 | from .npcompat import DTypeLike
|
| 19 | +from .nputils import NumpyVIndexAdapter |
19 | 20 | from .options import OPTIONS
|
20 | 21 | from .pycompat import dask_version, integer_types, is_duck_dask_array, sparse_array_type
|
21 | 22 | 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 | +) |
23 | 30 |
|
24 | 31 | if TYPE_CHECKING:
|
25 | 32 | from .indexes import Index
|
@@ -431,15 +438,15 @@ class ExplicitlyIndexed:
|
431 | 438 | __slots__ = ()
|
432 | 439 |
|
433 | 440 |
|
434 |
| -class ExplicitlyIndexedNDArrayMixin(utils.NDArrayMixin, ExplicitlyIndexed): |
| 441 | +class ExplicitlyIndexedNDArrayMixin(NDArrayMixin, ExplicitlyIndexed): |
435 | 442 | __slots__ = ()
|
436 | 443 |
|
437 | 444 | def __array__(self, dtype=None):
|
438 | 445 | key = BasicIndexer((slice(None),) * self.ndim)
|
439 | 446 | return np.asarray(self[key], dtype=dtype)
|
440 | 447 |
|
441 | 448 |
|
442 |
| -class ImplicitToExplicitIndexingAdapter(utils.NDArrayMixin): |
| 449 | +class ImplicitToExplicitIndexingAdapter(NDArrayMixin): |
443 | 450 | """Wrap an array, converting tuples into the indicated explicit indexer."""
|
444 | 451 |
|
445 | 452 | __slots__ = ("array", "indexer_cls")
|
@@ -1234,7 +1241,7 @@ def _indexing_array_and_key(self, key):
|
1234 | 1241 | array = self.array
|
1235 | 1242 | key = _outer_to_numpy_indexer(key, self.array.shape)
|
1236 | 1243 | elif isinstance(key, VectorizedIndexer):
|
1237 |
| - array = nputils.NumpyVIndexAdapter(self.array) |
| 1244 | + array = NumpyVIndexAdapter(self.array) |
1238 | 1245 | key = key.tuple
|
1239 | 1246 | elif isinstance(key, BasicIndexer):
|
1240 | 1247 | array = self.array
|
@@ -1363,7 +1370,7 @@ class PandasIndexingAdapter(ExplicitlyIndexedNDArrayMixin):
|
1363 | 1370 | __slots__ = ("array", "_dtype")
|
1364 | 1371 |
|
1365 | 1372 | 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) |
1367 | 1374 |
|
1368 | 1375 | if dtype is None:
|
1369 | 1376 | self._dtype = get_valid_numpy_dtype(array)
|
@@ -1406,7 +1413,7 @@ def _convert_scalar(self, item):
|
1406 | 1413 |
|
1407 | 1414 | # as for numpy.ndarray indexing, we always want the result to be
|
1408 | 1415 | # a NumPy array.
|
1409 |
| - return utils.to_0d_array(item) |
| 1416 | + return to_0d_array(item) |
1410 | 1417 |
|
1411 | 1418 | def __getitem__(
|
1412 | 1419 | self, indexer
|
|
0 commit comments