def create_next_timer(*args, **kwargs):
def remove_last_timer():
def create_next_loop(*args, **kwargs):
def remove_last_loop():
def refresh_shortcuts():
def hard_reset():
def get_current_timer(): def dump_times():
def assign_subdivisions(position, keep_subdivisions=True):
def _assign_subdvsn(position):
def _assign_par_subdvsn(position): def sanitize_rgstr_stamps(rgstr_stamps=None):
    if rgstr_stamps is not None:
        if not isinstance(rgstr_stamps, (list, tuple)):
            raise TypeError("Expected list or tuple for param 'rgstr_stamps' (elements passed through str()).")
        rgstr_stamps = list(set(rgstr_stamps))
        for s in rgstr_stamps:
            s = str(s)
    else:
        rgstr_stamps = list()
    return rgstr_stamps def opt_arg_wrap(inner_wrap):
    def wrapped_dec(*args, **kwargs):
        if len(args) == 1 and callable(args[0]):
            return inner_wrap(args[0])
        else:
            def gtimer_wrapped_arg(func):
                return inner_wrap(func, *args, **kwargs)
            return gtimer_wrapped_arg
    return wrapped_dec UNASGN = 'UNASSIGNED' class StartError(GTimerError):
    pass class StoppedError(GTimerError):
    pass class PausedError(GTimerError):
    pass class LoopError(GTimerError):
    pass class GTimerError(Exception):
    pass class UniqueNameError(GTimerError):
    pass class BackdateError(GTimerError):
    pass
from timeit import default_timer as timer
from gtimer.private import focus as f
from gtimer.private import times as times_priv
from gtimer.local.util import sanitize_rgstr_stamps
from gtimer.util import opt_arg_wrap
from gtimer.private.const import UNASGN
from gtimer.local.exceptions import (StartError, StoppedError, PausedError,
                                     LoopError, GTimerError, UniqueNameError,
                                     BackdateError)
        raise StoppedError("Cannot resume stopped timer.")
    if not f.t.paused:
        raise PausedError("Cannot resume timer that is not paused.")
    f.t.paused = False
    f.t.start_t = t
    f.t.last_t = t
    return t


def blank_stamp(name=None, backdate=None,
                unique=None, keep_subdivisions=False, quick_print=None,
                un=None, ks=False, qp=None):
    """
    Mark the beginning of a new interval, but the elapsed time
    of the previous interval is discarded.  Intentionally the same signature
    as stamp().

    Notes:
        The default for keep_subdivisions is False (does not refer to an
        adjustable global setting), meaning that any subdivisons awaiting would be
        discarded after having their self times aggregated into this timer.  If
        this is set to True, subdivisions are put in the 'UNASSIGNED' position,
        indicating they are not properly accounted for in the hierarchy.

    Args:
        name (any, optional): Inactive.
        backdate (any, optional): Inactive.
        unique (any, optional): Inactive.
        keep_subdivisions (bool, optional): Keep subdivisions awaiting
        quick_print (any, optional): Inactive.
        un (any, optional): Inactive.
        ks (bool, optional): see stamp().
        qp (any, optional): Inactive.

    Returns:
        float: The current time.

    Raises:
        StoppedError: If timer is already stopped.
    """
    t = timer()
    if f.t.stopped:
        raise StoppedError("Cannot blank_stamp stopped timer.")
    keep_subdivisions = (keep_subdivisions or ks)
    times_priv.assign_subdivisions(UNASGN, keep_subdivisions)
    f.t.last_t = timer()
    f.t.self_cut += f.t.last_t - t
    return t


def reset():
    """
    Reset the timer at the current level in the hierarchy (i.e. might or
    might not be the root).

    Notes:
        Erases timing data but preserves relationship to the hierarchy.  If the
        current timer level was not previously stopped, any timing data from this
        timer (including subdivisions) will be discarded and not added to the next
        higher level in the data structure.  If the current timer was previously
        stopped, then its data has already been pushed into the next higher level.

    Returns:
        float: The current time.

    Raises:
        LoopError: If in a timed loop.
    """
    if f.t.in_loop:
        raise LoopError("Cannot reset a timer while it is in timed loop.")
    f.t.reset()
    f.refresh_shortcuts()
    return f.t.start_t


def current_time():
    """
    Returns the current time using timeit.default_timer() (same as used
    throughout gtimer).

    Returns:
        float: the current time
    """
    return timer()


#
# Timer hierarchy.
#


@opt_arg_wrap
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)