Skip to content

Commit

Permalink
DaskIndexingAdapter->ChunkedIndexingAdapter
Browse files Browse the repository at this point in the history
  • Loading branch information
TomNicholas committed Mar 14, 2023
1 parent 6cfe9fa commit 4ca044b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions xarray/core/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from xarray.core.nputils import NumpyVIndexAdapter
from xarray.core.options import OPTIONS
from xarray.core.parallelcompat import get_chunked_array_type, is_chunked_array
from xarray.core.pycompat import array_type, integer_types, is_duck_dask_array
from xarray.core.pycompat import array_type, integer_types
from xarray.core.types import T_Xarray
from xarray.core.utils import (
NDArrayMixin,
Expand Down Expand Up @@ -676,8 +676,8 @@ def as_indexable(array):
return NumpyIndexingAdapter(array)
if isinstance(array, pd.Index):
return PandasIndexingAdapter(array)
if is_duck_dask_array(array):
return DaskIndexingAdapter(array)
if is_chunked_array(array):
return ChunkedIndexingAdapter(array)
if hasattr(array, "__array_function__"):
return NdArrayLikeIndexingAdapter(array)
if hasattr(array, "__array_namespace__"):
Expand Down Expand Up @@ -1309,7 +1309,7 @@ def __getitem__(self, key):
if isinstance(key, BasicIndexer):
return self.array[key.tuple]
elif isinstance(key, OuterIndexer):
# manual orthogonal indexing (implemented like DaskIndexingAdapter)
# manual orthogonal indexing (implemented like ChunkedIndexingAdapter)
key = key.tuple
value = self.array
for axis, subkey in reversed(list(enumerate(key))):
Expand All @@ -1335,8 +1335,8 @@ def transpose(self, order):
return xp.permute_dims(self.array, order)


class DaskIndexingAdapter(ExplicitlyIndexedNDArrayMixin):
"""Wrap a dask array to support explicit indexing."""
class ChunkedIndexingAdapter(ExplicitlyIndexedNDArrayMixin):
"""Wrap a chunked array (e.g. a dask array) to support explicit indexing."""

__slots__ = ("array",)

Expand Down
2 changes: 1 addition & 1 deletion xarray/tests/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ def find_and_validate_array(obj):
if isinstance(obj.array, np.ndarray):
assert isinstance(obj, indexing.NumpyIndexingAdapter)
elif isinstance(obj.array, dask_array_type):
assert isinstance(obj, indexing.DaskIndexingAdapter)
assert isinstance(obj, indexing.ChunkedIndexingAdapter)
elif isinstance(obj.array, pd.Index):
assert isinstance(obj, indexing.PandasIndexingAdapter)
else:
Expand Down
8 changes: 4 additions & 4 deletions xarray/tests/test_variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
from xarray.core.common import full_like, ones_like, zeros_like
from xarray.core.indexing import (
BasicIndexer,
ChunkedIndexingAdapter,
CopyOnWriteArray,
DaskIndexingAdapter,
LazilyIndexedArray,
MemoryCachedArray,
NumpyIndexingAdapter,
Expand Down Expand Up @@ -2725,15 +2725,15 @@ def test_MemoryCachedArray(self):
self.check_vectorized_indexing(v)

@requires_dask
def test_DaskIndexingAdapter(self):
def test_ChunkedIndexingAdapter(self):
import dask.array as da

da = da.asarray(self.d)
v = Variable(dims=("x", "y"), data=DaskIndexingAdapter(da))
v = Variable(dims=("x", "y"), data=ChunkedIndexingAdapter(da))
self.check_orthogonal_indexing(v)
self.check_vectorized_indexing(v)
# doubly wrapping
v = Variable(dims=("x", "y"), data=CopyOnWriteArray(DaskIndexingAdapter(da)))
v = Variable(dims=("x", "y"), data=CopyOnWriteArray(ChunkedIndexingAdapter(da)))
self.check_orthogonal_indexing(v)
self.check_vectorized_indexing(v)

Expand Down

0 comments on commit 4ca044b

Please sign in to comment.