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

Function test_eval_dask_xr_where

xarray/tests/test_eval.py:473–487  ·  view source on GitHub ↗

Test that xr.where() with dask arrays preserves lazy evaluation.

()

Source from the content-addressed store, hash-verified

471
472@requires_dask
473def test_eval_dask_xr_where() -> None:
474 """Test that xr.where() with dask arrays preserves lazy evaluation."""
475 from xarray.core.utils import is_duck_dask_array
476
477 ds = Dataset({"a": ("x", np.arange(-5, 5, dtype=float))}).chunk({"x": 5})
478
479 with raise_if_dask_computes():
480 result = ds.eval("xr.where(a > 0, a, 0)")
481
482 assert isinstance(result, DataArray)
483 assert is_duck_dask_array(result.data)
484
485 # Verify correctness when computed
486 expected = xr.where(ds["a"] > 0, ds["a"], 0)
487 assert_equal(result, expected)
488
489
490@requires_dask

Callers

nothing calls this directly

Calls 8

DatasetClass · 0.90
raise_if_dask_computesFunction · 0.90
is_duck_dask_arrayFunction · 0.90
assert_equalFunction · 0.90
arangeMethod · 0.80
evalMethod · 0.80
chunkMethod · 0.45
whereMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…