def wrap(func, subdivide=True, name=None, rgstr_stamps=None, save_itrs=None):
    """
    Decorator function which can automatically induce a subdivision on
    entering a subfunction or method.  Can be used (as @gtimer.wrap) with or
    without any arguments.

    Notes:
        If subdivide is False, then the wrapper does nothing but return the
        provided function.

        If a name is not provided, the function's __name__ is used (recommended).

        For the other options, see subdivide().

    Args:
        func (callable): Function to be decorated.
        subdivide (bool, optional): To subdivide.
        name (any, optional): Identifier for the subdivision, passed through str()
        rgstr_stamps (list,tuple, optional): Identifiers.
        save_itrs (bool, optional): to save individual iterations.

    Returns:
        callable: A new function or method with timing hierarchy management
            surrounding a call to the original function.
    """
    subdivision = bool(subdivide)
    if subdivision:
        name = func.__name__ if name is None else str(name)
        rgstr_stamps = sanitize_rgstr_stamps(rgstr_stamps)
        wrap_save_itrs = save_itrs

        def gtimer_wrapped(*args, **kwargs):
            save_itrs = SET['SI'] if wrap_save_itrs is None else wrap_save_itrs
            _auto_subdivide(name, rgstr_stamps, save_itrs=save_itrs)
            result = func(*args, **kwargs)
            _end_auto_subdivision()
            return result
    else:
        def gtimer_wrapped(*args, **kwargs):
            return func(*args, **kwargs)

    return gtimer_wrapped
def wrap ( func , subdivide = True , name = None , rgstr_stamps = None , save_itrs = None ) : subdivision = bool ( subdivide ) if subdivision : name = func . __name__ if name is None else str ( name ) rgstr_stamps = sanitize_rgstr_stamps ( rgstr_stamps ) wrap_save_itrs = save_itrs def gtimer_wrapped ( * args , ** kwargs ) : save_itrs = SET [ 'SI' ] if wrap_save_itrs is None else wrap_save_itrs _auto_subdivide ( name , rgstr_stamps , save_itrs = save_itrs ) result = func ( * args , ** kwargs ) _end_auto_subdivision ( ) return result else : def gtimer_wrapped ( * args , ** kwargs ) : return func ( * args , ** kwargs ) return gtimer_wrapped
Decorator function which can automatically induce a subdivision on
    entering a subfunction or method.  Can be used (as @gtimer.wrap) with or
    without any arguments.

    Notes:
        If subdivide is False, then the wrapper does nothing but return the
        provided function.

        If a name is not provided, the function's __name__ is used (recommended).

        For the other options, see subdivide().

    Args:
        func (callable): Function to be decorated.
        subdivide (bool, optional): To subdivide.
        name (any, optional): Identifier for the subdivision, passed through str()
        rgstr_stamps (list,tuple, optional): Identifiers.
        save_itrs (bool, optional): to save individual iterations.

    Returns:
        callable: A new function or method with timing hierarchy management
            surrounding a call to the original function.