Skip to content

Commit 3290e24

Browse files
committed
10000 it/s -> 12868.72it/s
1 parent 3fba0a7 commit 3290e24

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

xarray/core/dataarray.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,8 @@ def __init__(
459459

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

xarray/core/indexing.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,15 +296,16 @@ def slice_slice(old_slice: slice, applied_slice: slice, size: int) -> slice:
296296

297297

298298
def _index_indexer_1d(old_indexer, applied_indexer, size: int):
299-
assert isinstance(applied_indexer, integer_types + (slice, np.ndarray))
300299
if isinstance(applied_indexer, slice) and applied_indexer == slice(None):
301300
# shortcut for the usual case
302301
return old_indexer
303302
if isinstance(old_indexer, slice):
304303
if isinstance(applied_indexer, slice):
305304
indexer = slice_slice(old_indexer, applied_indexer, size)
305+
elif isinstance(applied_indexer, integer_types):
306+
indexer = range(*old_indexer.indices(size))[applied_indexer] # type: ignore[assignment]
306307
else:
307-
indexer = _expand_slice(old_indexer, size)[applied_indexer] # type: ignore[assignment]
308+
indexer = _expand_slice(old_indexer, size)[applied_indexer]
308309
else:
309310
indexer = old_indexer[applied_indexer]
310311
return indexer

0 commit comments

Comments
 (0)