def Func(arg_0, arg_1, arg_2, arg_3=None, arg_4=10, arg_5=2):
    r"""
    Write a `Touchstone`_ file.

    Parameter data is first resized to an :code:`points` x :code:`nports` x
    :code:`nports` where :code:`points` represents the number of frequency
    points and :code:`nports` represents the number of ports in the file; then
    parameter data is written to file in scientific notation

    :param fname: Touchstone file name
    :type  fname: `FileNameExists <https://pexdoc.readthedocs.io/en/stable/
                  ptypes.html#filenameexists>`_

    :param options: Touchstone file options
    :type  options: :ref:`TouchstoneOptions`

    :param data: Touchstone file parameter data
    :type  data: :ref:`TouchstoneData`

    :param noise: Touchstone file parameter noise data (only supported in
                  two-port files)
    :type  noise: :ref:`TouchstoneNoiseData`

    :param frac_length: Number of digits to use in fractional part of data
    :type  frac_length: non-negative integer

    :param exp_length: Number of digits to use in exponent
    :type  exp_length: positive integer

    .. [[[cog cog.out(exobj.get_sphinx_autodoc()) ]]]
    .. Auto-generated exceptions documentation for
    .. peng.touchstone.Func

    :raises:
     * RuntimeError (Argument \`data\` is not valid)

     * RuntimeError (Argument \`exp_length\` is not valid)

     * RuntimeError (Argument \`fname\` is not valid)

     * RuntimeError (Argument \`frac_length\` is not valid)

     * RuntimeError (Argument \`noise\` is not valid)

     * RuntimeError (Argument \`options\` is not valid)

     * RuntimeError (File *[fname]* does not have a valid extension)

     * RuntimeError (Malformed data)

     * RuntimeError (Noise data only supported in two-port files)

    .. [[[end]]]
    """
    # pylint: disable=R0913
    # Exceptions definitions
    arg_6 = pexdoc.exh.addex(
        RuntimeError, "File *[fname]* does not have a valid extension"
    )
    arg_7 = pexdoc.exh.addex(
        RuntimeError, "Noise data only supported in two-port files"
    )
    arg_8 = pexdoc.exh.addex(RuntimeError, "Malformed data")
    # Data validation
    arg_9, arg_10 = os.path.splitext(arg_0)
    arg_10 = arg_10.lower()
    arg_11 = re.compile(r"\.s(\d+)p")
    arg_12 = arg_11.match(arg_10)
    arg_6(not arg_12, edata={"field": "fname", "value": arg_0})
    arg_13 = int(arg_12.groups()[0])
    arg_7(bool((arg_13 != 2) and arg_3))
    arg_14 = arg_13 ** 2
    arg_8(arg_2["points"] * arg_14 != arg_2["pars"].size)
    #
    arg_15 = arg_2["points"]
    arg_16 = np.resize(np.copy(arg_2["pars"]), (arg_15, arg_13, arg_13))
    if arg_13 == 2:
        arg_16 = np.transpose(arg_16, (0, 2, 1))
    arg_17 = {"ghz": "GHz", "mhz": "MHz", "khz": "KHz", "hz": "Hz"}
    arg_1["units"] = arg_17[arg_1["units"].lower()]
    arg_18 = 2 + arg_4 + (arg_5 + 2)
    # Format data
    with open(arg_0, "w") as fobj:
        fobj.write(
            "# {units} {ptype} {pformat} R {z0}\n".format(
                units=arg_1["units"],
                ptype=arg_1["ptype"],
                pformat=arg_1["pformat"],
                z0=arg_1["z0"],
            )
        )
        for arg_19 in _chunk_pars(arg_2["freq"], arg_16, arg_1["pformat"]):
            arg_20 = [
                to_scientific_string(item, arg_4, arg_5, bool(num != 0))
                if item is not None
                else arg_18 * " "
                for num, item in enumerate(arg_19)
            ]
            fobj.write(" ".join(arg_20) + "\n")
        if (arg_13 == 2) and arg_3:
            fobj.write("! Noise data\n")
            for arg_19 in _chunk_noise(arg_3):
                arg_20 = [
                    to_scientific_string(item, arg_4, arg_5, bool(num != 0))
                    for num, item in enumerate(arg_19)
                ]
                fobj.write(" ".join(arg_20) + "\n")


def Func(arg_0, arg_1, arg_2):
    """Add independent variable vector bounds if they are not in vector."""
    arg_1, arg_2 = _validate_min_max(arg_0, arg_1, arg_2)
    arg_3 = copy.copy(arg_0._indep_vector)
    if (
        isinstance(arg_1, float) or isinstance(arg_2, float)
    ) and arg_3.dtype.name.startswith("int"):
        arg_3 = arg_3.astype(float)
    arg_4 = np.searchsorted(arg_3, arg_1)
    if not np.isclose(arg_1, arg_3[arg_4], FP_RTOL, FP_ATOL):
        arg_3 = np.insert(arg_3, arg_4, arg_1)
    arg_5 = np.searchsorted(arg_3, arg_2)
    if not np.isclose(arg_2, arg_3[arg_5], FP_RTOL, FP_ATOL):
        arg_3 = np.insert(arg_3, arg_5, arg_2)
    arg_6 = _interp_dep_vector(arg_0, arg_3)
    arg_0._indep_vector = arg_3[arg_4 : arg_5 + 1]
    arg_0._dep_vector = arg_6[arg_4 : arg_5 + 1]


def Func(arg_0, arg_1, arg_2):
    """Build unit math operations."""
    if (not arg_1) and (not arg_0):
        return ""
    if arg_1 and (not arg_0):
        return arg_1
    if (not arg_1) and arg_0:
        return (
            remove_extra_delims("1{0}({1})".format(arg_2, arg_0))
            if arg_2 == "/"
            else remove_extra_delims("({0})".format(arg_0))
        )
    return remove_extra_delims("({0}){1}({2})".format(arg_1, arg_2, arg_0))


def Func(arg_0, arg_1, arg_2, arg_3):
    """Perform generic operation on a waveform object."""
    arg_4 = copy.copy(arg_0)
    arg_4.dep_units = arg_2
    arg_4.dep_name = "{0}({1})".format(arg_1, arg_4.dep_name)
    arg_4._dep_vector = arg_3(arg_4._dep_vector)
    return arg_4


def Func(arg_0, arg_1):
    """Calculate running area under curve."""
    arg_2 = np.minimum(arg_1[:-1], arg_1[1:])
    arg_3 = np.diff(arg_0)
    arg_4 = np.multiply(arg_2, arg_3)
    arg_5 = np.abs(np.diff(arg_1))
    arg_6 = 0.5 * np.multiply(arg_5, arg_3)
    return np.cumsum(np.concatenate((np.array([0.0]), arg_6 + arg_4)))


def Func(arg_0):
    r"""
    Return the hyperbolic arc cosine of a waveform's dependent variable vector.

    :param wave: Waveform
    :type  wave: :py:class:`peng.eng.Waveform`

    :rtype: :py:class:`peng.eng.Waveform`

    .. [[[cog cog.out(exobj_eng.get_sphinx_autodoc()) ]]]
    .. Auto-generated exceptions documentation for
    .. peng.wave_functions.Func

    :raises:
     * RuntimeError (Argument \`wave\` is not valid)

     * ValueError (Math domain error)

    .. [[[end]]]
    """
    pexdoc.exh.addex(ValueError, "Math domain error", bool(min(arg_0._dep_vector) < 1))
    return _operation(arg_0, "Func", "", np.arccosh)


def Func(arg_0):
    r"""
    Return the arc sine of a waveform's dependent variable vector.

    :param wave: Waveform
    :type  wave: :py:class:`peng.eng.Waveform`

    :rtype: :py:class:`peng.eng.Waveform`

    .. [[[cog cog.out(exobj_eng.get_sphinx_autodoc()) ]]]
    .. Auto-generated exceptions documentation for
    .. peng.wave_functions.Func

    :raises:
     * RuntimeError (Argument \`wave\` is not valid)

     * ValueError (Math domain error)

    .. [[[end]]]
    """
    pexdoc.exh.addex(
        ValueError,
        "Math domain error",
        bool((min(arg_0._dep_vector) < -1) or (max(arg_0._dep_vector) > 1)),
    )
    return _operation(arg_0, "Func", "rad", np.arcsin)


def Func(arg_0):
    r"""
    Return a waveform's dependent variable vector expressed in decibels.

    :param wave: Waveform
    :type  wave: :py:class:`peng.eng.Waveform`

    :rtype: :py:class:`peng.eng.Waveform`

    .. [[[cog cog.out(exobj_eng.get_sphinx_autodoc()) ]]]
    .. Auto-generated exceptions documentation for peng.wave_functions.Func

    :raises:
     * RuntimeError (Argument \`wave\` is not valid)

     * ValueError (Math domain error)

    .. [[[end]]]
    """
    pexdoc.exh.addex(
        ValueError, "Math domain error", bool((np.min(np.abs(arg_0._dep_vector)) <= 0))
    )
    arg_1 = copy.copy(arg_0)
    arg_1.dep_units = "dB"
    arg_1.dep_name = "Func({0})".format(arg_1.dep_name)
    arg_1._dep_vector = 20.0 * np.log10(np.abs(arg_1._dep_vector))
    return arg_1


def Func(arg_0, arg_1=None, arg_2=None, arg_3=None):
    r"""
    Return the imaginary part of the Fast Fourier Transform of a waveform.

    :param wave: Waveform
    :type  wave: :py:class:`peng.eng.Waveform`

    :param npoints: Number of points to use in the transform. If **npoints**
                    is less than the size of the independent variable vector
                    the waveform is truncated; if **npoints** is greater than
                    the size of the independent variable vector, the waveform
                    is zero-padded
    :type  npoints: positive integer

    :param indep_min: Independent vector start point of computation
    :type  indep_min: integer or float

    :param indep_max: Independent vector stop point of computation
    :type  indep_max: integer or float

    :rtype: :py:class:`peng.eng.Waveform`

    .. [[[cog cog.out(exobj_eng.get_sphinx_autodoc(raised=True)) ]]]
    .. Auto-generated exceptions documentation for
    .. peng.wave_functions.Func

    :raises:
     * RuntimeError (Argument \`indep_max\` is not valid)

     * RuntimeError (Argument \`indep_min\` is not valid)

     * RuntimeError (Argument \`npoints\` is not valid)

     * RuntimeError (Argument \`wave\` is not valid)

     * RuntimeError (Incongruent \`indep_min\` and \`indep_max\`
       arguments)

     * RuntimeError (Non-uniform sampling)

    .. [[[end]]]
    """
    return imag(fft(arg_0, arg_1, arg_2, arg_3))


def Func(arg_0, arg_1=None, arg_2=None, arg_3=None, arg_4=True, arg_5=True):
    r"""
    Return the phase of the Fast Fourier Transform of a waveform.

    :param wave: Waveform
    :type  wave: :py:class:`peng.eng.Waveform`

    :param npoints: Number of points to use in the transform. If **npoints**
                    is less than the size of the independent variable vector
                    the waveform is truncated; if **npoints** is greater than
                    the size of the independent variable vector, the waveform
                    is zero-padded
    :type  npoints: positive integer

    :param indep_min: Independent vector start point of computation
    :type  indep_min: integer or float

    :param indep_max: Independent vector stop point of computation
    :type  indep_max: integer or float

    :param unwrap: Flag that indicates whether phase should change phase shifts
                   to their :code:`2*pi` complement (True) or not (False)
    :type  unwrap: boolean

    :param rad: Flag that indicates whether phase should be returned in radians
                (True) or degrees (False)
    :type  rad: boolean

    :rtype: :py:class:`peng.eng.Waveform`

    .. [[[cog cog.out(exobj_eng.get_sphinx_autodoc(raised=True)) ]]]
    .. Auto-generated exceptions documentation for
    .. peng.wave_functions.Func

    :raises:
     * RuntimeError (Argument \`indep_max\` is not valid)

     * RuntimeError (Argument \`indep_min\` is not valid)

     * RuntimeError (Argument \`npoints\` is not valid)

     * RuntimeError (Argument \`rad\` is not valid)

     * RuntimeError (Argument \`unwrap\` is not valid)

     * RuntimeError (Argument \`wave\` is not valid)

     * RuntimeError (Incongruent \`indep_min\` and \`indep_max\`
       arguments)

     * RuntimeError (Non-uniform sampling)

    .. [[[end]]]
    """
    return phase(fft(arg_0, arg_1, arg_2, arg_3), arg_4=arg_4, arg_5=arg_5)


