MCPcopy
hub / github.com/pydata/xarray / BasicIndexer

Class BasicIndexer

xarray/core/indexing.py:477–503  ·  view source on GitHub ↗

Tuple for basic indexing. All elements should be int or slice objects. Indexing follows NumPy's rules for basic indexing: each axis is independently sliced and axes indexed with an integer are dropped from the result.

Source from the content-addressed store, hash-verified

475
476
477class BasicIndexer(ExplicitIndexer):
478 """Tuple for basic indexing.
479
480 All elements should be int or slice objects. Indexing follows NumPy's
481 rules for basic indexing: each axis is independently sliced and axes
482 indexed with an integer are dropped from the result.
483 """
484
485 __slots__ = ()
486
487 def __init__(self, key: tuple[BasicIndexerType, ...]):
488 if not isinstance(key, tuple):
489 raise TypeError(f"key must be a tuple: {key!r}")
490
491 new_key = []
492 for k in key:
493 if isinstance(k, integer_types):
494 k = int(k)
495 elif isinstance(k, slice):
496 k = as_integer_slice(k)
497 else:
498 raise TypeError(
499 f"unexpected indexer type for {type(self).__name__}: {k!r}"
500 )
501 new_key.append(k)
502
503 super().__init__(tuple(new_key))
504
505
506class OuterIndexer(ExplicitIndexer):

Callers 10

first_n_itemsFunction · 0.90
last_n_itemsFunction · 0.90
get_duck_arrayMethod · 0.85
__init__Method · 0.85
_updated_keyMethod · 0.85
__getitem__Method · 0.85
_decompose_outer_indexerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…