Skip to content

Commit

Permalink
Update core.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Illviljan committed Aug 26, 2024
1 parent c13a8ae commit e56e7cb
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions xarray/namedarray/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,15 +496,15 @@ def __ge__(self, other: int | float | NamedArray, /):
def __getitem__(self, key: _IndexKeyLike | NamedArray) -> NamedArray:
from xarray.namedarray._array_api._utils import _atleast_0d, _infer_dims

if isinstance(key, int | slice | tuple):
_data = _atleast_0d(self._data[key], self._data.__array_namespace__())
_dims = _infer_dims(_data.shape) # TODO: fix
return self._new(_dims, _data)
elif isinstance(key, NamedArray):
if isinstance(key, NamedArray):
_key = key._data # TODO: Transpose, unordered dims shouldn't matter.
_data = _atleast_0d(self._data[_key], self._data.__array_namespace__())
_dims = _infer_dims(_data.shape) # TODO: fix
return self._new(_dims, _data)
elif isinstance(key, int | slice | tuple) or key is None or key is ...:
_data = _atleast_0d(self._data[key], self._data.__array_namespace__())
_dims = _infer_dims(_data.shape) # TODO: fix
return self._new(_dims, _data)
else:
raise NotImplementedError(f"{key=} is not supported")

Expand Down

0 comments on commit e56e7cb

Please sign in to comment.