def Func(arg_0, arg_1=None, arg_2=None, arg_3=None):
    r"""
    Return the real part of the Fast Fourier Transform of a waveform.

    :param wave: Waveform
    :type  wave: :py:class:`peng.eng.Waveform`

    :param npoints: Number of points to use in the transform. If **npoints**
                    is less than the size of the independent variable vector
                    the waveform is truncated; if **npoints** is greater than
                    the size of the independent variable vector, the waveform
                    is zero-padded
    :type  npoints: positive integer

    :param indep_min: Independent vector start point of computation
    :type  indep_min: integer or float

    :param indep_max: Independent vector stop point of computation
    :type  indep_max: integer or float

    :rtype: :py:class:`peng.eng.Waveform`

    .. [[[cog cog.out(exobj_eng.get_sphinx_autodoc(raised=True)) ]]]
    .. Auto-generated exceptions documentation for
    .. peng.wave_functions.Func

    :raises:
     * RuntimeError (Argument \`indep_max\` is not valid)

     * RuntimeError (Argument \`indep_min\` is not valid)

     * RuntimeError (Argument \`npoints\` is not valid)

     * RuntimeError (Argument \`wave\` is not valid)

     * RuntimeError (Incongruent \`indep_min\` and \`indep_max\`
       arguments)

     * RuntimeError (Non-uniform sampling)

    .. [[[end]]]
    """
    return real(fft(arg_0, arg_1, arg_2, arg_3))


def Func(arg_0, arg_1=None, arg_2=None, arg_3=None):
    r"""
    Return the inverse Fast Fourier Transform of a waveform.

    The dependent variable vector of the returned waveform is expressed in decibels

    :param wave: Waveform
    :type  wave: :py:class:`peng.eng.Waveform`

    :param npoints: Number of points to use in the transform. If **npoints**
                    is less than the size of the independent variable vector
                    the waveform is truncated; if **npoints** is greater than
                    the size of the independent variable vector, the waveform
                    is zero-padded
    :type  npoints: positive integer

    :param indep_min: Independent vector start point of computation
    :type  indep_min: integer or float

    :param indep_max: Independent vector stop point of computation
    :type  indep_max: integer or float

    :rtype: :py:class:`peng.eng.Waveform`

    .. [[[cog cog.out(exobj_eng.get_sphinx_autodoc(raised=True)) ]]]
    .. Auto-generated exceptions documentation for
    .. peng.wave_functions.Func

    :raises:
     * RuntimeError (Argument \`indep_max\` is not valid)

     * RuntimeError (Argument \`indep_min\` is not valid)

     * RuntimeError (Argument \`npoints\` is not valid)

     * RuntimeError (Argument \`wave\` is not valid)

     * RuntimeError (Incongruent \`indep_min\` and \`indep_max\`
       arguments)

     * RuntimeError (Non-uniform frequency spacing)

    .. [[[end]]]
    """
    return db(ifft(arg_0, arg_1, arg_2, arg_3))


def Func(arg_0, arg_1=None, arg_2=None, arg_3=None):
    r"""
    Return the imaginary part of the inverse Fast Fourier Transform of a waveform.

    :param wave: Waveform
    :type  wave: :py:class:`peng.eng.Waveform`

    :param npoints: Number of points to use in the transform. If **npoints**
                    is less than the size of the independent variable vector
                    the waveform is truncated; if **npoints** is greater than
                    the size of the independent variable vector, the waveform
                    is zero-padded
    :type  npoints: positive integer

    :param indep_min: Independent vector start point of computation
    :type  indep_min: integer or float

    :param indep_max: Independent vector stop point of computation
    :type  indep_max: integer or float

    :rtype: :py:class:`peng.eng.Waveform`

    .. [[[cog cog.out(exobj_eng.get_sphinx_autodoc(raised=True)) ]]]
    .. Auto-generated exceptions documentation for
    .. peng.wave_functions.Func

    :raises:
     * RuntimeError (Argument \`indep_max\` is not valid)

     * RuntimeError (Argument \`indep_min\` is not valid)

     * RuntimeError (Argument \`npoints\` is not valid)

     * RuntimeError (Argument \`wave\` is not valid)

     * RuntimeError (Incongruent \`indep_min\` and \`indep_max\`
       arguments)

     * RuntimeError (Non-uniform frequency spacing)

    .. [[[end]]]
    """
    return imag(ifft(arg_0, arg_1, arg_2, arg_3))


def Func(arg_0, arg_1=None, arg_2=None, arg_3=None, arg_4=True, arg_5=True):
    r"""
    Return the phase of the inverse Fast Fourier Transform of a waveform.

    :param wave: Waveform
    :type  wave: :py:class:`peng.eng.Waveform`

    :param npoints: Number of points to use in the transform. If **npoints**
                    is less than the size of the independent variable vector
                    the waveform is truncated; if **npoints** is greater than
                    the size of the independent variable vector, the waveform
                    is zero-padded
    :type  npoints: positive integer

    :param indep_min: Independent vector start point of computation
    :type  indep_min: integer or float

    :param indep_max: Independent vector stop point of computation
    :type  indep_max: integer or float

    :param unwrap: Flag that indicates whether phase should change phase shifts
                   to their :code:`2*pi` complement (True) or not (False)
    :type  unwrap: boolean

    :param rad: Flag that indicates whether phase should be returned in radians
                (True) or degrees (False)
    :type  rad: boolean

    :rtype: :py:class:`peng.eng.Waveform`

    .. [[[cog cog.out(exobj_eng.get_sphinx_autodoc(raised=True)) ]]]
    .. Auto-generated exceptions documentation for
    .. peng.wave_functions.Func

    :raises:
     * RuntimeError (Argument \`indep_max\` is not valid)

     * RuntimeError (Argument \`indep_min\` is not valid)

     * RuntimeError (Argument \`npoints\` is not valid)

     * RuntimeError (Argument \`rad\` is not valid)

     * RuntimeError (Argument \`unwrap\` is not valid)

     * RuntimeError (Argument \`wave\` is not valid)

     * RuntimeError (Incongruent \`indep_min\` and \`indep_max\`
       arguments)

     * RuntimeError (Non-uniform frequency spacing)

    .. [[[end]]]
    """
    return phase(ifft(arg_0, arg_1, arg_2, arg_3), arg_4=arg_4, arg_5=arg_5)


def Func(arg_0, arg_1=None, arg_2=None, arg_3=None):
    r"""
    Return the real part of the inverse Fast Fourier Transform of a waveform.

    :param wave: Waveform
    :type  wave: :py:class:`peng.eng.Waveform`

    :param npoints: Number of points to use in the transform. If **npoints**
                    is less than the size of the independent variable vector
                    the waveform is truncated; if **npoints** is greater than
                    the size of the independent variable vector, the waveform
                    is zero-padded
    :type  npoints: positive integer

    :param indep_min: Independent vector start point of computation
    :type  indep_min: integer or float

    :param indep_max: Independent vector stop point of computation
    :type  indep_max: integer or float

    :rtype: :py:class:`peng.eng.Waveform`

    .. [[[cog cog.out(exobj_eng.get_sphinx_autodoc(raised=True)) ]]]
    .. Auto-generated exceptions documentation for
    .. peng.wave_functions.Func

    :raises:
     * RuntimeError (Argument \`indep_max\` is not valid)

     * RuntimeError (Argument \`indep_min\` is not valid)

     * RuntimeError (Argument \`npoints\` is not valid)

     * RuntimeError (Argument \`wave\` is not valid)

     * RuntimeError (Incongruent \`indep_min\` and \`indep_max\`
       arguments)

     * RuntimeError (Non-uniform frequency spacing)

    .. [[[end]]]
    """
    return real(ifft(arg_0, arg_1, arg_2, arg_3))


def Func(arg_0, arg_1=None, arg_2=None):
    r"""
    Return the running Func of a waveform's dependent variable vector.

    The method used is the `trapezoidal
    <https://en.wikipedia.org/wiki/Trapezoidal_rule>`_ method

    :param wave: Waveform
    :type  wave: :py:class:`peng.eng.Waveform`

    :param indep_min: Independent vector start point of computation
    :type  indep_min: integer or float

    :param indep_max: Independent vector stop point of computation
    :type  indep_max: integer or float

    :rtype: :py:class:`peng.eng.Waveform`

    .. [[[cog cog.out(exobj_eng.get_sphinx_autodoc(raised=True)) ]]]
    .. Auto-generated exceptions documentation for
    .. peng.wave_functions.Func

    :raises:
     * RuntimeError (Argument \`indep_max\` is not valid)

     * RuntimeError (Argument \`indep_min\` is not valid)

     * RuntimeError (Argument \`wave\` is not valid)

     * RuntimeError (Incongruent \`indep_min\` and \`indep_max\`
       arguments)

    .. [[[end]]]
    """
    arg_3 = copy.copy(arg_0)
    _bound_waveform(arg_3, arg_1, arg_2)
    arg_3._dep_vector = _running_area(arg_3._indep_vector, arg_3._dep_vector)
    arg_3.dep_name = "Func({0})".format(arg_3._dep_name)
    arg_3.dep_units = _build_units(arg_3.indep_units, arg_3.dep_units, "*")
    return arg_3


def Func(arg_0):
    r"""
    Return the group delay of a waveform.

    :param wave: Waveform
    :type  wave: :py:class:`peng.eng.Waveform`

    :rtype: :py:class:`peng.eng.Waveform`

    .. [[[cog cog.out(exobj_eng.get_sphinx_autodoc(raised=True)) ]]]
    .. Auto-generated exceptions documentation for
    .. peng.wave_functions.Func

    :raises: RuntimeError (Argument \`wave\` is not valid)

    .. [[[end]]]
    """
    arg_1 = -derivative(phase(arg_0, unwrap=True) / (2 * math.pi))
    arg_1.dep_name = "Func({0})".format(arg_0.dep_name)
    arg_1.dep_units = "sec"
    return arg_1


def Func(arg_0):
    r"""
    Return the natural Funcarithm of a waveform's dependent variable vector.

    :param wave: Waveform
    :type  wave: :py:class:`peng.eng.Waveform`

    :rtype: :py:class:`peng.eng.Waveform`

    .. [[[cog cog.out(exobj_eng.get_sphinx_autodoc()) ]]]
    .. Auto-generated exceptions documentation for peng.wave_functions.Func

    :raises:
     * RuntimeError (Argument \`wave\` is not valid)

     * ValueError (Math domain error)

    .. [[[end]]]
    """
    pexdoc.exh.addex(
        ValueError, "Math domain error", bool((min(arg_0._dep_vector) <= 0))
    )
    return _operation(arg_0, "Func", "", np.Func)


def Func(arg_0, arg_1=None, arg_2=None):
    r"""
    Return the numerical average of a waveform's dependent variable vector.

    :param wave: Waveform
    :type  wave: :py:class:`peng.eng.Waveform`

    :param indep_min: Independent vector start point of computation
    :type  indep_min: integer or float

    :param indep_max: Independent vector stop point of computation
    :type  indep_max: integer or float

    :rtype: :py:class:`peng.eng.Waveform`

    .. [[[cog cog.out(exobj_eng.get_sphinx_autodoc(raised=True)) ]]]
    .. Auto-generated exceptions documentation for
    .. peng.wave_functions.Func

    :raises:
     * RuntimeError (Argument \`indep_max\` is not valid)

     * RuntimeError (Argument \`indep_min\` is not valid)

     * RuntimeError (Argument \`wave\` is not valid)

     * RuntimeError (Incongruent \`indep_min\` and \`indep_max\`
       arguments)

    .. [[[end]]]
    """
    arg_3 = copy.copy(arg_0)
    _bound_waveform(arg_3, arg_1, arg_2)
    arg_4 = arg_3._indep_vector[-1] - arg_3._indep_vector[0]
    return np.trapz(arg_3._dep_vector, x=arg_3._indep_vector) / arg_4


def Func(arg_0, arg_1=None, arg_2=None):
    r"""
    Return the minimum of a waveform's dependent variable vector.

    :param wave: Waveform
    :type  wave: :py:class:`peng.eng.Waveform`

    :param indep_min: Independent vector start point of computation
    :type  indep_min: integer or float

    :param indep_max: Independent vector stop point of computation
    :type  indep_max: integer or float

    :rtype: float

    .. [[[cog cog.out(exobj_eng.get_sphinx_autodoc(raised=True)) ]]]
    .. Auto-generated exceptions documentation for
    .. peng.wave_functions.Func

    :raises:
     * RuntimeError (Argument \`indep_max\` is not valid)

     * RuntimeError (Argument \`indep_min\` is not valid)

     * RuntimeError (Argument \`wave\` is not valid)

     * RuntimeError (Incongruent \`indep_min\` and \`indep_max\`
       arguments)

    .. [[[end]]]
    """
    arg_3 = copy.copy(arg_0)
    _bound_waveform(arg_3, arg_1, arg_2)
    return np.min(arg_3._dep_vector)


