datatree/datatree.py
def map_over_subtree(
        self,
        func: Callable,
        *args: Iterable[Any],
        **kwargs: Any,
    ) -> DataTree:
        """
        Apply a function to every dataset in this subtree, returning a new tree which stores the results.

        The function will be applied to any dataset stored in this node, as well as any dataset stored in any of the
        descendant nodes. The returned tree will have the same structure as the original subtree.

        func needs to return a Dataset in order to rebuild the subtree.

        Parameters
        ----------
        func : callable
            Function to apply to datasets with signature:
            `func(node.ds, *args, **kwargs) -> Dataset`.

            Function will not be applied to any nodes without datasets.
        *args : tuple, optional
            Positional arguments passed on to `func`.
        **kwargs : Any
            Keyword arguments passed on to `func`.

        Returns
        -------
        subtree : DataTree
            Subtree containing results from applying ``func`` to the dataset at each node.
        """
        # TODO this signature means that func has no way to know which node it is being called upon - change?

        return map_over_subtree(func)(self, *args, **kwargs)

        Apply a function to every dataset in this subtree, returning a new tree which stores the results.

        The function will be applied to any dataset stored in this node, as well as any dataset stored in any of the
        descendant nodes. The returned tree will have the same structure as the original subtree.

        func needs to return a Dataset in order to rebuild the subtree.

        Parameters
        ----------
        func : callable
            Function to apply to datasets with signature:
            `func(node.ds, *args, **kwargs) -> Dataset`.

            Function will not be applied to any nodes without datasets.
        *args : tuple, optional
            Positional arguments passed on to `func`.
        **kwargs : Any
            Keyword arguments passed on to `func`.

        Returns
        -------
        subtree : DataTree
            Subtree containing results from applying ``func`` to the dataset at each node.
        
Apply a function to every dataset in this subtree, returning a new tree which stores the results.
The function will be applied to any dataset stored in this node, as well as any dataset stored in any of the
descendant nodes. The returned tree will have the same structure as the original subtree.

func needs to return a Dataset in order to rebuild the subtree.

Parameters

func : callable
Function to apply to datasets with signature:
`func(node.ds, *args, **kwargs) -> Dataset`.

Function will not be applied to any nodes without datasets.
args : tuple, optional
Positional arguments passed on to `func`.
kwargs : Any
Keyword arguments passed on to `func`.

Returns

subtree : DataTree
Subtree containing results from applying ``func`` to the dataset at each node.
Apply a function to every dataset in this subtree returning a new tree which stores the results . The function will be applied to any dataset stored in this node as well as any dataset stored in any of the descendant nodes . The returned tree will have the same structure as the original subtree . func needs to return a Dataset in order to rebuild the subtree . Parameters func : callable Function to apply to datasets with signature : ` func ( node . ds * args ** kwargs ) - > Dataset ` . Function will not be applied to any nodes without datasets . args : tuple optional Positional arguments passed on to ` func ` . kwargs : Any Keyword arguments passed on to ` func ` . Returns subtree : DataTree Subtree containing results from applying ` ` func ` ` to the dataset at each node .
def map_over_subtree(
        self,
        func: Callable,
        *args: Iterable[Any],
        **kwargs: Any,
    ) -> DataTree:
        return map_over_subtree(func)(self, *args, **kwargs)
def map_over_subtree ( self , func : Callable , * args : Iterable [ Any ] , ** kwargs : Any , ) -> DataTree : return map_over_subtree ( func ) ( self , * args , ** kwargs )
Apply a function to every dataset in this subtree, returning a new tree which stores the results.
Apply a function to every dataset in this subtree returning a new tree which stores the results .
"""
        Apply a function to every dataset in this subtree, returning a new tree which stores the results.

        The function will be applied to any dataset stored in this node, as well as any dataset stored in any of the
        descendant nodes. The returned tree will have the same structure as the original subtree.

        func needs to return a Dataset in order to rebuild the subtree.

        Parameters
        ----------
        func : callable
            Function to apply to datasets with signature:
            `func(node.ds, *args, **kwargs) -> Dataset`.

            Function will not be applied to any nodes without datasets.
        *args : tuple, optional
            Positional arguments passed on to `func`.
        **kwargs : Any
            Keyword arguments passed on to `func`.

        Returns
        -------
        subtree : DataTree
            Subtree containing results from applying ``func`` to the dataset at each node.
        """ # TODO this signature means that func has no way to know which node it is being called upon - change?
self
func
Callable
args
Iterable[Any]
kwargs
Any