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

Function test_eval_dask_mixed_backends

xarray/tests/test_eval.py:514–535  ·  view source on GitHub ↗

Test expressions with mixed dask and numpy arrays.

()

Source from the content-addressed store, hash-verified

512
513@requires_dask
514def test_eval_dask_mixed_backends() -> None:
515 """Test expressions with mixed dask and numpy arrays."""
516 from xarray.core.utils import is_duck_dask_array
517
518 ds = Dataset(
519 {
520 "dask_var": ("x", np.arange(10.0)),
521 "numpy_var": ("x", np.linspace(0, 1, 10)),
522 }
523 )
524 # Only chunk one variable
525 ds["dask_var"] = ds["dask_var"].chunk({"x": 5})
526
527 with raise_if_dask_computes():
528 result = ds.eval("dask_var + numpy_var")
529
530 # Result should be dask-backed when any input is dask
531 assert is_duck_dask_array(result.data)
532
533 # Verify correctness
534 expected = ds["dask_var"] + ds["numpy_var"]
535 assert_equal(result, expected)
536
537
538@requires_dask

Callers

nothing calls this directly

Calls 8

evalMethod · 0.95
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
chunkMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…