Skip to content

Commit e6e5e47

Browse files
committed
Temporary fix for unsupported ExplicitlyIndexedNDArrayMixin subclasses
1 parent 89f542d commit e6e5e47

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

xarray/coding/strings.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,10 @@ def shape(self) -> tuple[int, ...]:
249249
def __repr__(self):
250250
return f"{type(self).__name__}({self.array!r})"
251251

252+
def _check_and_raise_if_non_basic_indexer(self, indexer) -> None:
253+
...
254+
# TODO: this is a temporary fix until BackendArray supports vindex and oindex
255+
252256
def __getitem__(self, key):
253257
# require slicing the last dimension completely
254258
key = type(key)(indexing.expanded_indexer(key.tuple, self.array.ndim))

xarray/coding/variables.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ def __init__(self, array, func: Callable, dtype: np.typing.DTypeLike):
6868
def dtype(self) -> np.dtype:
6969
return np.dtype(self._dtype)
7070

71+
def _check_and_raise_if_non_basic_indexer(self, indexer) -> None:
72+
...
73+
# TODO: this is a temporary fix until BackendArray supports vindex and oindex
74+
7175
def __getitem__(self, key):
7276
return type(self)(self.array[key], self.func, self.dtype)
7377

@@ -107,6 +111,10 @@ def __init__(self, array) -> None:
107111
def dtype(self) -> np.dtype:
108112
return np.dtype(self.array.dtype.kind + str(self.array.dtype.itemsize))
109113

114+
def _check_and_raise_if_non_basic_indexer(self, indexer) -> None:
115+
...
116+
# TODO: this is a temporary fix until BackendArray supports vindex and oindex
117+
110118
def __getitem__(self, key) -> np.ndarray:
111119
return np.asarray(self.array[key], dtype=self.dtype)
112120

@@ -139,6 +147,10 @@ def __init__(self, array) -> None:
139147
def dtype(self) -> np.dtype:
140148
return np.dtype("bool")
141149

150+
def _check_and_raise_if_non_basic_indexer(self, indexer) -> None:
151+
...
152+
# TODO: this is a temporary fix until BackendArray supports vindex and oindex
153+
142154
def __getitem__(self, key) -> np.ndarray:
143155
return np.asarray(self.array[key], dtype=self.dtype)
144156

0 commit comments

Comments
 (0)