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

Function test_temp_dataarray

xarray/tests/test_plot.py:3561–3597  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3559
3560@requires_matplotlib
3561def test_temp_dataarray() -> None:
3562 from xarray.plot.dataset_plot import _temp_dataarray
3563
3564 x = np.arange(1, 4)
3565 y = np.arange(4, 6)
3566 var1 = np.arange(x.size * y.size).reshape((x.size, y.size))
3567 var2 = np.arange(x.size * y.size).reshape((x.size, y.size))
3568 ds = xr.Dataset(
3569 {
3570 "var1": (["x", "y"], var1),
3571 "var2": (["x", "y"], 2 * var2),
3572 "var3": (["x"], 3 * x),
3573 },
3574 coords={
3575 "x": x,
3576 "y": y,
3577 "model": np.arange(7),
3578 },
3579 )
3580
3581 # No broadcasting:
3582 y_ = "var1"
3583 locals_ = {"x": "var2"}
3584 da = _temp_dataarray(ds, y_, locals_)
3585 assert da.shape == (3, 2)
3586
3587 # Broadcast from 1 to 2dim:
3588 y_ = "var3"
3589 locals_ = {"x": "var1"}
3590 da = _temp_dataarray(ds, y_, locals_)
3591 assert da.shape == (3, 2)
3592
3593 # Ignore non-valid coord kwargs:
3594 y_ = "var3"
3595 locals_ = dict(x="x", extend="var2")
3596 da = _temp_dataarray(ds, y_, locals_)
3597 assert da.shape == (3,)
3598
3599
3600@requires_matplotlib

Callers

nothing calls this directly

Calls 2

_temp_dataarrayFunction · 0.90
arangeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…