Skip to content

Commit

Permalink
Temporary fix for unsupported ExplicitlyIndexedNDArrayMixin subclasses
Browse files Browse the repository at this point in the history
  • Loading branch information
andersy005 committed Apr 9, 2024
1 parent 89f542d commit e6e5e47
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions xarray/coding/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@ def shape(self) -> tuple[int, ...]:
def __repr__(self):
return f"{type(self).__name__}({self.array!r})"

def _check_and_raise_if_non_basic_indexer(self, indexer) -> None:
...
# TODO: this is a temporary fix until BackendArray supports vindex and oindex

def __getitem__(self, key):
# require slicing the last dimension completely
key = type(key)(indexing.expanded_indexer(key.tuple, self.array.ndim))
Expand Down
12 changes: 12 additions & 0 deletions xarray/coding/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ def __init__(self, array, func: Callable, dtype: np.typing.DTypeLike):
def dtype(self) -> np.dtype:
return np.dtype(self._dtype)

def _check_and_raise_if_non_basic_indexer(self, indexer) -> None:
...
# TODO: this is a temporary fix until BackendArray supports vindex and oindex

def __getitem__(self, key):
return type(self)(self.array[key], self.func, self.dtype)

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

def _check_and_raise_if_non_basic_indexer(self, indexer) -> None:
...
# TODO: this is a temporary fix until BackendArray supports vindex and oindex

def __getitem__(self, key) -> np.ndarray:
return np.asarray(self.array[key], dtype=self.dtype)

Expand Down Expand Up @@ -139,6 +147,10 @@ def __init__(self, array) -> None:
def dtype(self) -> np.dtype:
return np.dtype("bool")

def _check_and_raise_if_non_basic_indexer(self, indexer) -> None:
...
# TODO: this is a temporary fix until BackendArray supports vindex and oindex

def __getitem__(self, key) -> np.ndarray:
return np.asarray(self.array[key], dtype=self.dtype)

Expand Down

0 comments on commit e6e5e47

Please sign in to comment.