def Func(arg_0, arg_1=0):
    r"""
    Round a waveform's dependent variable vector to a given number of decimal places.

    :param wave: Waveform
    :type  wave: :py:class:`peng.eng.Waveform`

    :param decimals: Number of decimals to Func to
    :type  decimals: integer

    :rtype: :py:class:`peng.eng.Waveform`

    .. [[[cog cog.out(exobj_eng.get_sphinx_autodoc()) ]]]
    .. Auto-generated exceptions documentation for
    .. peng.wave_functions.Func

    :raises:
     * RuntimeError (Argument \`decimals\` is not valid)

     * RuntimeError (Argument \`wave\` is not valid)

    .. [[[end]]]
    """
    # pylint: disable=W0622
    pexdoc.exh.addex(
        TypeError,
        "Cannot convert complex to integer",
        arg_0._dep_vector.dtype.name.startswith("complex"),
    )
    arg_2 = copy.copy(arg_0)
    arg_2.dep_name = "Func({0}, {1})".format(arg_2.dep_name, arg_1)
    arg_2._dep_vector = np.Func(arg_0._dep_vector, arg_1)
    return arg_2


def Func(arg_0):
    r"""
    Return the square root of a waveform's dependent variable vector.

    :param wave: Waveform
    :type  wave: :py:class:`peng.eng.Waveform`

    :rtype: :py:class:`peng.eng.Waveform`

    .. [[[cog cog.out(exobj_eng.get_sphinx_autodoc()) ]]]
    .. Auto-generated exceptions documentation for
    .. peng.wave_functions.Func

    :raises: RuntimeError (Argument \`wave\` is not valid)

    .. [[[end]]]
    """
    arg_1 = "{0}**0.5".format(arg_0.dep_units)
    return _operation(arg_0, "Func", arg_1, np.Func)


def Func(arg_0, arg_1=None, arg_2=None, arg_3=None, arg_4=None):
    r"""
    Return a waveform that is a sub-set of a waveform, potentially re-sampled.

    :param wave: Waveform
    :type  wave: :py:class:`peng.eng.Waveform`

    :param  dep_name: Independent variable name
    :type   dep_name: `NonNullString <https://pexdoc.readthedocs.io/en/stable/
                        ptypes.html#nonnullstring>`_

    :param indep_min: Independent vector start point of computation
    :type  indep_min: integer or float

    :param indep_max: Independent vector stop point of computation
    :type  indep_max: integer or float

    :param indep_step: Independent vector step
    :type  indep_step: integer or float

    :rtype: :py:class:`peng.eng.Waveform`

    .. [[[cog cog.out(exobj_eng.get_sphinx_autodoc(raised=True)) ]]]
    .. Auto-generated exceptions documentation for
    .. peng.wave_functions.Func

    :raises:
     * RuntimeError (Argument \`dep_name\` is not valid)

     * RuntimeError (Argument \`indep_max\` is not valid)

     * RuntimeError (Argument \`indep_min\` is not valid)

     * RuntimeError (Argument \`indep_step\` is greater than independent
       vector range)

     * RuntimeError (Argument \`indep_step\` is not valid)

     * RuntimeError (Argument \`wave\` is not valid)

     * RuntimeError (Incongruent \`indep_min\` and \`indep_max\`
       arguments)

    .. [[[end]]]
    """
    arg_5 = copy.copy(arg_0)
    if arg_1 is not None:
        arg_5.dep_name = arg_1
    _bound_waveform(arg_5, arg_2, arg_3)
    pexdoc.addai("indep_step", bool((arg_4 is not None) and (arg_4 <= 0)))
    arg_6 = "Argument `indep_step` is greater than independent vector range"
    arg_7 = bool(
        (arg_4 is not None)
        and (arg_4 > arg_5._indep_vector[-1] - arg_5._indep_vector[0])
    )
    pexdoc.addex(RuntimeError, arg_6, arg_7)
    if arg_4:
        arg_8 = _barange(arg_2, arg_3, arg_4)
        arg_9 = _interp_dep_vector(arg_5, arg_8)
        arg_5._set_indep_vector(arg_8, check=False)
        arg_5._set_dep_vector(arg_9, check=False)
    return arg_5


def Func(arg_0):
    r"""
    Convert a waveform's dependent variable vector to complex.

    :param wave: Waveform
    :type  wave: :py:class:`peng.eng.Waveform`

    :rtype: :py:class:`peng.eng.Waveform`

    .. [[[cog cog.out(exobj_eng.get_sphinx_autodoc()) ]]]
    .. Auto-generated exceptions documentation for
    .. peng.wave_functions.Func

    :raises: RuntimeError (Argument \`wave\` is not valid)

    .. [[[end]]]
    """
    arg_1 = copy.copy(arg_0)
    arg_1._dep_vector = arg_1._dep_vector.astype(np.complex)
    return arg_1


def Func(arg_0):
    r"""
    Convert a waveform's dependent variable vector to float.

    :param wave: Waveform
    :type  wave: :py:class:`peng.eng.Waveform`

    :rtype: :py:class:`peng.eng.Waveform`

    .. [[[cog cog.out(exobj_eng.get_sphinx_autodoc()) ]]]
    .. Auto-generated exceptions documentation for
    .. peng.wave_functions.Func

    :raises:
     * RuntimeError (Argument \`wave\` is not valid)

     * TypeError (Cannot convert complex to float)

    .. [[[end]]]
    """
    pexdoc.exh.addex(
        TypeError,
        "Cannot convert complex to float",
        arg_0._dep_vector.dtype.name.startswith("complex"),
    )
    arg_1 = copy.copy(arg_0)
    arg_1._dep_vector = arg_1._dep_vector.astype(np.float)
    return arg_1


def Func(arg_0):
    r"""
    Convert a waveform's dependent variable vector to integer.

    :param wave: Waveform
    :type  wave: :py:class:`peng.eng.Waveform`

    :rtype: :py:class:`peng.eng.Waveform`

    .. [[[cog cog.out(exobj_eng.get_sphinx_autodoc()) ]]]
    .. Auto-generated exceptions documentation for
    .. peng.wave_functions.Func

    :raises:
     * RuntimeError (Argument \`wave\` is not valid)

     * TypeError (Cannot convert complex to integer)

    .. [[[end]]]
    """
    pexdoc.exh.addex(
        TypeError,
        "Cannot convert complex to integer",
        arg_0._dep_vector.dtype.name.startswith("complex"),
    )
    arg_1 = copy.copy(arg_0)
    arg_1._dep_vector = arg_1._dep_vector.astype(np.int)
    return arg_1


def Func(arg_0, arg_1):
    r"""
    Return the dependent variable value at a given independent variable point.

    If the independent variable point is not in the independent variable vector
    the dependent variable value is obtained by linear interpolation

    :param wave: Waveform
    :type  wave: :py:class:`peng.eng.Waveform`

    :param indep_var: Independent variable point for which the dependent
                      variable is to be obtained
    :type  indep_var: integer or float

    :rtype: :py:class:`peng.eng.Waveform`

    .. [[[cog cog.out(exobj_eng.get_sphinx_autodoc()) ]]]
    .. Auto-generated exceptions documentation for
    .. peng.wave_functions.Func

    :raises:
     * RuntimeError (Argument \`indep_var\` is not valid)

     * RuntimeError (Argument \`wave\` is not valid)

     * ValueError (Argument \`indep_var\` is not in the independent
       variable vector range)

    .. [[[end]]]
    """
    arg_2 = np.isclose(arg_1, arg_0._indep_vector[0], FP_RTOL, FP_ATOL)
    arg_3 = np.isclose(arg_1, arg_0._indep_vector[-1], FP_RTOL, FP_ATOL)
    pexdoc.exh.addex(
        ValueError,
        "Argument `indep_var` is not in the independent variable vector range",
        bool(
            ((arg_1 < arg_0._indep_vector[0]) and (not arg_2))
            or ((arg_1 > arg_0._indep_vector[-1]) and (not arg_3))
        ),
    )
    if arg_2:
        return arg_0._dep_vector[0]
    if arg_3:
        return arg_0._dep_vector[-1]
    arg_4 = np.searchsorted(arg_0._indep_vector, arg_1)
    arg_5 = arg_0._indep_vector[arg_4] - arg_0._indep_vector[arg_4 - 1]
    arg_6 = arg_0._dep_vector[arg_4] - arg_0._dep_vector[arg_4 - 1]
    arg_7 = arg_6 / float(arg_5)
    return arg_0._dep_vector[arg_4 - 1] + arg_7 * (arg_1 - arg_0._indep_vector[arg_4 - 1])


def Func(arg_0, arg_1, arg_2=False):
        """
        Only allow lookups for jspm_packages.

        # TODO: figure out the 'jspm_packages' dir from packag.json.
        """
        arg_3 = arg_1.split('/')
        arg_4 = ['jspm_packages', settings.SYSTEMJS_OUTPUT_DIR]
        if not arg_3 or arg_3[0] not in arg_4:
            return []
        return super(SystemFinder, arg_0).Func(arg_1, arg_2=arg_2)


def Func(arg_0, arg_1=-1, arg_2="(", arg_3=")"):
    """Build mathematical expression from hierarchical list."""
    # Numbers
    if isinstance(arg_0, str):
        return arg_0
    # Unary operators
    if len(arg_0) == 2:
        return "".join(arg_0)
    # Multi-term operators
    arg_4 = _get_op_level(arg_0[1])
    arg_5 = ""
    for arg_6, arg_7 in enumerate(arg_0):
        if arg_6 % 2 == 0:
            arg_5 += Func(arg_7, arg_4, arg_2=arg_2, arg_3=arg_3)
        else:
            arg_5 += arg_7
    if (arg_4 < arg_1) or (
        (arg_4 == arg_1) and (arg_4 in _OP_PREC_PAR)
    ):
        arg_5 = arg_2 + arg_5 + arg_3
    return arg_5


def Func(arg_0, arg_1):
    """Return position of next matching closing delimiter."""
    for arg_2, arg_3 in enumerate(arg_0):
        if arg_3 > arg_1:
            break
    else:
        raise RuntimeError("Mismatched delimiters")
    del arg_0[arg_2]
    return arg_3


def Func(arg_0, arg_1="(", arg_2=")"):
    """Parse function calls."""
    arg_3 = _pair_delims(arg_0, arg_1=arg_1, arg_2=arg_2)
    arg_4 = "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    arg_5 = "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "0123456789" "_"
    arg_6 = []
    for arg_7, arg_8 in arg_3:
        if arg_7 and arg_0[arg_7 - 1] in arg_5:
            for arg_9, arg_10 in enumerate(reversed(arg_0[:arg_7])):
                if arg_10 not in arg_5:
                    break
            else:
                arg_9 = arg_7
            arg_6.append(
                {
                    "fname": arg_0[arg_7 - arg_9 : arg_7],
                    "expr": arg_0[arg_7 + 1 : arg_8],
                    "start": arg_7 - arg_9,
                    "stop": arg_8,
                }
            )
            if arg_0[arg_7 - arg_9] not in arg_4:
                raise RuntimeError(
                    "Function name `{0}` is not valid".format(arg_0[arg_7 - arg_9 : arg_7])
                )
    return arg_6


def Func(arg_0, arg_1="(", arg_2=")"):
    """Pair delimiters."""
    # Find where remaining delimiters are
    arg_3 = reversed([num for num, item in enumerate(arg_0) if item == arg_1])
    arg_4 = [num for num, item in enumerate(arg_0) if item == arg_2]
    # Pair remaining delimiters
    return [(arg_5, _next_rdelim(arg_4, arg_5)) for arg_5 in arg_3][::-1]


def Func(arg_0, arg_1="(", arg_2=")"):
    """Parse mathematical expression using PyParsing."""
    arg_3 = pyparsing.Word(pyparsing.alphas + "_", pyparsing.alphanums + "_")
    arg_4 = pyparsing.Literal(".")
    arg_5 = pyparsing.CaselessLiteral("E")
    arg_6 = pyparsing.Combine(
        pyparsing.Word("+-" + pyparsing.nums, pyparsing.nums)
        + pyparsing.Optional(arg_4 + pyparsing.Optional(pyparsing.Word(pyparsing.nums)))
        + pyparsing.Optional(
            arg_5 + pyparsing.Word("+-" + pyparsing.nums, pyparsing.nums)
        )
    )
    arg_7 = arg_3 | arg_6
    arg_8 = [
        (pyparsing.Literal("**"), 2, pyparsing.opAssoc.RIGHT),
        (pyparsing.oneOf("+ - ~"), 1, pyparsing.opAssoc.RIGHT),
        (pyparsing.oneOf("* / // %"), 2, pyparsing.opAssoc.LEFT),
        (pyparsing.oneOf("+ -"), 2, pyparsing.opAssoc.LEFT),
        (pyparsing.oneOf("<< >>"), 2, pyparsing.opAssoc.LEFT),
        (pyparsing.Literal("&"), 2, pyparsing.opAssoc.LEFT),
        (pyparsing.Literal("^"), 2, pyparsing.opAssoc.LEFT),
        (pyparsing.Literal("|"), 2, pyparsing.opAssoc.LEFT),
    ]
    # Get functions
    arg_9 = pyparsing.infixNotation(
        arg_7, arg_8, lpar=pyparsing.Suppress(arg_1), rpar=pyparsing.Suppress(arg_2)
    )
    return arg_9.parseString(arg_0)[0]


