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

Method test_set_dims

xarray/tests/test_variable.py:1639–1658  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1637 v.get_axis_num(("x", "y")) + ()
1638
1639 def test_set_dims(self):
1640 v = Variable(["x"], [0, 1])
1641 actual = v.set_dims(["x", "y"])
1642 expected = Variable(["x", "y"], [[0], [1]])
1643 assert_identical(actual, expected)
1644
1645 actual = v.set_dims(["y", "x"])
1646 assert_identical(actual, expected.T)
1647
1648 actual = v.set_dims({"x": 2, "y": 2})
1649 expected = Variable(["x", "y"], [[0, 0], [1, 1]])
1650 assert_identical(actual, expected)
1651
1652 v = Variable(["foo"], [0, 1])
1653 actual = v.set_dims("foo")
1654 expected = v
1655 assert_identical(actual, expected)
1656
1657 with pytest.raises(ValueError, match=r"must be a superset"):
1658 v.set_dims(["z"])
1659
1660 def test_set_dims_object_dtype(self):
1661 v = Variable([], ("a", 1))

Callers

nothing calls this directly

Calls 3

set_dimsMethod · 0.95
VariableClass · 0.90
assert_identicalFunction · 0.90

Tested by

no test coverage detected