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

Function test_eval_dask_assignment

xarray/tests/test_eval.py:436–453  ·  view source on GitHub ↗

Test that assignments with dask arrays preserve lazy evaluation.

()

Source from the content-addressed store, hash-verified

434
435@requires_dask
436def test_eval_dask_assignment() -> None:
437 """Test that assignments with dask arrays preserve lazy evaluation."""
438 from xarray.core.utils import is_duck_dask_array
439
440 ds = Dataset(
441 {"a": ("x", np.arange(10.0)), "b": ("x", np.linspace(0, 1, 10))}
442 ).chunk({"x": 5})
443
444 with raise_if_dask_computes():
445 result = ds.eval("z = a + b")
446
447 assert isinstance(result, Dataset)
448 assert "z" in result.data_vars
449 assert is_duck_dask_array(result["z"].data)
450
451 # Verify correctness when computed
452 expected = ds["a"] + ds["b"]
453 assert_equal(result["z"], expected)
454
455
456@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
linspaceMethod · 0.80
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…