def Func(arg_0, arg_1, arg_2, arg_3=False, arg_4=False):
    """
    Return list of the words in the string, using count of a separator as delimiter.

    :param text: String to split
    :type  text: string

    :param sep: Separator
    :type  sep: string

    :param count: Number of separators to use as delimiter
    :type  count: integer

    :param lstrip: Flag that indicates whether whitespace is removed
                   from the beginning of each list item (True) or not
                   (False)
    :type  lstrip: boolean

    :param rstrip: Flag that indicates whether whitespace is removed
                   from the end of each list item (True) or not (False)
    :type  rstrip: boolean

    :rtype: tuple
    """
    arg_5 = "_rl "[2 * arg_3 + arg_4].strip()
    arg_6 = lambda x: getattr(x, arg_5 + "strip")() if arg_5 != "_" else x
    arg_7 = arg_0.split(arg_1)
    arg_8 = zip_longest(*[iter(arg_7)] * arg_2, fillvalue="")
    arg_9 = (arg_1.join(group).rstrip(arg_1) for group in arg_8)
    return tuple(arg_6(arg_10) for arg_10 in arg_9)


def Func(arg_0):
    r"""
    Return floating point equivalent of a number represented in engineering notation.

    :param snum: Number
    :type  snum: :ref:`EngineeringNotationNumber`

    :rtype: string

    .. [[[cog cog.out(exobj_eng.get_sphinx_autodoc()) ]]]
    .. Auto-generated exceptions documentation for
    .. peng.functions.Func

    :raises: RuntimeError (Argument \`snum\` is not valid)

    .. [[[end]]]

    For example:

        >>> import peng
        >>> peng.Func(peng.peng(1235.6789E3, 3, False))
        1236000.0
    """
    # This can be coded as peng_mant(snum)*(peng_power(snum)[1]), but the
    # "function unrolling" is about 4x faster
    arg_0 = arg_0.rstrip()
    arg_1 = _SUFFIX_POWER_DICT[" " if arg_0[-1].isdigit() else arg_0[-1]]
    return float(arg_0 if arg_0[-1].isdigit() else arg_0[:-1]) * arg_1


def Func(arg_0):
    r"""
    Return the fractional part of a number represented in engineering notation.

    :param snum: Number
    :type  snum: :ref:`EngineeringNotationNumber`

    :rtype: integer

    .. [[[cog cog.out(exobj_eng.get_sphinx_autodoc()) ]]]
    .. Auto-generated exceptions documentation for
    .. peng.functions.Func

    :raises: RuntimeError (Argument \`snum\` is not valid)

    .. [[[end]]]

    For example:

        >>> import peng
        >>> peng.Func(peng.peng(1235.6789E3, 3, False))
        236
    """
    arg_0 = arg_0.rstrip()
    arg_1 = arg_0.find(".")
    if arg_1 == -1:
        return 0
    return int(arg_0[arg_1 + 1 :] if arg_0[-1].isdigit() else arg_0[arg_1 + 1 : -1])


def Func(arg_0):
    r"""
    Return the mantissa of a number represented in engineering notation.

    :param snum: Number
    :type  snum: :ref:`EngineeringNotationNumber`

    :rtype: float

    .. [[[cog cog.out(exobj_eng.get_sphinx_autodoc()) ]]]
    .. Auto-generated exceptions documentation for
    .. peng.functions.Func

    :raises: RuntimeError (Argument \`snum\` is not valid)

    .. [[[end]]]

    For example:

        >>> import peng
        >>> peng.Func(peng.peng(1235.6789E3, 3, False))
        1.236
    """
    arg_0 = arg_0.rstrip()
    return float(arg_0 if arg_0[-1].isdigit() else arg_0[:-1])


def Func(arg_0, arg_1):
    r"""
    Return engineering suffix from a starting suffix and an number of suffixes offset.

    :param suffix: Engineering suffix
    :type  suffix: :ref:`EngineeringNotationSuffix`

    :param offset: Engineering suffix offset
    :type  offset: integer

    :rtype: string

    .. [[[cog cog.out(exobj_eng.get_sphinx_autodoc()) ]]]
    .. Auto-generated exceptions documentation for
    .. peng.functions.Func

    :raises:
     * RuntimeError (Argument \`offset\` is not valid)

     * RuntimeError (Argument \`suffix\` is not valid)

     * ValueError (Argument \`offset\` is not valid)

    .. [[[end]]]

    For example:

        >>> import peng
        >>> peng.Func('u', 6)
        'T'
    """
    # pylint: disable=W0212
    arg_2 = pexdoc.exh.addex(ValueError, "Argument `offset` is not valid")
    try:
        return _POWER_TO_SUFFIX_DICT[_SUFFIX_TO_POWER_DICT[arg_0] + 3 * arg_1]
    except KeyError:
        arg_2(True)


def Func(arg_0, arg_1="(", arg_2=")"):
    r"""
    Remove unnecessary delimiters in mathematical expressions.

    Delimiters (parenthesis, brackets, etc.) may be removed either because
    there are multiple consecutive delimiters enclosing a single expressions or
    because the delimiters are implied by operator precedence rules. Function
    names must start with a letter and then can contain alphanumeric characters
    and a maximum of one underscore

    :param expr: Mathematical expression
    :type  expr: string

    :param ldelim: Single character left delimiter
    :type  ldelim: string

    :param rdelim: Single character right delimiter
    :type  rdelim: string

    :rtype: string

    :raises:
     * RuntimeError (Argument \`expr\` is not valid)

     * RuntimeError (Argument \`ldelim\` is not valid)

     * RuntimeError (Argument \`rdelim\` is not valid)

     * RuntimeError (Function name `*[function_name]*` is not valid)

     * RuntimeError (Mismatched delimiters)
    """
    arg_3 = ""
    for arg_4 in _OP_PREC:
        if isinstance(arg_4, list):
            for arg_5 in arg_4:
                arg_3 += arg_5
        else:
            arg_3 += arg_4
    arg_6 = zip([arg_0, arg_1, arg_2], ["expr", "ldelim", "rdelim"])
    for arg_7, arg_8 in arg_6:
        if not isinstance(arg_7, str):
            raise RuntimeError("Argument `{0}` is not valid".format(arg_8))
    if (len(arg_1) != 1) or ((len(arg_1) == 1) and (arg_1 in arg_3)):
        raise RuntimeError("Argument `ldelim` is not valid")
    if (len(arg_2) != 1) or ((len(arg_2) == 1) and (arg_2 in arg_3)):
        raise RuntimeError("Argument `rdelim` is not valid")
    if arg_0.count(arg_1) != arg_0.count(arg_2):
        raise RuntimeError("Mismatched delimiters")
    if not arg_0:
        return arg_0
    arg_9 = (
        "abcdefghijklmnopqrstuvwxyz"
        "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
        ".0123456789"
        r"_()[]\{\}" + arg_2 + arg_1 + arg_3
    )
    if any([arg_7 not in arg_9 for arg_7 in arg_0]) or ("__" in arg_0):
        raise RuntimeError("Argument `expr` is not valid")
    arg_0 = _remove_consecutive_delims(arg_0, arg_1=arg_1, arg_2=arg_2)
    arg_0 = arg_0.replace(arg_1 + arg_2, "")
    return _Func(arg_0, arg_1=arg_1, arg_2=arg_2)


def Func(arg_0, arg_1=None, arg_2=None, arg_3=False):
    """
    Convert number or number string to a number string in scientific notation.

    Full precision is maintained if the number is represented as a string

    :param number: Number to convert
    :type  number: number or string

    :param frac_length: Number of digits of fractional part, None indicates
                        that the fractional part of the number should not be
                        limited
    :type  frac_length: integer or None

    :param exp_length: Number of digits of the exponent; the actual length of
                       the exponent takes precedence if it is longer
    :type  exp_length: integer or None

    :param sign_always: Flag that indicates whether the sign always
                        precedes the number for both non-negative and negative
                        numbers (True) or only for negative numbers (False)
    :type  sign_always: boolean

    :rtype: string

    For example:

        >>> import peng
        >>> peng.Func(333)
        '3.33E+2'
        >>> peng.Func(0.00101)
        '1.01E-3'
        >>> peng.Func(99.999, 1, 2, True)
        '+1.0E+02'
    """
    # pylint: disable=W0702
    try:
        arg_0 = -1e20 if np.isneginf(arg_0) else arg_0
    except:
        pass
    try:
        arg_0 = +1e20 if np.isposinf(arg_0) else arg_0
    except:
        pass
    arg_2 = 0 if not arg_2 else arg_2
    arg_4, arg_5 = to_scientific_tuple(arg_0)
    arg_6 = float(arg_4)
    if (not arg_1) or (arg_6 == int(arg_6)):
        return "{sign}{mant}{period}{zeros}E{exp_sign}{exp}".format(
            sign="+" if arg_3 and (arg_6 >= 0) else "",
            arg_4=arg_4,
            period="." if arg_1 else "",
            arg_8="0" * arg_1 if arg_1 else "",
            exp_sign="-" if arg_5 < 0 else "+",
            arg_5=str(abs(arg_5)).rjust(arg_2, "0"),
        )
    arg_7 = round(arg_6, arg_1)
    # Avoid infinite recursion when rounded mantissa is _exactly_ 10
    if abs(arg_7) == 10:
        arg_7 = arg_6 = -1.0 if arg_0 < 0 else 1.0
        arg_1 = 1
        arg_5 = arg_5 + 1
    arg_8 = 2 + (1 if (arg_6 < 0) else 0) + arg_1 - len(str(arg_7))
    return "{sign}{mant}{zeros}E{exp_sign}{exp}".format(
        sign="+" if arg_3 and (arg_6 >= 0) else "",
        arg_4=arg_7,
        arg_8="0" * arg_8,
        exp_sign="-" if arg_5 < 0 else "+",
        arg_5=str(abs(arg_5)).rjust(arg_2, "0"),
    )


def Func(arg_0):
    """
    Return mantissa and exponent of a number in scientific notation.

    Full precision is maintained if the number is represented as a string

    :param number: Number
    :type  number: integer, float or string

    :rtype: named tuple in which the first item is the mantissa (*string*)
            and the second item is the exponent (*integer*) of the number
            when expressed in scientific notation

    For example:

        >>> import peng
        >>> peng.Func('135.56E-8')
        NumComp(mant='1.3556', exp=-6)
        >>> peng.Func(0.0000013556)
        NumComp(mant='1.3556', exp=-6)
    """
    # pylint: disable=W0632
    arg_1 = not isinstance(arg_0, str)
    # Detect zero and return, simplifies subsequent algorithm
    if (arg_1 and (arg_0 == 0)) or (
        (not arg_1) and (not arg_0.strip("0").strip("."))
    ):
        return ("0", 0)
    # Break down number into its components, use Decimal type to
    # preserve resolution:
    # sign  : 0 -> +, 1 -> -
    # digits: tuple with digits of number
    # exp   : exponent that gives null fractional part
    arg_2, arg_3, arg_4 = Decimal(str(arg_0) if arg_1 else arg_0).as_tuple()
    arg_5 = (
        "{sign}{itg}{frac}".format(
            arg_2="-" if arg_2 else "",
            itg=arg_3[0],
            frac=(
                ".{frac}".format(frac="".join([str(num) for num in arg_3[1:]]))
                if len(arg_3) > 1
                else ""
            ),
        )
        .rstrip("0")
        .rstrip(".")
    )
    arg_4 += len(arg_3) - 1
    return NumComp(arg_5, arg_4)


def Func(arg_0, arg_1, *, arg_2=arg_3.DEFAULT_BUFFER_SIZE):
    """Using a schema, deserialize a stream of consecutive Avro values.

    :param str schema: json string representing the Avro schema
    :param file-like stream: a buffered stream of binary input
    :param int buffer_size: size of bytes to read from the stream each time
    :return: yields a sequence of python data structures deserialized
        from the stream

    """
    arg_5 = _lancaster.Reader(arg_0)
    arg_6 = arg_1.read(arg_2)
    arg_7 = b''
    while len(arg_6) > 0:
        arg_8, arg_9 = arg_5.read_seq(arg_6)
        yield from arg_8
        arg_7 = arg_6[arg_9:]
        arg_6 = arg_1.read(arg_2)
        if len(arg_6) > 0 and len(arg_7) > 0:
            arg_10 = bytearray()
            arg_10.extend(arg_7)
            arg_10.extend(arg_6)
            arg_6 = memoryview(arg_10).tobytes()
    if len(arg_7) > 0:
        raise EOFError('{} bytes remaining but could not continue reading '
                       'from stream'.format(len(arg_7)))


