Skip to content

Commit

Permalink
Update _utils.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Illviljan committed Sep 24, 2024
1 parent 733a45a commit b7ceeb4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions xarray/namedarray/_array_api/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,21 +422,23 @@ def _dims_from_tuple_indexing(dims: _Dims, key: _IndexKeys) -> _Dims:
('dim_2', 'x', 'y')
>>> _dims_from_tuple_indexing(("x", "y"), (0, None, None, 0))
('dim_1', 'dim_2')
>>> _dims_from_tuple_indexing(("x",), (..., 0))
()
"""
_dims = list(dims)
j = 0
for k in key:
if k is None:
# None adds 1 dimension:
_dims.insert(j, _new_unique_dim_name(tuple(_dims)))
j += 1
elif isinstance(k, int):
# Integer removes 1 dimension:
_dims.pop(j)
j -= 1
else:
# Slices and Ellipsis maintains same dimensions:
pass
j += 1

return tuple(_dims)


Expand Down

0 comments on commit b7ceeb4

Please sign in to comment.