Test that xr.where() with dask arrays preserves lazy evaluation.
()
| 471 | |
| 472 | @requires_dask |
| 473 | def 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 |
nothing calls this directly
no test coverage detected
searching dependent graphs…