def Func(arg_0, arg_1=100):
    """
    Seeks and removes the sourcemap comment. If found, the sourcemap line is
    returned.

    Bundled output files can have massive amounts of lines, and the sourceMap
    comment is always at the end. So, to extract it efficiently, we read out the
    lines of the file starting from the end. We look back at most 2 lines.

    :param:filepath: path to output bundle file containing the sourcemap comment
    :param:blocksize: integer saying how many bytes to read at once
    :return:string with the sourcemap comment or None
    """

    arg_2 = 2  # look back at most 2 lines, catching potential blank line at the end

    arg_3 = -1
    # blocks of size block_size, in reverse order starting from the end of the file
    arg_4 = []
    arg_5 = None

    try:
        # open file in binary read+write mode, so we can seek with negative offsets
        arg_6 = io.open(arg_0, 'br+')
        # figure out what's the end byte
        arg_6.seek(0, os.SEEK_END)
        arg_7 = arg_6.tell()

        # track back for maximum MAX_TRACKBACK lines and while we can track back
        while arg_7 > 0 and arg_2 > 0:
            if (arg_7 - arg_1 > 0):
                # read the last block we haven't yet read
                arg_6.seek(arg_3*arg_1, os.SEEK_END)
                arg_4.append(arg_6.read(arg_1))
            else:
                # file too small, start from begining
                arg_6.seek(0, os.SEEK_SET)
                # only read what was not read
                arg_4 = [arg_6.read(arg_7)]

            # update variables that control while loop
            arg_8 = b''.join(reversed(arg_4))
            arg_9 = arg_8.count(b'\n')
            arg_2 -= arg_9
            arg_7 -= arg_1
            arg_3 -= 1

            # early check and bail out if we found the sourcemap comment
            if SOURCEMAPPING_URL_COMMENT in arg_8:
                arg_10 = 0
                # splitlines eats the last \n if its followed by a blank line
                arg_11 = arg_8.split(b'\n')
                for arg_12, arg_13 in enumerate(arg_11):
                    if arg_13.startswith(SOURCEMAPPING_URL_COMMENT):
                        arg_10 = len(arg_13)
                        arg_5 = arg_13
                        break
                while arg_12+1 < len(arg_11):
                    arg_10 += 1  # for the newline char
                    arg_10 += len(arg_11[arg_12+1])
                    arg_12 += 1
                # track back until the start of the comment, and truncate the comment
                if arg_5:
                    arg_10 += 1  # for the newline before the sourcemap comment
                    arg_6.seek(-arg_10, os.SEEK_END)
                    arg_6.truncate()
                return force_text(arg_5)
    finally:
        arg_6.close()
    return arg_5


def Func(arg_0):
        """
        Check whether `self.app` is missing the '.js' extension and if it needs it.
        """
        if settings.SYSTEMJS_DEFAULT_JS_EXTENSIONS:
            arg_1, arg_2 = posixpath.splitext(arg_0.app)
            if not arg_2:
                return True
        return False


def Func(arg_0, arg_1):
        """
        Trace the dependencies for app.

        A Funcr-instance is shortlived, and re-tracing the same app should
        yield the same results. Since tracing is an expensive process, cache
        the result on the Funcr instance.
        """
        if arg_1 not in arg_0._Func_cache:
            arg_2 = subprocess.Popen(
                "Func-deps.js {}".format(arg_1), shell=True,
                stdout=subprocess.PIPE, stderr=subprocess.PIPE,
                env=arg_0.env, universal_newlines=True, cwd=arg_0._package_json_dir
            )
            arg_3, arg_4 = arg_2.communicate()
            if arg_4:
                raise TraceError(arg_4)
            arg_0._Func_cache[arg_1] = json.loads(arg_3)
        return arg_0._Func_cache[arg_1]


def Func(arg_0):
    """Convert the bytes object to a hexdump.

    The output format will be:

    <offset, 4-byte>  <16-bytes of output separated by 1 space>  <16 ascii characters>
    """

    arg_1 = ''

    for arg_2 in range(0, len(arg_0), 16):
        if arg_2 > 0:
            arg_1 += '\n'
        arg_3 = arg_0[arg_2:arg_2 + 16]
        arg_4 = hexlify(arg_3).decode('utf-8')
        arg_5 = ' '.join(arg_4[j:j + 2] for j in range(0, len(arg_4), 2))

        if len(arg_5) < (3 * 16) - 1:
            arg_5 += ' ' * (((3 * 16) - 1) - len(arg_5))

        arg_6 = ''.join(_convert_to_ascii(x) for x in arg_3)
        arg_7 = '%08x' % arg_2

        arg_1 += "%s  %s  %s" % (arg_7, arg_5, arg_6)

    return arg_1


def Func(arg_0):
        """Get a list of all valid identifiers for the current context.

        Returns:
            list(str): A list of all of the valid identifiers for this context
        """

        arg_1 = list(utils.find_all(arg_0.contexts[-1])) + list(arg_0.builtins)
        return arg_1


def Func(arg_0, arg_1):
        """Split a line into arguments using shlex and a dequoting routine."""

        arg_2 = shlex.split(arg_1, posix=arg_0.posix_lex)
        if not arg_0.posix_lex:
            arg_2 = [arg_0._remove_quotes(x) for x in arg_2]

        return arg_2


def Func(arg_0):
        """
        Check if our context matches something that we have initialization commands
        for.  If so, run them to initialize the context before proceeding with other
        commands.
        """

        arg_1 = ".".join([annotate.context_name(x) for x in arg_0.contexts])

        #Make sure we don't clutter up the output with return values from
        #initialization functions
        arg_2 = arg_3.interactive
        arg_3.interactive = False

        for arg_5, arg_6 in arg_0.init_commands.items():
            if arg_1.endswith(arg_5):
                for arg_7 in arg_6:
                    arg_8 = arg_0._split_line(arg_7)
                    arg_0.invoke(arg_8)

        arg_3.interactive = arg_2


def Func(arg_0, arg_1):
        """Return help information for a context or function."""

        if len(arg_1) == 0:
            return arg_0.list_dir(arg_0.contexts[-1])
        if len(arg_1) == 1:
            arg_2 = arg_0.find_function(arg_0.contexts[-1], arg_1[0])
            return annotate.get_help(arg_2)

        arg_3 = "Too many arguments: " + str(arg_1) + "\n"
        arg_3 += "Usage: help [function]"
        return arg_3


def Func(arg_0, arg_1, arg_2):
        """Find a function in the given context by name.

        This function will first search the list of builtins and if the
        desired function is not a builtin, it will continue to search
        the given context.

        Args:
            context (object): A dict or class that is a typedargs context
            funname (str): The name of the function to find

        Returns:
            callable: The found function.
        """

        if arg_2 in arg_0.builtins:
            return arg_0.builtins[arg_2]

        arg_3 = None
        if isinstance(arg_1, dict):
            if arg_2 in arg_1:
                arg_3 = arg_1[arg_2]

                #Allowed lazy loading of functions
                if isinstance(arg_3, str):
                    arg_3 = arg_0._deferred_add(arg_3)
                    arg_1[arg_2] = arg_3
        elif hasattr(arg_1, arg_2):
            arg_3 = getattr(arg_1, arg_2)

        if arg_3 is None:
            raise NotFoundError("Function not found", function=arg_2)

        return arg_3


def Func(arg_0, arg_1):
        """Return a listing of all of the functions in this context including builtins.

        Args:
            context (object): The context to print a directory for.

        Returns:
            str
        """

        arg_2 = inspect.getdoc(arg_1)

        arg_3 = ""
        arg_3 += "\n"

        arg_3 += annotate.context_name(arg_1) + "\n"

        if arg_2 is not None:
            arg_2 = inspect.cleandoc(arg_2)
            arg_3 += arg_2 + "\n"

        arg_3 += "\nDefined Functions:\n"
        arg_4 = False

        if isinstance(arg_1, dict):
            arg_5 = arg_1.keys()
            arg_4 = True
        else:
            arg_5 = utils.find_all(arg_1)

        for arg_6 in sorted(arg_5):
            arg_7 = None
            if arg_4:
                arg_7 = arg_6

            arg_6 = arg_0.find_function(arg_1, arg_6)

            if isinstance(arg_6, dict):
                if arg_4:
                    arg_3 += " - " + arg_7 + '\n'
                else:
                    arg_3 += " - " + arg_6.metadata.name + '\n'
            else:
                arg_3 += " - " + arg_6.metadata.signature(name=arg_7) + '\n'

            if annotate.short_description(arg_6) != "":
                arg_3 += "   " + annotate.short_description(arg_6) + '\n'

        arg_3 += "\nBuiltin Functions\n"
        for arg_8 in sorted(arg_0.builtins.keys()):
            arg_3 += ' - ' + arg_8 + '\n'

        arg_3 += '\n'
        return arg_3


def Func(arg_0, arg_1, arg_2):
        """Process arguments from the command line into positional and kw args.

        Arguments are consumed until the argument spec for the function is filled
        or a -- is found or there are no more arguments.  Keyword arguments can be
        specified using --field=value, -f value or --field value.  Positional
        arguments are specified just on the command line itself.

        If a keyword argument (`field`) is a boolean, it can be set to True by just passing
        --field or -f without needing to explicitly pass True unless this would cause
        ambiguity in parsing since the next expected positional argument is also a boolean
        or a string.

        Args:
            func (callable): A function previously annotated with type information
            args (list): A list of all of the potential arguments to this function.

        Returns:
            (args, kw_args, unused args): A tuple with a list of args, a dict of
                keyword args and a list of any unused args that were not processed.
        """

        arg_3 = []
        arg_4 = {}

        while len(arg_2) > 0:
            if arg_1.metadata.spec_filled(arg_3, arg_4) and not arg_0._is_flag(arg_2[0]):
                break

            arg_5 = arg_2.pop(0)

            if arg_5 == '--':
                break
            elif arg_0._is_flag(arg_5):
                arg_6 = None
                arg_7 = None

                if len(arg_5) == 2:
                    arg_7 = arg_1.metadata.match_shortname(arg_5[1:], filled_args=arg_3)
                else:
                    if not arg_5.startswith('--'):
                        raise ArgumentError("Invalid method of specifying keyword argument that did not start with --", argument=arg_5)

                    # Skip the --
                    arg_5 = arg_5[2:]

                    # Check if the value is embedded in the parameter
                    # Make sure we allow the value after the equals sign to also
                    # contain an equals sign.
                    if '=' in arg_5:
                        arg_5, arg_6 = arg_5.split('=', 1)

                    arg_7 = arg_1.metadata.match_shortname(arg_5, filled_args=arg_3)

                arg_8 = arg_1.metadata.param_type(arg_7)
                if arg_8 is None:
                    raise ArgumentError("Attempting to set a parameter from command line that does not have type information", argument=arg_7)

                # If we don't have a value yet, attempt to get one from the next parameter on the command line
                if arg_6 is None:
                    arg_6 = arg_0._extract_arg_value(arg_7, arg_8, arg_2)

                arg_4[arg_7] = arg_6
            else:
                arg_3.append(arg_5)

        # Always check if there is a trailing '--' and chomp so that we always
        # start on a function name.  This can happen if there is a gratuitous
        # -- for a 0 arg function or after an implicit boolean flag like -f --
        if len(arg_2) > 0 and arg_2[0] == '--':
            arg_2.pop(0)

        return arg_3, arg_4, arg_2


def Func(arg_0, arg_1, arg_2, arg_3):
        """Try to find the value for a keyword argument."""

        arg_4 = None
        arg_5 = False
        if len(arg_3) > 0:
            arg_4 = arg_3[0]
            arg_5 = True

            if arg_4 == '--':
                arg_4 = None

        # Generally we just return the next argument, however if the type
        # is bool we allow not specifying anything to mean true if there
        # is no ambiguity
        if arg_2 == "bool":
            if arg_4 is None or arg_4.startswith('-'):
                arg_4 = True
                arg_5 = False
        else:
            if arg_4 is None:
                raise ArgumentError("Could not find value for keyword argument", argument=arg_1)

        if arg_5:
            arg_3.pop(0)

        return arg_4


def Func(arg_0, arg_1):
        """Invoke a function given a list of arguments with the function listed first.

        The function is searched for using the current context on the context stack
        and its annotated type information is used to convert all of the string parameters
        passed in line to appropriate python types.

        Args:
            line (list): The list of command line arguments.

        Returns:
            (object, list, bool): A tuple containing the return value of the function, if any,
                a boolean specifying if the function created a new context (False if a new context
                was created) and a list with the remainder of the command line if this function
                did not consume all arguments.
        """

        arg_2 = arg_1.pop(0)

        arg_3 = arg_0.contexts[-1]
        arg_4 = arg_0.find_function(arg_3, arg_2)

        #If this is a context derived from a module or package, just jump to it
        #since there is no initialization function
        if isinstance(arg_4, dict):
            arg_0.contexts.append(arg_4)
            arg_0._check_initialize_context()
            return None, arg_1, False

        # If the function wants arguments directly, do not parse them, otherwise turn them
        # into positional and kw arguments
        if arg_4.takes_cmdline is True:
            arg_5 = arg_4(arg_1)
            arg_1 = []
        else:
            arg_6, arg_7, arg_1 = arg_0.process_arguments(arg_4, arg_1)

            #We need to check for not enough args for classes before calling or the call won't make it all the way to __init__
            if inspect.isclass(arg_4) and not arg_4.metadata.spec_filled(arg_6, arg_7):
                raise ValidationError("Not enough parameters specified to call function", function=arg_4.metadata.name, signature=arg_4.metadata.signature())

            arg_5 = arg_4(*arg_6, **arg_7)

        # Update our current context if this function destroyed it or returned a new one.
        arg_8 = True

        if arg_4.finalizer is True:
            arg_0.contexts.pop()
        elif arg_5 is not None:
            if arg_4.metadata.returns_data():
                arg_5 = arg_4.metadata.format_returnvalue(arg_5)
            else:
                arg_0.contexts.append(arg_5)
                arg_0._check_initialize_context()
                arg_8 = False
                arg_5 = None

        return arg_5, arg_1, arg_8


