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

Function as_indexable

xarray/core/indexing.py:1005–1024  ·  view source on GitHub ↗

This function always returns an ExplicitlyIndexed subclass, so that the vectorized indexing is always possible with the returned object.

(array)

Source from the content-addressed store, hash-verified

1003
1004
1005def as_indexable(array):
1006 """
1007 This function always returns an ExplicitlyIndexed subclass,
1008 so that the vectorized indexing is always possible with the returned
1009 object.
1010 """
1011 if isinstance(array, ExplicitlyIndexed):
1012 return array
1013 if isinstance(array, np.ndarray):
1014 return NumpyIndexingAdapter(array)
1015 if isinstance(array, pd.Index):
1016 return PandasIndexingAdapter(array)
1017 if is_duck_dask_array(array):
1018 return DaskIndexingAdapter(array)
1019 if hasattr(array, "__array_namespace__"):
1020 return ArrayApiIndexingAdapter(array)
1021 if hasattr(array, "__array_function__"):
1022 return NdArrayLikeIndexingAdapter(array)
1023
1024 raise TypeError(f"Invalid array type: {type(array)}")
1025
1026
1027def _outer_to_vectorized_indexer(

Callers 15

__getitem__Method · 0.90
_getitem_with_maskMethod · 0.90
__setitem__Method · 0.90
transposeMethod · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
__init__Method · 0.90
_ensure_copiedMethod · 0.90
__init__Method · 0.90
get_duck_arrayMethod · 0.90
async_get_duck_arrayMethod · 0.90

Calls 7

is_duck_dask_arrayFunction · 0.90
DaskIndexingAdapterClass · 0.85
typeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…