This function always returns an ExplicitlyIndexed subclass, so that the vectorized indexing is always possible with the returned object.
(array)
| 1003 | |
| 1004 | |
| 1005 | def 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 | |
| 1027 | def _outer_to_vectorized_indexer( |
no test coverage detected
searching dependent graphs…