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

Method test_reduce

xarray/tests/test_dask.py:217–235  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

215 assert not a2._in_memory
216
217 def test_reduce(self):
218 u = self.eager_var
219 v = self.lazy_var
220 self.assertLazyAndAllClose(u.mean(), v.mean())
221 self.assertLazyAndAllClose(u.std(), v.std())
222 with raise_if_dask_computes():
223 actual = v.argmax(dim="x")
224 self.assertLazyAndAllClose(u.argmax(dim="x"), actual)
225 with raise_if_dask_computes():
226 actual = v.argmin(dim="x")
227 self.assertLazyAndAllClose(u.argmin(dim="x"), actual)
228 self.assertLazyAndAllClose((u > 1).any(), (v > 1).any())
229 self.assertLazyAndAllClose((u < 1).all("x"), (v < 1).all("x"))
230 with pytest.raises(NotImplementedError, match=r"only works along an axis"):
231 v.median()
232 with pytest.raises(NotImplementedError, match=r"only works along an axis"):
233 v.median(v.dims)
234 with raise_if_dask_computes():
235 v.reduce(duck_array_ops.mean)
236
237 def test_missing_values(self):
238 values = np.array([0, 1, np.nan, 3])

Callers

nothing calls this directly

Calls 10

assertLazyAndAllCloseMethod · 0.95
raise_if_dask_computesFunction · 0.90
meanMethod · 0.45
stdMethod · 0.45
argmaxMethod · 0.45
argminMethod · 0.45
anyMethod · 0.45
allMethod · 0.45
medianMethod · 0.45
reduceMethod · 0.45

Tested by

no test coverage detected