datatree.DataTree.isomorphic#

DataTree.isomorphic(other: datatree.datatree.DataTree, from_root: bool = False, strict_names: bool = False) bool[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 method does not check any part of the tree above the given node. Therefore this method can be used as default to check that two subtrees are isomorphic.

Parameters
  • other (DataTree) – The other tree object to compare to.

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

  • strict_names (bool, optional, default is False) – Whether or not to also check that every node in the tree has the same name as its counterpart in the other tree.