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

Method test_multiindex_level_as_coord

xarray/tests/test_plot.py:1519–1538  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1517 assert np.min(ax.get_xlim()) > 100.0
1518
1519 def test_multiindex_level_as_coord(self) -> None:
1520 da = DataArray(
1521 easy_array((3, 2)),
1522 dims=("x", "y"),
1523 coords=dict(x=("x", [0, 1, 2]), a=("y", [0, 1]), b=("y", [2, 3])),
1524 )
1525 da = da.set_index(y=["a", "b"])
1526
1527 for x, y in (("a", "x"), ("b", "x"), ("x", "a"), ("x", "b")):
1528 self.plotfunc(da, x=x, y=y)
1529
1530 ax = plt.gca()
1531 assert x == ax.get_xlabel()
1532 assert y == ax.get_ylabel()
1533
1534 with pytest.raises(ValueError, match=r"levels of the same MultiIndex"):
1535 self.plotfunc(da, x="a", y="b")
1536
1537 with pytest.raises(ValueError, match=r"y must be one of None, 'a', 'b', 'x'"):
1538 self.plotfunc(da, x="a", y="y")
1539
1540 def test_default_title(self) -> None:
1541 a = DataArray(easy_array((4, 3, 2)), dims=["a", "b", "c"])

Callers

nothing calls this directly

Calls 3

set_indexMethod · 0.95
DataArrayClass · 0.90
easy_arrayFunction · 0.85

Tested by

no test coverage detected