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

Method test_name

xarray/tests/test_datatree.py:35–55  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

33 assert_identical(dt.to_dataset(), xr.Dataset())
34
35 def test_name(self) -> None:
36 dt = DataTree()
37 assert dt.name is None
38
39 dt = DataTree(name="foo")
40 assert dt.name == "foo"
41
42 dt.name = "bar"
43 assert dt.name == "bar"
44
45 dt = DataTree(children={"foo": DataTree()})
46 assert dt["/foo"].name == "foo"
47 with pytest.raises(
48 ValueError, match="cannot set the name of a node which already has a parent"
49 ):
50 dt["/foo"].name = "bar"
51
52 detached = dt["/foo"].copy()
53 assert detached.name == "foo"
54 detached.name = "bar"
55 assert detached.name == "bar"
56
57 def test_bad_names(self) -> None:
58 with pytest.raises(TypeError):

Callers

nothing calls this directly

Calls 2

DataTreeClass · 0.90
copyMethod · 0.45

Tested by

no test coverage detected