MCPcopy Create free account
hub / github.com/pydata/xarray / _outer_to_numpy_indexer

Function _outer_to_numpy_indexer

xarray/core/indexing.py:1064–1085  ·  view source on GitHub ↗

Convert an OuterIndexer into an indexer for NumPy. Parameters ---------- indexer : Basic/OuterIndexer An indexer to convert. shape : tuple Shape of the array subject to the indexing. Returns ------- tuple Tuple suitable for use to index a NumPy a

(indexer: BasicIndexer | OuterIndexer, shape: _Shape)

Source from the content-addressed store, hash-verified

1062
1063
1064def _outer_to_numpy_indexer(indexer: BasicIndexer | OuterIndexer, shape: _Shape):
1065 """Convert an OuterIndexer into an indexer for NumPy.
1066
1067 Parameters
1068 ----------
1069 indexer : Basic/OuterIndexer
1070 An indexer to convert.
1071 shape : tuple
1072 Shape of the array subject to the indexing.
1073
1074 Returns
1075 -------
1076 tuple
1077 Tuple suitable for use to index a NumPy array.
1078 """
1079 if len([k for k in indexer.tuple if not isinstance(k, slice)]) <= 1:
1080 # If there is only one vector and all others are slice,
1081 # it can be safely used in mixed basic/advanced indexing.
1082 # Boolean index should already be converted to integer array.
1083 return indexer.tuple
1084 else:
1085 return _outer_to_vectorized_indexer(indexer, shape).tuple
1086
1087
1088def _combine_indexers(old_key, shape: _Shape, new_key) -> VectorizedIndexer:

Callers 2

_oindex_getMethod · 0.85
_oindex_setMethod · 0.85

Calls 1

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…