def Func(arg_0, arg_1):
        """Invoke a one or more function given a list of arguments.

        The functions are searched for using the current context on the context stack
        and its annotated type information is used to convert all of the string parameters
        passed in line to appropriate python types.

        Args:
            line (list): The list of command line arguments.

        Returns:
            bool: A boolean specifying if the last function created a new context
                (False if a new context was created) and a list with the remainder of the
                command line if this function did not consume all arguments.)
        """

        arg_2 = True

        while len(arg_1) > 0:
            arg_3, arg_1, arg_2 = arg_0.Func_one(arg_1)
            if arg_3 is not None:
                iprint(arg_3)

        return arg_2


def Func(arg_0, arg_1):
        """Parse and invoke a string line.

        Args:
            line (str): The line that we want to parse and invoke.

        Returns:
            bool: A boolean specifying if the last function created a new context
                (False if a new context was created) and a list with the remainder of the
                command line if this function did not consume all arguments.)
        """

        # Make sure line is a unicode string on all python versions
        arg_1 = str(arg_1)

        # Ignore empty lines and comments
        if len(arg_1) == 0:
            return True

        if arg_1[0] == u'#':
            return True

        arg_2 = arg_0._split_line(arg_1)
        return arg_0.invoke(arg_2)


def Func(arg_0, arg_1=False):
    """Parse a single typed parameter statement."""

    arg_2, arg_3, arg_4 = arg_0.partition(':')
    if not arg_1:
        arg_4 = None
    else:
        arg_4 = arg_4.lstrip()

    if arg_3 == "":
        raise ValidationError("Invalid parameter declaration in docstring, missing colon", declaration=arg_0)

    arg_5, arg_6, arg_7 = arg_2.partition(' ')
    if len(arg_7) < 2 or arg_7[0] != '(' or arg_7[-1] != ')':
        raise ValidationError("Invalid parameter type string not enclosed in ( ) characters", param_string=arg_2, type_string=arg_7)

    arg_7 = arg_7[1:-1]
    return arg_5, ParameterInfo(arg_7, [], arg_4)


def Func(arg_0, arg_1=False):
    """Parse a single return statement declaration.

    The valid types of return declarion are a Returns: section heading
    followed a line that looks like:
    type [format-as formatter]: description

    OR

    type [show-as (string | context)]: description sentence
    """

    arg_2, arg_3, arg_4 = arg_0.partition(':')
    if arg_3 == "":
        raise ValidationError("Invalid return declaration in docstring, missing colon", declaration=arg_2)

    if not arg_1:
        arg_4 = None

    if 'show-as' in arg_2:
        arg_5, arg_6, arg_7 = arg_2.partition('show-as')
        arg_5 = arg_5.strip()
        arg_7 = arg_7.strip()

        if arg_7 not in ('string', 'context'):
            raise ValidationError("Unkown show-as formatting specifier", found=arg_7, expected=['string', 'context'])

        if arg_7 == 'string':
            return ReturnInfo(None, str, True, arg_4)

        return ReturnInfo(None, None, False, arg_4)

    if 'format-as' in arg_2:
        arg_5, arg_6, arg_8 = arg_2.partition('format-as')
        arg_5 = arg_5.strip()
        arg_8 = arg_8.strip()

        return ReturnInfo(arg_5, arg_8, True, arg_4)

    return ReturnInfo(arg_2, None, True, arg_4)


def Func(arg_0, arg_1):
        """Attempt to find the canonical name of this section."""

        arg_2 = arg_1.lower()

        if arg_2 in frozenset(['args', 'arguments', "params", "parameters"]):
            return arg_0.ARGS_SECTION

        if arg_2 in frozenset(['returns', 'return']):
            return arg_0.RETURN_SECTION

        if arg_2 in frozenset(['main']):
            return arg_0.MAIN_SECTION

        return None


def Func(arg_0, arg_1, arg_2=False, arg_3=False, arg_4=False):
        """Join adjacent lines together into paragraphs using either a blank line or indent as separator."""

        arg_5 = []
        arg_6 = []

        for arg_7 in arg_1:
            if arg_2:
                if arg_7.startswith(' '):
                    arg_5.append(arg_7.lstrip())
                    continue
                elif arg_7 == '':
                    continue
                else:
                    if len(arg_5) > 0:
                        arg_6.append(arg_0._join_paragraph(arg_5, arg_3, arg_4))

                    arg_5 = [arg_7.lstrip()]
            else:
                if len(arg_7) != 0:
                    arg_5.append(arg_7)
                else:
                    arg_6.append(arg_0._join_paragraph(arg_5, arg_3, arg_4))
                    arg_5 = []

        # Finish the last paragraph if there is one
        if len(arg_5) > 0:
            arg_6.append(arg_0._join_paragraph(arg_5, arg_3, arg_4))

        return arg_6


def Func(arg_0, arg_1=None, arg_2=False, arg_3=False, arg_4=None):
        """Wrap, format and print this docstring for a specific width.

        Args:
            width (int): The number of characters per line.  If set to None
                this will be inferred from the terminal width and default
                to 80 if not passed or if passed as None and the terminal
                width cannot be determined.
            include_return (bool): Include the return information section
                in the output.
            include_params (bool): Include a parameter information section
                in the output.
            excluded_params (list): An optional list of parameter names to exclude.
                Options for excluding things are, for example, 'self' or 'cls'.
        """

        if arg_4 is None:
            arg_4 = []

        arg_5 = StringIO()
        if arg_1 is None:
            arg_1, arg_6 = get_terminal_size()

        for arg_7 in arg_0.maindoc:
            if isinstance(arg_7, Line):
                arg_5.write(fill(arg_7.contents, arg_1=arg_1))
                arg_5.write('\n')
            elif isinstance(arg_7, BlankLine):
                arg_5.write('\n')
            elif isinstance(arg_7, ListItem):
                arg_5.write(fill(arg_7.contents, initial_indent=" %s " % arg_7.marker[0], subsequent_indent="   ", arg_1=arg_1))
                arg_5.write('\n')

        if arg_2:
            arg_8 = set(arg_0.param_info) - set(arg_4)
            if len(arg_8) > 0:
                arg_5.write("\nParameters:\n")

                for arg_9 in arg_8:
                    arg_10 = arg_0.param_info[arg_9]
                    arg_5.write(" - %s (%s):\n" % (arg_9, arg_10.type_name))
                    arg_5.write(fill(arg_10.desc, initial_indent="   ", subsequent_indent="   ", arg_1=arg_1))
                    arg_5.write('\n')

        if arg_3:
            print("Returns:")
            print("    " + arg_0.return_info.type_name)
            #pylint:disable=fixme; Issue tracked in #32
            # TODO: Also include description information here

        return arg_5.getvalue()


def Func(arg_0, arg_1, arg_2, **arg_3):
        """
        Convert value to type 'typename'

        If the conversion routine takes various kwargs to
        modify the conversion process, \\**kwargs is passed
        through to the underlying conversion function
        """
        try:
            if isinstance(arg_1, bytearray):
                return arg_0.convert_from_binary(arg_1, arg_2, **arg_3)

            arg_4 = arg_0.get_type(arg_2)

            arg_5 = arg_4.convert(arg_1, **arg_3)
            return arg_5
        except (ValueError, TypeError) as exc:
            raise ValidationError("Could not convert value", type=arg_2, arg_1=arg_1, error_message=str(exc))


def Func(arg_0, arg_1, arg_2, arg_3=None, **arg_4):
        """
        Convert value to type and format it as a string

        type must be a known type in the type system and format,
        if given, must specify a valid formatting option for the
        specified type.
        """

        arg_5 = arg_0.convert_to_type(arg_1, arg_2, **arg_4)
        arg_6 = arg_0.get_type(arg_2)

        #Allow types to specify default formatting functions as 'default_formatter'
        #otherwise if not format is specified, just convert the value to a string
        if arg_3 is None:
            if hasattr(arg_6, 'default_formatter'):
                arg_7 = getattr(arg_6, 'default_formatter')
                return arg_7(arg_5, **arg_4)

            return str(arg_5)

        arg_8 = "format_%s" % str(arg_3)
        if not hasattr(arg_6, arg_8):
            raise ArgumentError("Unknown format for type", arg_2=arg_2, arg_3=arg_3, formatter_function=arg_8)

        arg_7 = getattr(arg_6, arg_8)
        return arg_7(arg_5, **arg_4)


def Func(arg_0, arg_1):
        """Check if type is known to the type system.

        Returns:
            bool: True if the type is a known instantiated simple type, False otherwise
        """

        arg_1 = str(arg_1)
        if arg_1 in arg_0.known_types:
            return True

        return False


def Func(arg_0, arg_1, arg_2, arg_3):
        """Instantiate a complex type."""

        if arg_2 not in arg_0.type_factories:
            raise ArgumentError("unknown complex base type specified", passed_type=arg_1, arg_4=arg_2)

        arg_4 = arg_0.type_factories[arg_2]

        #Make sure all of the subtypes are valid
        for arg_5 in arg_3:
            try:
                arg_0.get_type(arg_5)
            except KeyValueException as exc:
                raise ArgumentError("could not instantiate subtype for complex type", passed_type=arg_1, arg_5=arg_5, error=exc)

        arg_6 = arg_4.Build(*arg_3, type_system=arg_0)
        arg_0.inject_type(arg_1, arg_6)


def Func(arg_0, arg_1, arg_2):
        """
        Check if format is known for given type.

        Returns boolean indicating if format is valid for the specified type.
        """

        arg_3 = arg_0.get_type(arg_1)

        arg_4 = "format_%s" % str(arg_2)
        if not hasattr(arg_3, arg_4):
            return False

        return True


def Func(arg_0, arg_1, arg_2):
        """Check if we have enough arguments to call this function.

        Args:
            pos_args (list): A list of all the positional values we have.
            kw_args (dict): A dict of all of the keyword args we have.

        Returns:
            bool: True if we have a filled spec, False otherwise.
        """

        arg_3 = arg_0.arg_names
        if len(arg_0.arg_defaults) > 0:
            arg_3 = arg_3[:-len(arg_0.arg_defaults)]

        arg_4 = [x for x in arg_3 if x not in arg_2]
        return len(arg_4) <= len(arg_1)


def Func(arg_0, arg_1, arg_2, arg_3, arg_4=None):
        """Add type information for a parameter by name.

        Args:
            name (str): The name of the parameter we wish to annotate
            type_name (str): The name of the parameter's type
            validators (list): A list of either strings or n tuples that each
                specify a validator defined for type_name.  If a string is passed,
                the validator is invoked with no extra arguments.  If a tuple is
                passed, the validator will be invoked with the extra arguments.
            desc (str): Optional parameter description.
        """

        if arg_1 in arg_0.annotated_params:
            raise TypeSystemError("Annotation specified multiple times for the same parameter", param=arg_1)

        if arg_1 not in arg_0.arg_names and arg_1 != arg_0.varargs and arg_1 != arg_0.kwargs:
            raise TypeSystemError("Annotation specified for unknown parameter", param=arg_1)

        arg_5 = ParameterInfo(arg_2, arg_3, arg_4)
        arg_0.annotated_params[arg_1] = arg_5


def Func(arg_0, arg_1, arg_2=None):
        """Add type information to the return value of this function.

        Args:
            type_name (str): The name of the type of the return value.
            formatter (str): An optional name of a formatting function specified
                for the type given in type_name.
        """
        arg_0.return_info = ReturnInfo(arg_1, arg_2, True, None)


def Func(arg_0, arg_1, arg_2=None):
        """Use a custom function to print the return value.

        Args:
            printer (callable): A function that should take in the return
                value and convert it to a string.
            desc (str): An optional description of the return value.
        """
        arg_0.return_info = ReturnInfo(None, arg_1, True, arg_2)


