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

Function test_eval_dask_complex_expression

xarray/tests/test_eval.py:491–510  ·  view source on GitHub ↗

Test that complex expressions preserve dask backing.

()

Source from the content-addressed store, hash-verified

489
490@requires_dask
491def 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

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…