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

Function _sanitize_slice_element

xarray/core/indexes.py:554–569  ·  view source on GitHub ↗
(x)

Source from the content-addressed store, hash-verified

552
553
554def _sanitize_slice_element(x):
555 from xarray.core.dataarray import DataArray
556 from xarray.core.variable import Variable
557
558 if not isinstance(x, tuple) and len(np.shape(x)) != 0:
559 raise ValueError(
560 f"cannot use non-scalar arrays in a slice for xarray indexing: {x}"
561 )
562
563 if isinstance(x, Variable | DataArray):
564 x = x.values
565
566 if isinstance(x, np.ndarray):
567 x = x[()]
568
569 return x
570
571
572def _query_slice(index, label, coord_name="", method=None, tolerance=None):

Callers 1

_query_sliceFunction · 0.85

Calls 1

shapeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…