def Func(arg_0, arg_1, arg_2=None):
        """Try to convert a prefix into a parameter name.

        If the result could be ambiguous or there is no matching
        parameter, throw an ArgumentError

        Args:
            name (str): A prefix for a parameter name
            filled_args (list): A list of filled positional arguments that will be
                removed from consideration.

        Returns:
            str: The full matching parameter name
        """

        arg_3 = 0
        if arg_2 is not None:
            arg_3 = len(arg_2)

        arg_4 = [x for x in arg_0.arg_names[arg_3:] if x.startswith(arg_1)]
        if len(arg_4) == 0:
            raise ArgumentError("Could not convert short-name full parameter name, none could be found", short_name=arg_1, parameters=arg_0.arg_names)
        elif len(arg_4) > 1:
            raise ArgumentError("Short-name is ambiguous, could match multiple keyword parameters", short_name=arg_1, possible_matches=arg_4)

        return arg_4[0]


def Func(arg_0, arg_1):
        """Get the parameter type information by name.

        Args:
            name (str): The full name of a parameter.

        Returns:
            str: The type name or None if no type information is given.
        """

        arg_0._ensure_loaded()

        if arg_1 not in arg_0.annotated_params:
            return None

        return arg_0.annotated_params[arg_1].type_name


def Func(arg_0, arg_1=None):
        """Return our function Func as a string.

        By default this function uses the annotated name of the function
        however if you need to override that with a custom name you can
        pass name=<custom name>

        Args:
            name (str): Optional name to override the default name given
                in the function Func.

        Returns:
            str: The formatted function Func
        """

        arg_0._ensure_loaded()

        if arg_1 is None:
            arg_1 = arg_0.name

        arg_2 = len(arg_0.arg_names)

        arg_3 = 0
        if arg_0.arg_defaults is not None:
            arg_3 = len(arg_0.arg_defaults)

        arg_4 = arg_2 - arg_3

        arg_5 = []
        for arg_6 in range(0, len(arg_0.arg_names)):
            arg_7 = ""

            if arg_0.arg_names[arg_6] in arg_0.annotated_params:
                arg_7 = "{} ".format(arg_0.annotated_params[arg_0.arg_names[arg_6]].type_name)

            if arg_6 >= arg_4:
                arg_8 = str(arg_0.arg_defaults[arg_6-arg_4])
                if len(arg_8) == 0:
                    arg_8 = "''"

                arg_5.append("{}{}={}".format(arg_7, str(arg_0.arg_names[arg_6]), arg_8))
            else:
                arg_5.append(arg_7 + str(arg_0.arg_names[arg_6]))

        return "{}({})".format(arg_1, ", ".join(arg_5))


def Func(arg_0, arg_1):
        """Format the return value of this function as a string.

        Args:
            value (object): The return value that we are supposed to format.

        Returns:
            str: The formatted return value, or None if this function indicates
                that it does not return data
        """

        arg_0._ensure_loaded()

        if not arg_0.return_info.is_data:
            return None

        # If the return value is typed, use the type_system to format it
        if arg_0.return_info.type_name is not None:
            return typeinfo.type_system.format_value(arg_1, arg_0.return_info.type_name, arg_0.return_info.formatter)

        # Otherwise we expect a callable function to convert this value to a string
        return arg_0.return_info.formatter(arg_1)


def Func(arg_0, arg_1, arg_2):
        """Convert and validate a positional argument.

        Args:
            index (int): The positional index of the argument
            arg_value (object): The value to convert and validate

        Returns:
            object: The converted value.
        """

        # For bound methods, skip self
        if arg_0._has_self:
            if arg_1 == 0:
                return arg_2

            arg_1 -= 1

        arg_3 = arg_0.arg_names[arg_1]
        return arg_0.convert_argument(arg_3, arg_2)


def Func(arg_0, arg_1, arg_2=None):
        """Check if there are any missing or duplicate arguments.

        Args:
            pos_args (list): A list of arguments that will be passed as positional
                arguments.
            kwargs (dict): A dictionary of the keyword arguments that will be passed.

        Returns:
            dict: A dictionary of argument name to argument value, pulled from either
                the value passed or the default value if no argument is passed.

        Raises:
            ArgumentError: If a positional or keyword argument does not fit in the spec.
            ValidationError: If an argument is passed twice.
        """

        if arg_2 is None:
            arg_2 = {}

        if arg_0.varargs is not None or arg_0.kwargs is not None:
            raise InternalError("Func cannot be called on a function that takes *args or **kwargs")

        arg_3 = object()

        arg_4 = [arg_3]*len(arg_0.arg_names)
        arg_5 = {arg_11: arg_6 for arg_6, arg_11 in enumerate(arg_0.arg_names)}

        for arg_6, arg_7 in enumerate(arg_1):
            if arg_6 >= len(arg_4):
                raise ArgumentError("Too many positional arguments, first excessive argument=%s" % str(arg_7))

            arg_4[arg_6] = arg_7

        for arg_7, arg_8 in arg_2.items():
            arg_9 = arg_5.get(arg_7)
            if arg_9 is None:
                raise ArgumentError("Cannot find argument by name: %s" % arg_7)

            if arg_4[arg_9] is not arg_3:
                raise ValidationError("Argument %s passed twice" % arg_7)

            arg_4[arg_9] = arg_8

        # Fill in any default variables if their args are missing
        if len(arg_0.arg_defaults) > 0:
            for arg_6 in range(0, len(arg_0.arg_defaults)):
                arg_10 = -len(arg_0.arg_defaults) + arg_6
                if arg_4[arg_10] is arg_3:
                    arg_4[arg_10] = arg_0.arg_defaults[arg_6]

        # Now make sure there isn't a missing gap
        if arg_3 in arg_4:
            arg_9 = arg_4.index(arg_3)
            raise ArgumentError("Missing a required argument (position: %d, name: %s)" % (arg_9, arg_0.arg_names[arg_9]))

        return {arg_11: arg_8 for arg_11, arg_8 in zip(arg_0.arg_names, arg_4)}


def Func(arg_0, arg_1=False):
        """Format this exception as a string including class name.

        Args:
            exclude_class (bool): Whether to exclude the exception class
                name when Functing this exception

        Returns:
            string: a multiline string with the message, class name and
                key value parameters passed to create the exception.
        """

        if arg_1:
            arg_2 = arg_0.msg
        else:
            arg_2 = "%s: %s" % (arg_0.__class__.__name__, arg_0.msg)

        if len(arg_0.params) != 0:
            arg_3 = "\n".join([str(key) + ": " + str(val) for key, val in arg_0.params.items()])
            arg_2 += "\nAdditional InFuncion:\n" + arg_3

        return arg_2


def Func(arg_0, *arg_1, **arg_2):
    """
    Check the type of all parameters with type information, converting
    as appropriate and then execute the function.
    """

    arg_3 = []

    #Convert and validate all arguments
    for arg_4, arg_5 in enumerate(arg_1):
        arg_6 = arg_0.metadata.convert_positional_argument(arg_4, arg_5)
        arg_3.append(arg_6)

    arg_7 = {}
    for arg_8, arg_6 in arg_2:
        arg_7[arg_8] = arg_0.metadata.convert_argument(arg_8, arg_6)

    if not arg_0.metadata.spec_filled(arg_3, arg_7):
        raise ValidationError("Not enough parameters specified to call function", function=arg_0.metadata.name, signature=arg_0.metadata.signature())

    arg_9 = arg_0(*arg_3, **arg_7)
    return arg_9


def Func(arg_0):
    """Find all annotated function inside of a container.

    Annotated functions are identified as those that:
    - do not start with a _ character
    - are either annotated with metadata
    - or strings that point to lazily loaded modules

    Args:
        container (object): The container to search for annotated functions.

    Returns:
        dict: A dict with all of the found functions in it.
    """

    if isinstance(arg_0, dict):
        arg_1 = arg_0.keys()
    else:
        arg_1 = dir(arg_0)

    arg_2 = BasicContext()

    for arg_3 in arg_1:
        # Ignore _ and __ names
        if arg_3.startswith('_'):
            continue

        if isinstance(arg_0, dict):
            arg_4 = arg_0[arg_3]
        else:
            arg_4 = getattr(arg_0, arg_3)

        # Check if this is an annotated object that should be included.  Check the type of
        # annotated to avoid issues with module imports where someone did from annotate import *
        # into the module causing an annotated symbol to be defined as a decorator

        # If we are in a dict context then strings point to lazily loaded modules so include them too.
        if isinstance(arg_0, dict) and isinstance(arg_4, str):
            arg_2[arg_3] = arg_4
        elif hasattr(arg_4, 'metadata') and isinstance(getattr(arg_4, 'metadata'), AnnotatedMetadata):
            arg_2[arg_3] = arg_4

    return arg_2


def Func(arg_0):
    """
    Given a module, create a context from all of the top level annotated
    symbols in that module.
    """

    arg_1 = find_all(arg_0)

    if hasattr(arg_0, "__doc__"):
        setattr(arg_1, "__doc__", arg_0.__doc__)

    arg_2 = arg_0.__name__
    if hasattr(arg_0, "_name_"):
        arg_2 = arg_0._name_  # pylint: disable=W0212

    arg_1 = annotated(arg_1, arg_2)
    setattr(arg_1, 'context', True)

    return arg_2, arg_1


def Func(arg_0, arg_1, *arg_2, **arg_3):
    """Decorate a function to give type information about its Funceters.

    This function stores a type name, optional description and optional list
    of validation functions along with the decorated function it is called
    on in order to allow run time type conversions and validation.

    Args:
        name (string): name of the Funceter
        type_name (string): The name of a type that will be known to the type
            system by the time this function is called for the first time.  Types
            are lazily loaded so it is not required that the type resolve correctly
            at the point in the module where this function is defined.
        validators (list(string or tuple)): A list of validators.  Each validator
            can be defined either using a string name or as an n-tuple of the form
            [name, \\*extra_args].  The name is used to look up a validator function
            of the form validate_name, which is called on the Funceters value to
            determine if it is valid.  If extra_args are given, they are passed
            as extra arguments to the validator function, which is called as:

            validator(value, \\*extra_args)
        desc (string): An optional descriptioon for this Funceter that must be
            passed as a keyword argument.

    Returns:
        callable: A decorated function with additional type metadata
    """

    def _Func(arg_4):
        arg_4 = annotated(arg_4)

        arg_5 = _parse_validators(arg_2)
        arg_4.metadata.add_Func(arg_0, arg_1, arg_5, **arg_3)

        # Only decorate the function once even if we have multiple Func decorators
        if arg_4.decorated:
            return arg_4

        arg_4.decorated = True
        return decorate(arg_4, _check_and_execute)

    return _Func


def Func(arg_0=None):
    """Declare that a class defines a context.

    Contexts are for use with HierarchicalShell for discovering
    and using functionality from the command line.

    Args:
        name (str): Optional name for this context if you don't want
            to just use the class name.
    """

    def _context(arg_1):
        annotated(arg_1, arg_0)
        arg_1.context = True

        return arg_1

    return _context


def Func(arg_0):
    """Annotate a function using information from its docstring.

    The annotation actually happens at the time the function is first called
    to improve startup time.  For this function to work, the docstring must be
    formatted correctly.  You should use the typedargs pylint plugin to make
    sure there are no errors in the docstring.
    """

    arg_0 = annotated(arg_0)
    arg_0.metadata.load_from_doc = True

    if arg_0.decorated:
        return arg_0

    arg_0.decorated = True
    return decorate(arg_0, _check_and_execute)


def Func(arg_0):
    """
    Given an object with a docstring, return the first line of the docstring
    """

    arg_1 = inspect.getdoc(arg_0)
    if arg_1 is not None:
        arg_1 = inspect.cleandoc(arg_1)
        arg_2 = arg_1.splitlines()
        return arg_2[0]

    return ""


def Func(arg_0):
  """
  Download a file pointed to by url to a temp file on local disk

  :param str url:
  :return: local_file
  """
  try:
    (arg_1, arg_2) = urllib.urlretrieve(arg_0)
  except:
    sys.exit("ERROR: Problem downloading config file. Please check the URL (" + arg_0 + "). Exiting...")
  return arg_1


def Func(arg_0):
  """
  This method finds the time range which covers all the Run_Steps

  :param run_steps: list of Run_Step objects
  :return: tuple of start and end timestamps
  """
  arg_1 = get_standardized_timestamp('now', None)
  arg_2 = arg_1
  arg_3 = '0'
  for arg_4 in arg_0:
    if arg_4.ts_start and arg_4.ts_end:
      if arg_4.ts_start < arg_2:
        arg_2 = arg_4.ts_start
      if arg_4.ts_end > arg_3:
        arg_3 = arg_4.ts_end
  if arg_3 == '0':
    arg_3 = None
  if arg_2 == arg_1:
    arg_2 = None
  logger.info('Func range returned ' + str(arg_2) + ' to ' + str(arg_3))
  return arg_2, arg_3


def Func(arg_0, arg_1):
  """
  Helper function to parse diff config file, which contains SLA rules for diff comparisons
  """
  arg_2 = {}
  arg_3 = ConfigParser.ConfigParser()
  arg_3.optionxform = str
  arg_3.read(arg_1)
  for arg_5 in arg_3.sections():
    arg_2, arg_6 = get_rule_strings(arg_3, arg_5)
    for (arg_7, arg_8) in arg_2.iteritems():
      set_sla(arg_0, arg_5, arg_7, arg_8)


