Test that complex expressions preserve dask backing.
()
| 489 | |
| 490 | @requires_dask |
| 491 | def test_eval_dask_complex_expression() -> None: |
| 492 | """Test that complex expressions preserve dask backing.""" |
| 493 | from xarray.core.utils import is_duck_dask_array |
| 494 | |
| 495 | rng = np.random.default_rng(42) |
| 496 | ds = Dataset( |
| 497 | { |
| 498 | "x": (["time", "lat", "lon"], rng.random((3, 4, 5))), |
| 499 | "y": (["time", "lat", "lon"], rng.random((3, 4, 5))), |
| 500 | } |
| 501 | ).chunk({"time": 1, "lat": 2, "lon": 5}) |
| 502 | |
| 503 | with raise_if_dask_computes(): |
| 504 | result = ds.eval("x * 2 + y ** 2") |
| 505 | |
| 506 | assert is_duck_dask_array(result.data) |
| 507 | |
| 508 | # Verify correctness when computed |
| 509 | expected = ds["x"] * 2 + ds["y"] ** 2 |
| 510 | assert_equal(result, expected) |
| 511 | |
| 512 | |
| 513 | @requires_dask |
nothing calls this directly
no test coverage detected
searching dependent graphs…