Skip to content

Commit

Permalink
10000 it/s -> 12868.72it/s
Browse files Browse the repository at this point in the history
  • Loading branch information
hmaarrfk committed May 5, 2024
1 parent cd34827 commit b464438
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion xarray/core/dataarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,8 @@ def __init__(

# These fully describe a DataArray
self._variable = variable
self._coords = coords
# Variables can have undefined data type according to MyPy due to the fastpath
self._coords: Sequence[Sequence | pd.Index | DataArray] | Mapping = coords # type: ignore[assignment]
self._name = name
self._indexes = indexes # type: ignore[assignment]

Expand Down
5 changes: 3 additions & 2 deletions xarray/core/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,15 +296,16 @@ def slice_slice(old_slice: slice, applied_slice: slice, size: int) -> slice:


def _index_indexer_1d(old_indexer, applied_indexer, size: int):
assert isinstance(applied_indexer, integer_types + (slice, np.ndarray))
if isinstance(applied_indexer, slice) and applied_indexer == slice(None):
# shortcut for the usual case
return old_indexer
if isinstance(old_indexer, slice):
if isinstance(applied_indexer, slice):
indexer = slice_slice(old_indexer, applied_indexer, size)
elif isinstance(applied_indexer, integer_types):
indexer = range(*old_indexer.indices(size))[applied_indexer] # type: ignore[assignment]
else:
indexer = _expand_slice(old_indexer, size)[applied_indexer] # type: ignore[assignment]
indexer = _expand_slice(old_indexer, size)[applied_indexer]
else:
indexer = old_indexer[applied_indexer]
return indexer
Expand Down

0 comments on commit b464438

Please sign in to comment.