datatree/datatree.py
def _map_over_subtree(tree, *args, **kwargs):
        """Internal function which maps func over every node in tree, returning a tree of the results."""

        # Recreate and act on root node
        out_tree = DataNode(name=tree.name, data=tree.ds)
        if out_tree.has_data:
            out_tree.ds = func(out_tree.ds, *args, **kwargs)

        # Act on every other node in the tree, and rebuild from results
        for node in tree.descendants:
            # TODO make a proper relative_path method
            relative_path = node.pathstr.replace(tree.pathstr, '')
            result = func(node.ds, *args, **kwargs) if node.has_data else None
            out_tree[relative_path] = result

        return out_tree
Internal function which maps func over every node in tree, returning a tree of the results.
Internal function which maps func over every node in tree, returning a tree of the results.
Internal function which maps func over every node in tree returning a tree of the results .
def _map_over_subtree(tree, *args, **kwargs):
        out_tree = DataNode(name=tree.name, data=tree.ds)
        if out_tree.has_data:
            out_tree.ds = func(out_tree.ds, *args, **kwargs)
        for node in tree.descendants:
            relative_path = node.pathstr.replace(tree.pathstr, '')
            result = func(node.ds, *args, **kwargs) if node.has_data else None
            out_tree[relative_path] = result
        return out_tree
def _map_over_subtree ( tree , * args , ** kwargs ) : out_tree = DataNode ( name = tree . name , data = tree . ds ) if out_tree . has_data : out_tree . ds = func ( out_tree . ds , * args , ** kwargs ) for node in tree . descendants : relative_path = node . pathstr . replace ( tree . pathstr , '' ) result = func ( node . ds , * args , ** kwargs ) if node . has_data else None out_tree [ relative_path ] = result return out_tree
Internal function which maps func over every node in tree, returning a tree of the results.
Internal function which maps func over every node in tree returning a tree of the results .
"""Internal function which maps func over every node in tree, returning a tree of the results.""" # Recreate and act on root node # Act on every other node in the tree, and rebuild from results # TODO make a proper relative_path method
tree