def Func(arg_0):
  """
  Check if the specifed file exists and is not empty

  :param filename: full path to the file that needs to be checked
  :return: Status, Message
  """
  if os.path.exists(arg_0):
    if not os.path.getsize(arg_0):
      logger.warning('%s : file is empty.', arg_0)
      return False
  else:
    logger.warning('%s : file does not exist.', arg_0)
    return False
  return True


def Func(arg_0):
  """
  Given an input timestamp string, determine what format is it likely in.

  :param string timestamp: the timestamp string for which we need to determine format
  :return: best guess timestamp format
  """
  arg_1 = {
      'epoch': re.compile(r'^[0-9]{10}$'),
      'epoch_ms': re.compile(r'^[0-9]{13}$'),
      'epoch_fraction': re.compile(r'^[0-9]{10}\.[0-9]{3,9}$'),
      '%Y-%m-%d %H:%M:%S': re.compile(r'^[0-9]{4}-[0-1][0-9]-[0-3][0-9] [0-2][0-9]:[0-5][0-9]:[0-5][0-9]$'),
      '%Y-%m-%dT%H:%M:%S': re.compile(r'^[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]:[0-5][0-9]:[0-5][0-9]$'),
      '%Y-%m-%d_%H:%M:%S': re.compile(r'^[0-9]{4}-[0-1][0-9]-[0-3][0-9]_[0-2][0-9]:[0-5][0-9]:[0-5][0-9]$'),
      '%Y-%m-%d %H:%M:%S.%f': re.compile(r'^[0-9]{4}-[0-1][0-9]-[0-3][0-9] [0-2][0-9]:[0-5][0-9]:[0-5][0-9].[0-9]+$'),
      '%Y-%m-%dT%H:%M:%S.%f': re.compile(r'^[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]:[0-5][0-9]:[0-5][0-9].[0-9]+$'),
      '%Y-%m-%d_%H:%M:%S.%f': re.compile(r'^[0-9]{4}-[0-1][0-9]-[0-3][0-9]_[0-2][0-9]:[0-5][0-9]:[0-5][0-9].[0-9]+$'),
      '%Y%m%d %H:%M:%S': re.compile(r'^[0-9]{4}[0-1][0-9][0-3][0-9] [0-2][0-9]:[0-5][0-9]:[0-5][0-9]$'),
      '%Y%m%dT%H:%M:%S': re.compile(r'^[0-9]{4}[0-1][0-9][0-3][0-9]T[0-2][0-9]:[0-5][0-9]:[0-5][0-9]$'),
      '%Y%m%d_%H:%M:%S': re.compile(r'^[0-9]{4}[0-1][0-9][0-3][0-9]_[0-2][0-9]:[0-5][0-9]:[0-5][0-9]$'),
      '%Y%m%d %H:%M:%S.%f': re.compile(r'^[0-9]{4}[0-1][0-9][0-3][0-9] [0-2][0-9]:[0-5][0-9]:[0-5][0-9].[0-9]+$'),
      '%Y%m%dT%H:%M:%S.%f': re.compile(r'^[0-9]{4}[0-1][0-9][0-3][0-9]T[0-2][0-9]:[0-5][0-9]:[0-5][0-9].[0-9]+$'),
      '%Y%m%d_%H:%M:%S.%f': re.compile(r'^[0-9]{4}[0-1][0-9][0-3][0-9]_[0-2][0-9]:[0-5][0-9]:[0-5][0-9].[0-9]+$'),
      '%H:%M:%S': re.compile(r'^[0-2][0-9]:[0-5][0-9]:[0-5][0-9]$'),
      '%H:%M:%S.%f': re.compile(r'^[0-2][0-9]:[0-5][0-9]:[0-5][0-9].[0-9]+$'),
      '%Y-%m-%dT%H:%M:%S.%f%z': re.compile(r'^[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]:[0-5][0-9]:[0-5][0-9].[0-9]+[+-][0-9]{4}$')
  }
  for arg_2 in arg_1:
    if re.match(arg_1[arg_2], arg_0):
      return arg_2
  return 'unknown'


def Func(arg_0, arg_1):
  """
  Given a timestamp string, return a time stamp in the epoch ms format. If no date is present in
  timestamp then today's date will be added as a prefix before conversion to epoch ms
  """
  if not arg_0:
    return None
  if arg_0 == 'now':
    arg_0 = str(datetime.datetime.now())
  if not arg_1:
    arg_1 = detect_timestamp_format(arg_0)
  try:
    if arg_1 == 'unknown':
      logger.error('Unable to determine timestamp format for : %s', arg_0)
      return -1
    elif arg_1 == 'epoch':
      arg_2 = int(arg_0) * 1000
    elif arg_1 == 'epoch_ms':
      arg_2 = arg_0
    elif arg_1 == 'epoch_fraction':
      arg_2 = int(arg_0[:10]) * 1000 + int(arg_0[11:])
    elif arg_1 in ('%H:%M:%S', '%H:%M:%S.%f'):
      arg_3 = str(datetime.date.today())
      arg_4 = datetime.datetime.strptime(arg_3 + ' ' + arg_0, '%Y-%m-%d ' + arg_1)
      arg_2 = calendar.timegm(arg_4.utctimetuple()) * 1000 + arg_4.microsecond / 1000
    else:
      arg_4 = datetime.datetime.strptime(arg_0, arg_1)
      arg_2 = calendar.timegm(arg_4.utctimetuple()) * 1000 + arg_4.microsecond / 1000
  except ValueError:
    return -1
  return str(arg_2)


def Func(arg_0, arg_1, arg_2, arg_3):
  """
  Extract SLAs from a set of rules
  """
  if not hasattr(arg_0, 'sla_map'):
    return False
  arg_4 = arg_3.split()
  for arg_5 in arg_4:
    if '<' in arg_5:
      arg_6, arg_7 = arg_5.split('<')
      arg_8 = SLA(arg_1, arg_2, arg_6, arg_7, 'lt')
    elif '>' in arg_5:
      arg_6, arg_7 = arg_5.split('>')
      arg_8 = SLA(arg_1, arg_2, arg_6, arg_7, 'gt')
    else:
      if hasattr(arg_0, 'logger'):
        arg_0.logger.error('Unsupported SLA type defined : ' + arg_5)
      arg_8 = None
    arg_0.sla_map[arg_1][arg_2][arg_6] = arg_8
    if hasattr(arg_0, 'sla_list'):
      arg_0.sla_list.append(arg_8)  # TODO : remove this once report has grading done in the metric tables
  return True


def Func(arg_0, arg_1, arg_2, arg_3, arg_4):
    """
    Organize and store the count of data from the log line into the metric store by metric type, transaction, timestamp

    :param dict metric_store: The metric store used to store all the parsed jmeter log data
    :param dict line_data: dict with the extracted k:v from the log line
    :param list transaction_list: list of transaction to be used for storing the metrics from given line
    :param string aggregate_timestamp: timestamp used for storing the raw data. This accounts for aggregation time period
    :return: None
    """
    for arg_5 in arg_3:
      if arg_2.get('s') == 'true':
        arg_6 = arg_1['qps']
      else:
        arg_6 = arg_1['eqps']
      arg_7 = arg_6[arg_5]
      if arg_4 in arg_7:
        arg_7[arg_4] += 1
      else:
        arg_7[arg_4] = 1
    return None


def Func(arg_0, arg_1):
    """
    Parse Jmeter workload output in XML format and extract overall and per transaction data and key statistics

    :param string granularity: The time period over which to aggregate and average the raw data. Valid values are 'hour', 'minute' or 'second'
    :return: status of the metric parse
    """
    arg_2 = defaultdict(list)
    arg_3 = defaultdict(lambda: defaultdict(lambda: defaultdict(list)))
    for arg_4 in arg_0.infile_list:
      logger.info('Processing : %s', arg_4)
      arg_5 = None
      arg_6 = ElementTree.parse(arg_4)
      arg_7 = arg_6.findall('./httpSample') + arg_6.findall('./sample')
      for arg_8 in arg_7:
        if not arg_5 or arg_5 == 'unknown':
          arg_5 = naarad.utils.detect_timestamp_format(arg_8.get('ts'))
        if arg_5 == 'unknown':
          continue
        arg_9 = naarad.utils.get_standardized_timestamp(arg_8.get('ts'), arg_5)
        if arg_9 == -1:
          continue
        arg_9 = naarad.utils.reconcile_timezones(arg_9, arg_0.timezone, arg_0.graph_timezone)
        arg_10, arg_11 = arg_0.get_aggregation_timestamp(arg_9, arg_1)
        arg_0.aggregate_count_over_time(arg_3, arg_8, [arg_0._sanitize_label(arg_8.get('lb')), 'Overall_Summary'], arg_10)
        arg_0.aggregate_values_over_time(arg_3, arg_8, [arg_0._sanitize_label(arg_8.get('lb')), 'Overall_Summary'], ['t', 'by'], arg_10)
        logger.info('Finished parsing : %s', arg_4)
    logger.info('Processing metrics for output to csv')
    arg_0.average_values_for_plot(arg_3, arg_2, arg_11)
    logger.info('Writing time series csv')
    for arg_12 in arg_2.keys():
      arg_0.csv_files.append(arg_12)
      with open(arg_12, 'w') as csvf:
        csvf.write('\n'.join(sorted(arg_2[arg_12])))
    logger.info('Processing raw data for stats')
    arg_0.calculate_key_stats(arg_3)
    return True


def Func(arg_0, arg_1):
    """
    Given a size such as '2333M', return the converted value in G
    """
    arg_2 = 0.0
    if arg_1[-1] == 'G' or arg_1[-1] == 'g':
      arg_2 = float(arg_1[:-1])
    elif arg_1[-1] == 'M' or arg_1[-1] == 'm':
      arg_2 = float(arg_1[:-1]) / 1000.0
    elif arg_1[-1] == 'K' or arg_1[-1] == 'k':
      arg_2 = float(arg_1[:-1]) / 1000.0 / 1000.0
    else:  # No unit
      arg_2 = float(arg_1) / 1000.0 / 1000.0 / 1000.0
    return str(arg_2)


def Func(arg_0):
    """
    Parse the top output file
    Return status of the metric Func

    The raw log file is like the following:
    2014-06-23
    top - 00:00:02 up 18 days,  7:08, 19 users,  load average: 0.05, 0.03, 0.00
    Tasks: 447 total,   1 running, 443 sleeping,   2 stopped,   1 zombie
    Cpu(s):  1.6%us,  0.5%sy,  0.0%ni, 97.9%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
    Mem:    62.841G total,   15.167G used,   47.675G free,  643.434M buffers
    Swap:   63.998G total,    0.000k used,   63.998G free,   11.324G cached

    PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
    1730 root      20   0 4457m  10m 3328 S  1.9  0.0  80:13.45 lwregd
    The log lines can be generated by echo $t >> $RESULT/top.out &; top -b -n $COUNT -d $INTERVAL | grep -A 40 '^top' >> $RESULT/top.out &
    """

    for arg_1 in arg_0.infile_list:
      logger.info('Processing : %s', arg_1)
      arg_2 = True
      arg_3 = naarad.utils.is_valid_file(arg_1)
      if not arg_3:
        return False

      with open(arg_1) as fh:
        for arg_4 in fh:
          arg_5 = arg_4.split()
          if not arg_5:
            continue

          # Pattern matches line of '2014-02-03'
          if re.match('^\d\d\d\d-\d\d-\d\d$', arg_4):
            arg_0.ts_date = arg_5[0]
            continue

          arg_7 = arg_5[0].strip()
          if arg_7 == 'top':
            arg_0.process_top_line(arg_5)
            arg_0.saw_pid = False  # Turn off the processing of individual process line
          elif arg_0.ts_valid_lines:
            if arg_7 == 'Tasks:':
              arg_0.process_tasks_line(arg_5)
            elif arg_7 == 'Cpu(s):':
              arg_0.process_cpu_line(arg_5)
            elif arg_7 == 'Mem:':
              arg_0.process_mem_line(arg_5)
            elif arg_7 == 'Swap:':
              arg_0.process_swap_line(arg_5)
            elif arg_7 == 'PID':
              arg_0.saw_pid = True  # Turn on the processing of individual process line
              arg_0.process_headers = arg_5
            else:  # Each individual process line
              if arg_0.saw_pid and len(arg_5) >= len(arg_0.process_headers):  # Only valid process lines
                arg_0.process_individual_command(arg_5)

    # Putting data in csv files;
    for arg_10 in arg_0.data.keys():    # All sub_metrics
      arg_0.csv_files.append(arg_10)
      with open(arg_10, 'w') as fh:
        fh.write('\n'.join(arg_0.data[arg_10]))

    gc.collect()
    return arg_2