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

Class ArrayWithoutBroadcastTo

xarray/tests/test_variable.py:1670–1683  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1668
1669 def test_set_dims_without_broadcast(self):
1670 class ArrayWithoutBroadcastTo(NDArrayMixin, indexing.ExplicitlyIndexed):
1671 def __init__(self, array):
1672 self.array = array
1673
1674 # Broadcasting with __getitem__ is "easier" to implement
1675 # especially for dims of 1
1676 def __getitem__(self, key):
1677 return self.array[key]
1678
1679 def __array_function__(self, *args, **kwargs):
1680 raise NotImplementedError(
1681 "Not we don't want to use broadcast_to here "
1682 "https://github.com/pydata/xarray/issues/9462"
1683 )
1684
1685 arr = ArrayWithoutBroadcastTo(np.zeros((3, 4)))
1686 # We should be able to add a new axis without broadcasting

Callers 1

Calls

no outgoing calls

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…