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

Method test_where_cupy_duck_array

xarray/tests/test_duck_array_ops.py:190–201  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

188
189 @requires_cupy
190 def test_where_cupy_duck_array(self):
191 import cupy as cp
192
193 arr = cp.array([[cp.nan, cp.nan], [2, 3], [4, 5]])
194 mask = ~cp.isnan(arr)
195 da = DataArray(arr, dims=("x", "y"), name="example")
196 output = da.where(mask, 0)
197
198 expected = np.array([[0, 0], [2, 3], [4, 5]])
199
200 assert isinstance(output.data, cp.ndarray)
201 assert_array_equal(output.to_numpy(), expected)
202
203 def test_concatenate_extension_duck_array(self, categorical1, categorical2):
204 concate_res = concatenate(

Callers

nothing calls this directly

Calls 3

DataArrayClass · 0.90
whereMethod · 0.45
to_numpyMethod · 0.45

Tested by

no test coverage detected