datatree.testing.assert_isomorphic#

datatree.testing.assert_isomorphic(a: datatree.datatree.DataTree, b: datatree.datatree.DataTree, from_root: bool = False)[source][source]#

Two DataTrees are considered isomorphic if every node has the same number of children.

Nothing about the data in each node is checked.

Isomorphism is a necessary condition for two trees to be used in a nodewise binary operation, such as tree1 + tree2.

By default this function does not check any part of the tree above the given node. Therefore this function can be used as default to check that two subtrees are isomorphic.

Parameters
  • a (DataTree) – The first object to compare.

  • b (DataTree) – The second object to compare.

  • from_root (bool, optional, default is False) – Whether or not to first traverse to the root of the trees before checking for isomorphism. If a & b have no parents then this has no effect.

See also

DataTree.isomorphic, assert_equals, assert_identical