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

Function test_nD_coord_dataarray

xarray/tests/test_dataarray.py:7622–7651  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7620
7621
7622def test_nD_coord_dataarray() -> None:
7623 # should succeed
7624 da = DataArray(
7625 np.ones((2, 4)),
7626 dims=("x", "y"),
7627 coords={
7628 "x": (("x", "y"), np.arange(8).reshape((2, 4))),
7629 "y": ("y", np.arange(4)),
7630 },
7631 )
7632 _assert_internal_invariants(da, check_default_indexes=True)
7633
7634 da2 = DataArray(np.ones(4), dims=("y"), coords={"y": ("y", np.arange(4))})
7635 da3 = DataArray(np.ones(4), dims=("z"))
7636
7637 _, actual = xr.align(da, da2)
7638 assert_identical(da2, actual)
7639
7640 expected = da.drop_vars("x")
7641 _, actual = xr.broadcast(da, da2)
7642 assert_identical(expected, actual)
7643
7644 actual, _ = xr.broadcast(da, da3)
7645 expected = da.expand_dims(z=4, axis=-1)
7646 assert_identical(actual, expected)
7647
7648 da4 = DataArray(np.ones((2, 4)), coords={"x": 0}, dims=["x", "y"])
7649 _assert_internal_invariants(da4, check_default_indexes=True)
7650 assert "x" not in da4.xindexes
7651 assert "x" in da4.coords
7652
7653
7654def test_lazy_data_variable_not_loaded():

Callers

nothing calls this directly

Calls 7

drop_varsMethod · 0.95
expand_dimsMethod · 0.95
DataArrayClass · 0.90
assert_identicalFunction · 0.90
arangeMethod · 0.80
alignMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…