datatree/datatree.py
def _expose_methods_wrapped_to_map_over_subtree(obj, method_name, method):
    """
    Expose given method on node object, but wrapped to map over whole subtree, not just that node object.

    Result is like having written this in obj's class definition:

    ```
    @map_over_subtree
    def method_name(self, *args, **kwargs):
        return self.method(*args, **kwargs)
    ```
    """

    # Expose Dataset method, but wrapped to map over whole subtree when called
    # TODO should we be using functools.partialmethod here instead?
    mapped_over_tree = functools.partial(map_over_subtree(method), obj)
    setattr(obj, method_name, mapped_over_tree)

    # TODO do we really need this for ops like __add__?
    # Add a line to the method's docstring explaining how it's been mapped
    method_docstring = method.__doc__
    if method_docstring is not None:
        updated_method_docstring = method_docstring.replace('\n', _MAPPED_DOCSTRING_ADDENDUM, 1)
        obj_method = getattr(obj, method_name)
        setattr(obj_method, '__doc__', updated_method_docstring)

    Expose given method on node object, but wrapped to map over whole subtree, not just that node object.

    Result is like having written this in obj's class definition:

    ```
    @map_over_subtree
    def method_name(self, *args, **kwargs):
        return self.method(*args, **kwargs)
    ```
    
Expose given method on node object, but wrapped to map over whole subtree, not just that node object.
Result is like having written this in obj's class definition.


Expose given method on node object but wrapped to map over whole subtree not just that node object . Result is like having written this in obj ' s class definition .
def _expose_methods_wrapped_to_map_over_subtree(obj, method_name, method):
    mapped_over_tree = functools.partial(map_over_subtree(method), obj)
    setattr(obj, method_name, mapped_over_tree)
    method_docstring = method.__doc__
    if method_docstring is not None:
        updated_method_docstring = method_docstring.replace('\n', _MAPPED_DOCSTRING_ADDENDUM, 1)
        obj_method = getattr(obj, method_name)
        setattr(obj_method, '__doc__', updated_method_docstring)
def _expose_methods_wrapped_to_map_over_subtree ( obj , method_name , method ) : mapped_over_tree = functools . partial ( map_over_subtree ( method ) , obj ) setattr ( obj , method_name , mapped_over_tree ) method_docstring = method . __doc__ if method_docstring is not None : updated_method_docstring = method_docstring . replace ( '\n' , _MAPPED_DOCSTRING_ADDENDUM , 1 ) obj_method = getattr ( obj , method_name ) setattr ( obj_method , '__doc__' , updated_method_docstring )
Expose given method on node object, but wrapped to map over whole subtree, not just that node object.
Expose given method on node object but wrapped to map over whole subtree not just that node object .
"""
    Expose given method on node object, but wrapped to map over whole subtree, not just that node object.

    Result is like having written this in obj's class definition:

    ```
    @map_over_subtree
    def method_name(self, *args, **kwargs):
        return self.method(*args, **kwargs)
    ```
    """ # Expose Dataset method, but wrapped to map over whole subtree when called # TODO should we be using functools.partialmethod here instead? # TODO do we really need this for ops like __add__? # Add a line to the method's docstring explaining how it's been mapped
obj
method_name
method