(self)
| 1753 | |
| 1754 | class TestRestructuring: |
| 1755 | def test_drop_nodes(self) -> None: |
| 1756 | sue = DataTree.from_dict({"Mary": None, "Kate": None, "Ashley": None}) |
| 1757 | |
| 1758 | # test drop just one node |
| 1759 | dropped_one = sue.drop_nodes(names="Mary") |
| 1760 | assert "Mary" not in dropped_one.children |
| 1761 | |
| 1762 | # test drop multiple nodes |
| 1763 | dropped = sue.drop_nodes(names=["Mary", "Kate"]) |
| 1764 | assert not {"Mary", "Kate"}.intersection(set(dropped.children)) |
| 1765 | assert "Ashley" in dropped.children |
| 1766 | |
| 1767 | # test raise |
| 1768 | with pytest.raises(KeyError, match=r"nodes {'Mary'} not present"): |
| 1769 | dropped.drop_nodes(names=["Mary", "Ashley"]) |
| 1770 | |
| 1771 | # test ignore |
| 1772 | childless = dropped.drop_nodes(names=["Mary", "Ashley"], errors="ignore") |
| 1773 | assert childless.children == {} |
| 1774 | |
| 1775 | def test_assign(self) -> None: |
| 1776 | dt = DataTree() |
nothing calls this directly
no test coverage detected