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

Method _broadcast_indexes_outer

xarray/core/variable.py:733–755  ·  view source on GitHub ↗
(self, key)

Source from the content-addressed store, hash-verified

731 )
732
733 def _broadcast_indexes_outer(self, key):
734 # drop dim if k is integer or if k is a 0d dask array
735 dims = tuple(
736 k.dims[0] if isinstance(k, Variable) else dim
737 for k, dim in zip(key, self.dims, strict=True)
738 if (not isinstance(k, integer_types) and not is_0d_dask_array(k))
739 )
740
741 new_key = []
742 for k in key:
743 if isinstance(k, Variable):
744 k = k.data
745 if not isinstance(k, BASIC_INDEXING_TYPES):
746 if not is_duck_array(k):
747 k = np.asarray(k)
748 if k.size == 0:
749 # Slice by empty list; numpy could not infer the dtype
750 k = k.astype(int)
751 elif k.dtype.kind == "b":
752 (k,) = np.nonzero(k)
753 new_key.append(k)
754
755 return dims, OuterIndexer(tuple(new_key)), None
756
757 def _broadcast_indexes_vectorized(self, key):
758 variables = []

Callers 1

_broadcast_indexesMethod · 0.95

Calls 4

is_0d_dask_arrayFunction · 0.90
is_duck_arrayFunction · 0.90
OuterIndexerClass · 0.90
astypeMethod · 0.45

Tested by

no test coverage detected