MCPcopy Index your code
hub / github.com/pydata/xarray / __init__

Method __init__

xarray/core/indexing.py:712–739  ·  view source on GitHub ↗

Parameters ---------- array : array_like Array like object to index. key : ExplicitIndexer, optional Array indexer. If provided, it is assumed to already be in canonical expanded form.

(self, array: Any, key: ExplicitIndexer | None = None)

Source from the content-addressed store, hash-verified

710 __slots__ = ("_shape", "array", "key")
711
712 def __init__(self, array: Any, key: ExplicitIndexer | None = None):
713 """
714 Parameters
715 ----------
716 array : array_like
717 Array like object to index.
718 key : ExplicitIndexer, optional
719 Array indexer. If provided, it is assumed to already be in
720 canonical expanded form.
721 """
722 if isinstance(array, type(self)) and key is None:
723 # unwrap
724 key = array.key # type: ignore[has-type, unused-ignore]
725 array = array.array # type: ignore[has-type, unused-ignore]
726
727 if key is None:
728 key = BasicIndexer((slice(None),) * array.ndim)
729
730 self.array = as_indexable(array)
731 self.key = key
732
733 shape: _Shape = ()
734 for size, k in zip(self.array.shape, self.key.tuple, strict=True):
735 if isinstance(k, slice):
736 shape += (len(range(*k.indices(size))),)
737 elif isinstance(k, np.ndarray):
738 shape += (k.size,)
739 self._shape = shape
740
741 def _updated_key(self, new_key: ExplicitIndexer) -> BasicIndexer | OuterIndexer:
742 iter_new_key = iter(expanded_indexer(new_key.tuple, self.ndim))

Callers

nothing calls this directly

Calls 3

as_indexableFunction · 0.90
typeFunction · 0.85
BasicIndexerClass · 0.85

Tested by

no test coverage detected