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

Method isel

xarray/core/indexes.py:818–837  ·  view source on GitHub ↗
(
        self, indexers: Mapping[Any, int | slice | np.ndarray | Variable]
    )

Source from the content-addressed store, hash-verified

816 return self.index
817
818 def isel(
819 self, indexers: Mapping[Any, int | slice | np.ndarray | Variable]
820 ) -> PandasIndex | None:
821 from xarray.core.variable import Variable
822
823 indxr = indexers[self.dim]
824 if isinstance(indxr, Variable):
825 if indxr.dims != (self.dim,):
826 # can't preserve an index if result has new dimensions
827 return None
828 else:
829 indxr = indxr.data
830 if not isinstance(indxr, slice) and is_scalar(indxr):
831 # scalar indexer: drop index
832 return None
833
834 if isinstance(indxr, slice) and indxr == slice(None):
835 return self
836
837 return self._replace(self.index[indxr]) # type: ignore[index,unused-ignore]
838
839 def sel(
840 self, labels: dict[Any, Any], method=None, tolerance=None

Callers

nothing calls this directly

Calls 2

_replaceMethod · 0.95
is_scalarFunction · 0.90

Tested by

no test coverage detected