if (not isinstance(obj, dict)) or (<EOL>isinstance(obj, dict)<EOL>and (sorted(obj.keys()) != sorted(["<STR_LIT>", "<STR_LIT>", "<STR_LIT>"]))<EOL>):<EOL><INDENT>raise ValueError(pexdoc.pcontracts.get_exdesc())<EOL><DEDENT>if not (isinstance(obj["<STR_LIT>"], int) and (obj["<STR_LIT>"] > <NUM_LIT:0>)):<EOL><INDENT>raise ValueError(pexdoc.pcontracts.get_exdesc())<EOL><DEDENT>if _check_increasing_real_numpy_vector(obj["<STR_LIT>"]):<EOL><INDENT>raise ValueError(pexdoc.pcontracts.get_exdesc())<EOL><DEDENT>if not isinstance(obj["<STR_LIT>"], np.ndarray):<EOL><INDENT>raise ValueError(pexdoc.pcontracts.get_exdesc())<EOL><DEDENT>vdata = ["<STR_LIT:int>", "<STR_LIT:float>", "<STR_LIT>"]<EOL>if not any([obj["<STR_LIT>"].dtype.name.startswith(item) for item in vdata]):<EOL><INDENT>raise ValueError(pexdoc.pcontracts.get_exdesc())<EOL><DEDENT>if obj["<STR_LIT>"].size != obj["<STR_LIT>"]:<EOL><INDENT>raise ValueError(pexdoc.pcontracts.get_exdesc())<EOL><DEDENT>nports = int(math.sqrt(obj["<STR_LIT>"].size / obj["<STR_LIT>"].size))<EOL>if obj["<STR_LIT>"] * (nports ** <NUM_LIT:2>) != obj["<STR_LIT>"].size:<EOL><INDENT>raise ValueError(pexdoc.pcontracts.get_exdesc())<EOL><DEDENT>

r"""
    Validate if an object is an :ref:`TouchstoneData` pseudo-type object.

    :param obj: Object
    :type  obj: any

    :raises: RuntimeError (Argument \`*[argument_name]*\` is not valid). The
     token \*[argument_name]\* is replaced by the name of the argument the
     contract is attached to

    :rtype: None


if _check_increasing_real_numpy_vector(obj):<EOL><INDENT>raise ValueError(pexdoc.pcontracts.get_exdesc())<EOL><DEDENT>

r"""
    Validate if an object is :ref:`IncreasingRealNumpyVector` pseudo-type object.

    :param obj: Object
    :type  obj: any

    :raises: RuntimeError (Argument \`*[argument_name]*\` is not valid). The
     token \*[argument_name]\* is replaced by the name of the argument the
     contract is attached to

    :rtype: None


exdesc = pexdoc.pcontracts.get_exdesc()<EOL>if not isinstance(obj, str):<EOL><INDENT>raise ValueError(exdesc)<EOL><DEDENT>if obj.upper() in ["<STR_LIT>", "<STR_LIT>"]:<EOL><INDENT>return None<EOL><DEDENT>raise ValueError(exdesc)<EOL>

r"""
    Validate if an object is a :ref:`WaveInterpOption` pseudo-type object.

    :param obj: Object
    :type  obj: any

    :raises: RuntimeError (Argument \`*[argument_name]*\` is not valid). The
     token \*[argument_name]\* is replaced by the name of the argument the
     contract is attached to

    :rtype: None


@pexdoc.pcontracts.contract(suffix="<STR_LIT>", offset=int)<EOL>def peng_suffix_math(suffix, offset):

<EOL>eobj = pexdoc.exh.addex(ValueError, "<STR_LIT>")<EOL>try:<EOL><INDENT>return _POWER_TO_SUFFIX_DICT[_SUFFIX_TO_POWER_DICT[suffix] + <NUM_LIT:3> * offset]<EOL><DEDENT>except KeyError:<EOL><INDENT>eobj(True)<EOL><DEDENT>

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.peng_suffix_math

    :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.peng_suffix_math('u', 6)
        'T'


<EOL>split = lambda x, p: (x.ljust(<NUM_LIT:3> + neg, "<STR_LIT:0>")[:p], x[p:].rstrip("<STR_LIT:0>"))<EOL>mant, exp = to_scientific_tuple(number)<EOL>mant, neg = mant.replace("<STR_LIT:.>", "<STR_LIT>"), mant.startswith("<STR_LIT:->")<EOL>new_mant = "<STR_LIT:.>".join(filter(None, split(mant, <NUM_LIT:1> + (exp % <NUM_LIT:3>) + neg)))<EOL>new_exp = int(<NUM_LIT:3> * math.floor(exp / <NUM_LIT:3>))<EOL>return NumComp(new_mant, new_exp)<EOL>

Return tuple with mantissa and exponent of number formatted in engineering notation.

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

:rtype: tuple


def _split_every(text, sep, count, lstrip=False, rstrip=False):

ltr = "<STR_LIT>"[<NUM_LIT:2> * lstrip + rstrip].strip()<EOL>func = lambda x: getattr(x, ltr + "<STR_LIT>")() if ltr != "<STR_LIT:_>" else x<EOL>items = text.split(sep)<EOL>groups = zip_longest(*[iter(items)] * count, fillvalue="<STR_LIT>")<EOL>joints = (sep.join(group).rstrip(sep) for group in groups)<EOL>return tuple(func(joint) for joint in joints)<EOL>

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


<EOL>snum = snum.rstrip()<EOL>power = _SUFFIX_POWER_DICT["<STR_LIT:U+0020>" if snum[-<NUM_LIT:1>].isdigit() else snum[-<NUM_LIT:1>]]<EOL>return float(snum if snum[-<NUM_LIT:1>].isdigit() else snum[:-<NUM_LIT:1>]) * power<EOL>

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.peng_float

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

    .. [[[end]]]

    For example:

        >>> import peng
        >>> peng.peng_float(peng.peng(1235.6789E3, 3, False))
        1236000.0


mant, exp = to_scientific_tuple(number)<EOL>if not exp:<EOL><INDENT>return str(number)<EOL><DEDENT>floating_mant = "<STR_LIT:.>" in mant<EOL>mant = mant.replace("<STR_LIT:.>", "<STR_LIT>")<EOL>if exp < <NUM_LIT:0>:<EOL><INDENT>return "<STR_LIT>" + "<STR_LIT:0>" * (-exp - <NUM_LIT:1>) + mant<EOL><DEDENT>if not floating_mant:<EOL><INDENT>return mant + "<STR_LIT:0>" * exp + ("<STR_LIT>" if isinstance(number, float) else "<STR_LIT>")<EOL><DEDENT>lfpart = len(mant) - <NUM_LIT:1><EOL>if lfpart < exp:<EOL><INDENT>return (mant + "<STR_LIT:0>" * (exp - lfpart)).rstrip("<STR_LIT:.>")<EOL><DEDENT>return mant<EOL>

r"""
    Convert number to string guaranteeing result is not in scientific notation.

    :param number: Number to convert
    :type  number: integer or float

    :rtype: string

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

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

    .. [[[end]]]


def _remove_extra_delims(expr, ldelim="<STR_LIT:(>", rdelim="<STR_LIT:)>", fcount=None):

if not expr.strip():<EOL><INDENT>return "<STR_LIT>"<EOL><DEDENT>fcount = [<NUM_LIT:0>] if fcount is None else fcount<EOL>tfuncs = _get_functions(expr, ldelim=ldelim, rdelim=rdelim)<EOL>for fdict in reversed(tfuncs):<EOL><INDENT>fcount[<NUM_LIT:0>] += <NUM_LIT:1><EOL>fdict["<STR_LIT>"] = "<STR_LIT>" + str(fcount[<NUM_LIT:0>])<EOL>expr = expr[: fdict["<STR_LIT:start>"]] + fdict["<STR_LIT>"] + expr[fdict["<STR_LIT>"] + <NUM_LIT:1> :]<EOL>fdict["<STR_LIT>"] = _remove_extra_delims(<EOL>fdict["<STR_LIT>"], ldelim=ldelim, rdelim=rdelim, fcount=fcount<EOL>)<EOL><DEDENT>expr = _build_expr(<EOL>_parse_expr(expr, ldelim=ldelim, rdelim=rdelim), ldelim=ldelim, rdelim=rdelim<EOL>)<EOL>for fdict in tfuncs:<EOL><INDENT>expr = expr.replace(<EOL>fdict["<STR_LIT>"], fdict["<STR_LIT>"] + ldelim + fdict["<STR_LIT>"] + rdelim<EOL>)<EOL><DEDENT>return expr<EOL>

Remove unnecessary delimiters (parenthesis, brackets, etc.).

Internal function that can be recursed


r"""
        Return a string with the expression needed to re-create the object.

        For example:

            >>> import numpy as np
            >>> import peng
            >>> obj = peng.Waveform(
            ...     np.array([1, 2, 3]),
            ...     np.array([4, 5, 6]),
            ...     'test'
            ... )
            >>> repr(obj)
            "peng.Waveform(indep_vector=array([1, 2, 3]), dep_vector=array([4, 5, 6]), dep_name='test', indep_scale='LINEAR', dep_scale='LINEAR', indep_units='', dep_units='', interp='CONTINUOUS')"


exobj = pexdoc.exh.addex(RuntimeError, "<STR_LIT>")<EOL>min_bound = max(np.min(wave_a.indep_vector), np.min(wave_b.indep_vector))<EOL>max_bound = min(np.max(wave_a.indep_vector), np.max(wave_b.indep_vector))<EOL>exobj(bool(min_bound > max_bound))<EOL>raw_range = np.unique(np.concatenate((wave_a.indep_vector, wave_b.indep_vector)))<EOL>return raw_range[np.logical_and(min_bound <= raw_range, raw_range <= max_bound)]<EOL>


return self._operation(other, "<STR_LIT>")<EOL>

Integer-divide the dependent variable vector of a waveform.

The integer division may be by the dependent variable vector of another
waveform, the dependent variable vector of a waveform by a number, or a
number by the dependent variable vector of a waveform. In the latter
case a :py:class:`peng.Waveform()` object is returned with the result.

For example:

    >>> import numpy as np
    >>> import peng
    >>> indep_vector = np.array([1, 2, 3])
    >>> dep_vector_a = np.array([4, 5, 6])
    >>> dep_vector_b = np.array([8, 2, 4])
    >>> obj_a = peng.Waveform(indep_vector, dep_vector_a, 'obj_a')
    >>> obj_b = peng.Waveform(indep_vector, dep_vector_b, 'obj_b')
    >>> print(obj_a//obj_b)
    Waveform: obj_a//obj_b
    Independent variable: [ 1, 2, 3 ]
    Dependent variable: [ 0, 2, 1 ]
    Independent variable scale: LINEAR
    Dependent variable scale: LINEAR
    Independent variable units: (None)
    Dependent variable units: (None)
    Interpolating function: CONTINUOUS

.. [[[cog cog.out(exobj_eng.get_sphinx_autodoc(raised=True)) ]]]
.. Auto-generated exceptions documentation for
.. peng.wave_core.Waveform.__floordiv__

:raises:
 * RuntimeError (Independent variable ranges do not overlap)

 * RuntimeError (Waveforms are not compatible)

 * TypeError (Complex operands not supported)

 * TypeError (Data type not supported)

.. [[[end]]]


return self._operation(other, "<STR_LIT>", reflected=True)<EOL>

Reflected floor (integer) division.

See :py:meth:`peng.Waveform.__floordiv__` for more details


Reflected right shift.

See :py:meth:`peng.Waveform.__rshift__` for more details


return not bool(<EOL>np.all(<EOL>np.isclose(<EOL>self._dep_vector, np.zeros(len(self._dep_vector)), FP_RTOL, FP_ATOL<EOL>)<EOL>)<EOL>)<EOL>

Test if the waveform dependent vector is zero for all its elements.

For example:

    >>> import numpy as np
    >>> import peng
    >>> indep_vector = np.array([1, 2, 3])
    >>> dep_vector = np.array([4, 5, 6])
    >>> obj = peng.Waveform(indep_vector, dep_vector, 'obj_a')
    >>> if obj:
    ...     print('Boolean test returned: True')
    ... else:
    ...     print('Boolean test returned: False')
    Boolean test returned: True
    >>> dep_vector = np.zeros(3)
    >>> obj = peng.Waveform(indep_vector, dep_vector, 'obj_a')
    >>> if obj:
    ...     print('Boolean test returned: True')
    ... else:
    ...     print('Boolean test returned: False')
    Boolean test returned: False


return self._operation(other, "<STR_LIT:->")<EOL>

Reflected subtraction.

See :py:meth:`peng.Waveform.__sub__` for more details


for iitem, ditem in zip(self._indep_vector, self._dep_vector):<EOL><INDENT>yield iitem, ditem<EOL><DEDENT>

Return an iterable over the independent and dependent variable vectors.

Each item returned by an iterator is a :py:data:`peng.Point` named
tuple

:rtype: iterable


Reflected left shift.

See :py:meth:`peng.Waveform.__lshift__` for more details


return not self.__eq__(other)<EOL>

Test waveform inequality.

Two waveforms are considered unequal if their independent variable
vectors are different with :py:data:`peng.FP_ATOL` absolute tolerance
and :py:data:`peng.FP_RTOL` relative tolerance, and/or their dependent
variable vectors are different with :py:data:`peng.FP_ATOL` absolute
tolerance and :py:data:`peng.FP_RTOL` relative tolerance, and/or their
independent variable scales are not the same, and/or their dependent
variable scales are not the, and/or their independent variable units
are not the same, and/or their dependent variable units are not the
same and/or they do not have the same interpolation function.

A waveform is considered unequal to a real number when its dependent
variable is not equal to that number at least in one element.


return self._operation(other, "<STR_LIT:*>")<EOL>

Multiply the dependent variable vector of a waveform.

The multiplication may be computed element-by-element using another the
dependent variable vector of another waveform or a number.

For example:

    >>> import numpy as np
    >>> import peng
    >>> indep_vector = np.array([1, 2, 3])
    >>> dep_vector_a = np.array([4, 5, 6])
    >>> dep_vector_b = np.array([8, 2, 4])
    >>> obj_a = peng.Waveform(indep_vector, dep_vector_a, 'obj_a')
    >>> obj_b = peng.Waveform(indep_vector, dep_vector_b, 'obj_b')
    >>> print(obj_a*obj_b)
    Waveform: obj_a*obj_b
    Independent variable: [ 1, 2, 3 ]
    Dependent variable: [ 32, 10, 24 ]
    Independent variable scale: LINEAR
    Dependent variable scale: LINEAR
    Independent variable units: (None)
    Dependent variable units: (None)
    Interpolating function: CONTINUOUS

.. [[[cog cog.out(exobj_eng.get_sphinx_autodoc()) ]]]
.. Auto-generated exceptions documentation for
.. peng.wave_core.Waveform.__mul__

:raises:
 * RuntimeError (Waveforms are not compatible)

 * TypeError (Data type not supported)

.. [[[end]]]


Reflected multiplication.

See :py:meth:`peng.Waveform.__mul__` for more details


return self._operation(other, "<STR_LIT:|>")<EOL>

Bit-wise logic or the dependent variable of a waveform.

The other operand may be the dependent variable vector of another
waveform or a number.

For example:

    >>> import numpy as np
    >>> import peng
    >>> indep_vector = np.array([1, 2, 3])
    >>> dep_vector_a = np.array([4, 5, 6])
    >>> dep_vector_b = np.array([8, 2, 4])
    >>> obj_a = peng.Waveform(indep_vector, dep_vector_a, 'obj_a')
    >>> obj_b = peng.Waveform(indep_vector, dep_vector_b, 'obj_b')
    >>> print(obj_a|obj_b)
    Waveform: obj_a|obj_b
    Independent variable: [ 1, 2, 3 ]
    Dependent variable: [ 12, 7, 6 ]
    Independent variable scale: LINEAR
    Dependent variable scale: LINEAR
    Independent variable units: (None)
    Dependent variable units: (None)
    Interpolating function: CONTINUOUS

.. [[[cog cog.out(exobj_eng.get_sphinx_autodoc(raised=True)) ]]]
.. Auto-generated exceptions documentation for
.. peng.wave_core.Waveform.__or__

:raises:
 * RuntimeError (Independent variable ranges do not overlap)

 * RuntimeError (Waveforms are not compatible)

 * TypeError (Complex operands not supported)

 * TypeError (Data type not supported)

.. [[[end]]]


return self._operation(other, "<STR_LIT:%>", reflected=True)<EOL>

Reflected division.

See :py:meth:`peng.Waveform.__mod__` for more details


if (not isinstance(item, tuple)) or (<EOL>isinstance(item, tuple) and (len(item) != <NUM_LIT:2>)<EOL>):<EOL><INDENT>return False<EOL><DEDENT>tchk = any([isinstance(item[<NUM_LIT:0>], typ) for typ in [int, float]])<EOL>if not tchk:<EOL><INDENT>return False<EOL><DEDENT>tchk = any([isinstance(item[<NUM_LIT:1>], typ) for typ in [int, float, complex]])<EOL>if not tchk:<EOL><INDENT>return False<EOL><DEDENT>indices = [np.where(self._indep_vector >= item[<NUM_LIT:0>])[<NUM_LIT:0>][<NUM_LIT:0>]]<EOL>if indices[<NUM_LIT:0>]:<EOL><INDENT>indices.append(indices[<NUM_LIT:0>] - <NUM_LIT:1>)<EOL><DEDENT>for index in indices:<EOL><INDENT>icmp = np.isclose(<EOL>np.array([self._indep_vector[index]]),<EOL>np.array([item[<NUM_LIT:0>]]),<EOL>FP_RTOL,<EOL>FP_ATOL,<EOL>)<EOL>dcmp = np.isclose(<EOL>np.array([self._dep_vector[index]]),<EOL>np.array([item[<NUM_LIT:1>]]),<EOL>FP_RTOL,<EOL>FP_ATOL,<EOL>)<EOL>if icmp and dcmp:<EOL><INDENT>return True<EOL><DEDENT><DEDENT>return False<EOL>

Test if an item is a data point in the waveform.

An item is in a waveform when it is a tuple with the characteristics of
the :py:data:`peng.Point` named tuple and its independent and dependent
values match a waveform's data point with :py:data:`peng.FP_ATOL`
absolute tolerance and :py:data:`peng.FP_RTOL` relative tolerance

:param item: Object
:type  item: any


Test whether waveform is less than or equal to another waveform or real number.

A waveform is less than or equal to another waveform or a number if
all elements of its dependent variable vector are less than or equal
to, element-by-element, the elements of the dependent variable vector
of another waveform or a real number with :py:data:`peng.FP_ATOL`
absolute tolerance and :py:data:`peng.FP_RTOL` relative tolerance

.. [[[cog cog.out(exobj_eng.get_sphinx_autodoc(raised=True)) ]]]
.. Auto-generated exceptions documentation for
.. peng.wave_core.Waveform.__le__

:raises:
 * RuntimeError (Independent variable ranges do not overlap)

 * RuntimeError (Waveforms are not compatible)

 * TypeError (Complex operands not supported)

 * TypeError (Data type not supported)

.. [[[end]]]


return _operation(wave, "<STR_LIT>", "<STR_LIT>", np.cos)<EOL>

r"""
    Return the 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.cos

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

    .. [[[end]]]


pexdoc.exh.addex(<EOL>ValueError,<EOL>"<STR_LIT>",<EOL>bool((min(wave._dep_vector) < -<NUM_LIT:1>) or (max(wave._dep_vector) > <NUM_LIT:1>)),<EOL>)<EOL>return _operation(wave, "<STR_LIT>", "<STR_LIT>", np.arcsin)<EOL>

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.asin

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

     * ValueError (Math domain error)

    .. [[[end]]]


pexdoc.exh.addex(<EOL>TypeError,<EOL>"<STR_LIT>",<EOL>wave._dep_vector.dtype.name.startswith("<STR_LIT>"),<EOL>)<EOL>ret = copy.copy(wave)<EOL>ret._dep_vector = ret._dep_vector.astype(np.float)<EOL>return ret<EOL>

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.wfloat

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

     * TypeError (Cannot convert complex to float)

    .. [[[end]]]


@pexdoc.pcontracts.contract(<EOL>wave=Waveform, indep_min="<STR_LIT>", indep_max="<STR_LIT>"<EOL>)<EOL>def average(wave, indep_min=None, indep_max=None):

ret = copy.copy(wave)<EOL>_bound_waveform(ret, indep_min, indep_max)<EOL>area = _running_area(ret._indep_vector, ret._dep_vector)<EOL>area[<NUM_LIT:0>] = ret._dep_vector[<NUM_LIT:0>]<EOL>deltas = ret._indep_vector - ret._indep_vector[<NUM_LIT:0>]<EOL>deltas[<NUM_LIT:0>] = <NUM_LIT:1.0><EOL>ret._dep_vector = np.divide(area, deltas)<EOL>ret.dep_name = "<STR_LIT>".format(ret._dep_name)<EOL>return ret<EOL>

r"""
    Return the running 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.average

    :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]]]


return phase(ifft(wave, npoints, indep_min, indep_max), unwrap=unwrap, rad=rad)<EOL>

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.ifftp

    :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 _operation(wave, "<STR_LIT>", "<STR_LIT>", np.sinh)<EOL>

r"""
    Return the hyperbolic 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.sinh

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

    .. [[[end]]]


return _operation(wave, "<STR_LIT>", wave.dep_units, np.floor)<EOL>

r"""
    Return the floor 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.floor

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

    .. [[[end]]]


def _operation(wave, desc, units, fpointer):

ret = copy.copy(wave)<EOL>ret.dep_units = units<EOL>ret.dep_name = "<STR_LIT>".format(desc, ret.dep_name)<EOL>ret._dep_vector = fpointer(ret._dep_vector)<EOL>return ret<EOL>

Perform generic operation on a waveform object.


<EOL>ret = copy.copy(wave)<EOL>_bound_waveform(ret, indep_min, indep_max)<EOL>close_min = np.isclose(min(ret._dep_vector), dep_var, FP_RTOL, FP_ATOL)<EOL>close_max = np.isclose(max(ret._dep_vector), dep_var, FP_RTOL, FP_ATOL)<EOL>if ((np.amin(ret._dep_vector) > dep_var) and (not close_min)) or (<EOL>(np.amax(ret._dep_vector) < dep_var) and (not close_max)<EOL>):<EOL><INDENT>return None<EOL><DEDENT>cross_wave = ret._dep_vector - dep_var<EOL>sign_wave = np.sign(cross_wave)<EOL>exact_idx = np.where(np.isclose(ret._dep_vector, dep_var, FP_RTOL, FP_ATOL))[<NUM_LIT:0>]<EOL>left_idx = np.where(np.diff(sign_wave))[<NUM_LIT:0>]<EOL>left_idx = np.setdiff1d(left_idx, exact_idx)<EOL>left_idx = np.setdiff1d(left_idx, exact_idx - <NUM_LIT:1>)<EOL>right_idx = left_idx + <NUM_LIT:1> if left_idx.size else np.array([])<EOL>indep_var = ret._indep_vector[exact_idx] if exact_idx.size else np.array([])<EOL>dvector = np.zeros(exact_idx.size).astype(int) if exact_idx.size else np.array([])<EOL>if left_idx.size and (ret.interp == "<STR_LIT>"):<EOL><INDENT>idvector = (<EOL><NUM_LIT> * (ret._dep_vector[right_idx] > ret._dep_vector[left_idx]).astype(int)<EOL>- <NUM_LIT:1><EOL>)<EOL>if indep_var.size:<EOL><INDENT>indep_var = np.concatenate((indep_var, ret._indep_vector[right_idx]))<EOL>dvector = np.concatenate((dvector, idvector))<EOL>sidx = np.argsort(indep_var)<EOL>indep_var = indep_var[sidx]<EOL>dvector = dvector[sidx]<EOL><DEDENT>else:<EOL><INDENT>indep_var = ret._indep_vector[right_idx]<EOL>dvector = idvector<EOL><DEDENT><DEDENT>elif left_idx.size:<EOL><INDENT>y_left = ret._dep_vector[left_idx]<EOL>y_right = ret._dep_vector[right_idx]<EOL>x_left = ret._indep_vector[left_idx]<EOL>x_right = ret._indep_vector[right_idx]<EOL>slope = ((y_left - y_right) / (x_left - x_right)).astype(float)<EOL>if indep_var.size:<EOL><INDENT>indep_var = np.concatenate(<EOL>(indep_var, x_left + ((dep_var - y_left) / slope))<EOL>)<EOL>dvector = np.concatenate((dvector, np.where(slope > <NUM_LIT:0>, <NUM_LIT:1>, -<NUM_LIT:1>)))<EOL>sidx = np.argsort(indep_var)<EOL>indep_var = indep_var[sidx]<EOL>dvector = dvector[sidx]<EOL><DEDENT>else:<EOL><INDENT>indep_var = x_left + ((dep_var - y_left) / slope)<EOL>dvector = np.where(slope > <NUM_LIT:0>, +<NUM_LIT:1>, -<NUM_LIT:1>)<EOL><DEDENT><DEDENT>if der is not None:<EOL><INDENT>indep_var = np.extract(dvector == der, indep_var)<EOL><DEDENT>return indep_var[inst - <NUM_LIT:1>] if inst <= indep_var.size else None<EOL>

r"""
    Return the independent variable point associated with a dependent variable point.

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

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

    :param dep_var: Dependent vector value to search for
    :type  dep_var: integer, float or complex

    :param der: Dependent vector derivative filter. If +1 only independent
                vector points that have positive derivatives when crossing
                the requested dependent vector point are returned; if -1 only
                independent vector points that have negative derivatives when
                crossing the requested dependent vector point are returned;
                if 0 only independent vector points that have null derivatives
                when crossing the requested dependent vector point are
                returned; otherwise if None all independent vector points are
                returned regardless of the dependent vector derivative. The
                derivative of the first and last point of the waveform is
                assumed to be null
    :type  der: integer, float or complex

    :param inst: Instance number filter. If, for example, **inst** equals 3,
                 then the independent variable vector point at which the
                 dependent variable vector equals the requested value for the
                 third time is returned
    :type  inst: 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: integer, float or None if the dependent variable point is not found

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

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

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

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

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

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

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

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

    .. [[[end]]]


@pexdoc.pcontracts.contract(<EOL>wave=Waveform, indep_min="<STR_LIT>", indep_max="<STR_LIT>"<EOL>)<EOL>def nmin(wave, indep_min=None, indep_max=None):

ret = copy.copy(wave)<EOL>_bound_waveform(ret, indep_min, indep_max)<EOL>return np.min(ret._dep_vector)<EOL>

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.nmin

    :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]]]


return _operation(wave, "<STR_LIT>", "<STR_LIT>", np.arcsinh)<EOL>

r"""
    Return the hyperbolic 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.asinh

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

    .. [[[end]]]


return _operation(wave, "<STR_LIT>", "<STR_LIT>", np.sin)<EOL>

r"""
    Return the 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.sin

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

    .. [[[end]]]


return _operation(wave, "<STR_LIT>", "<STR_LIT>", np.cosh)<EOL>

r"""
    Return the hyperbolic 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.cosh

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

    .. [[[end]]]


return _operation(wave, "<STR_LIT>", wave.dep_units, np.real)<EOL>

r"""
    Return the real part 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.real

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

    .. [[[end]]]


mname = "<STR_LIT>"<EOL>fname = "<STR_LIT>"<EOL>module_prefix = "<STR_LIT>".format(mname)<EOL>callable_names = (<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>)<EOL>return docs.support.trace_support.run_trace(<EOL>mname, fname, module_prefix, callable_names, no_print<EOL>)<EOL>


def ste(command, nindent, mdir, fpointer):

term_echo(<EOL>"<STR_LIT>".format(sep=os.path.sep, cmd=command),<EOL>nindent,<EOL>{"<STR_LIT>": mdir},<EOL>fpointer,<EOL>)<EOL>

r"""
    Echo terminal output.

    Print STDOUT resulting from a given Bash shell command (relative to the
    package :code:`pypkg` directory) formatted in reStructuredText

    :param command: Bash shell command, relative to
                    :bash:`${PMISC_DIR}/pypkg`
    :type  command: string

    :param nindent: Indentation level
    :type  nindent: integer

    :param mdir: Module directory
    :type  mdir: string

    :param fpointer: Output function pointer. Normally is :code:`cog.out` but
                     :code:`print` or other functions can be used for
                     debugging
    :type  fpointer: function object

    For example::

        .. This is a reStructuredText file snippet
        .. [[[cog
        .. import os, sys
        .. from docs.support.term_echo import term_echo
        .. file_name = sys.modules['docs.support.term_echo'].__file__
        .. mdir = os.path.realpath(
        ..     os.path.dirname(
        ..         os.path.dirname(os.path.dirname(file_name))
        ..     )
        .. )
        .. [[[cog ste('build_docs.py -h', 0, mdir, cog.out) ]]]

        .. code-block:: bash

        $ ${PMISC_DIR}/pypkg/build_docs.py -h
        usage: build_docs.py [-h] [-d DIRECTORY] [-n NUM_CPUS]
        ...

        .. ]]]


def term_echo(command, nindent=<NUM_LIT:0>, env=None, fpointer=None, cols=<NUM_LIT>):

<EOL>os.environ["<STR_LIT>"] = str(cols)<EOL>command_int = command<EOL>if env:<EOL><INDENT>for var, repl in env.items():<EOL><INDENT>command_int = command_int.replace("<STR_LIT>" + var + "<STR_LIT:}>", repl)<EOL><DEDENT><DEDENT>tokens = command_int.split("<STR_LIT:U+0020>")<EOL>if (platform.system().lower() == "<STR_LIT>") and (tokens[<NUM_LIT:0>].endswith("<STR_LIT>")):<EOL><INDENT>tokens = [sys.executable] + tokens<EOL><DEDENT>proc = subprocess.Popen(tokens, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)<EOL>stdout = proc.communicate()[<NUM_LIT:0>]<EOL>if sys.hexversion >= <NUM_LIT>:<EOL><INDENT>stdout = stdout.decode("<STR_LIT:utf-8>")<EOL><DEDENT>stdout = stdout.split("<STR_LIT:\n>")<EOL>indent = nindent * "<STR_LIT:U+0020>"<EOL>fpointer("<STR_LIT:\n>", dedent=False)<EOL>fpointer("<STR_LIT>".format(indent), dedent=False)<EOL>fpointer("<STR_LIT:\n>", dedent=False)<EOL>fpointer("<STR_LIT>".format(indent, command), dedent=False)<EOL>for line in stdout:<EOL><INDENT>if line.strip():<EOL><INDENT>fpointer(indent + "<STR_LIT:U+0020>" + line.replace("<STR_LIT:\t>", "<STR_LIT:U+0020>") + "<STR_LIT:\n>", dedent=False)<EOL><DEDENT>else:<EOL><INDENT>fpointer("<STR_LIT:\n>", dedent=False)<EOL><DEDENT><DEDENT>fpointer("<STR_LIT:\n>", dedent=False)<EOL>

Print STDOUT resulting from a Bash shell command formatted in reStructuredText.

:param command: Bash shell command
:type  command: string

:param nindent: Indentation level
:type  nindent: integer

:param env: Environment variable replacement dictionary. The Bash
            command is pre-processed and any environment variable
            represented in the full notation (:bash:`${...}`) is replaced.
            The dictionary key is the environment variable name and the
            dictionary value is the replacement value. For example, if
            **command** is :code:`'${PYTHON_CMD} -m "x=5"'` and **env**
            is :code:`{'PYTHON_CMD':'python3'}` the actual command issued
            is :code:`'python3 -m "x=5"'`
:type  env: dictionary

:param fpointer: Output function pointer. Normally is :code:`cog.out` but
                 :code:`print` or other functions can be used for
                 debugging
:type  fpointer: function object

:param cols: Number of columns of output
:type  cols: integer


if (not isinstance(obj, dict)) or (<EOL>isinstance(obj, dict)<EOL>and (sorted(obj.keys()) != sorted(["<STR_LIT>", "<STR_LIT>", "<STR_LIT>"]))<EOL>):<EOL><INDENT>raise ValueError(pexdoc.pcontracts.get_exdesc())<EOL><DEDENT>if not (isinstance(obj["<STR_LIT>"], int) and (obj["<STR_LIT>"] > <NUM_LIT:0>)):<EOL><INDENT>raise ValueError(pexdoc.pcontracts.get_exdesc())<EOL><DEDENT>if _check_increasing_real_numpy_vector(obj["<STR_LIT>"]):<EOL><INDENT>raise ValueError(pexdoc.pcontracts.get_exdesc())<EOL><DEDENT>if not isinstance(obj["<STR_LIT>"], np.ndarray):<EOL><INDENT>raise ValueError(pexdoc.pcontracts.get_exdesc())<EOL><DEDENT>vdata = ["<STR_LIT:int>", "<STR_LIT:float>", "<STR_LIT>"]<EOL>if not any([obj["<STR_LIT>"].dtype.name.startswith(item) for item in vdata]):<EOL><INDENT>raise ValueError(pexdoc.pcontracts.get_exdesc())<EOL><DEDENT>if obj["<STR_LIT>"].size != obj["<STR_LIT>"]:<EOL><INDENT>raise ValueError(pexdoc.pcontracts.get_exdesc())<EOL><DEDENT>nports = int(math.sqrt(obj["<STR_LIT>"].size / obj["<STR_LIT>"].size))<EOL>if obj["<STR_LIT>"] * (nports ** <NUM_LIT:2>) != obj["<STR_LIT>"].size:<EOL><INDENT>raise ValueError(pexdoc.pcontracts.get_exdesc())<EOL><DEDENT>

r"""
    Validate if an object is an :ref:`TouchstoneData` pseudo-type object.

    :param obj: Object
    :type  obj: any

    :raises: RuntimeError (Argument \`*[argument_name]*\` is not valid). The
     token \*[argument_name]\* is replaced by the name of the argument the
     contract is attached to

    :rtype: None


fdict = json_load(os.path.join("<STR_LIT:data>", "<STR_LIT>"))<EOL>sdeps = sorted(fdict.keys())<EOL>olines = []<EOL>for item in sdeps:<EOL><INDENT>olines.append(<EOL>"<STR_LIT>".format(<EOL>name=fdict[item]["<STR_LIT:name>"], url=fdict[item]["<STR_LIT:url>"]<EOL>)<EOL>)<EOL><DEDENT>ret = []<EOL>for line in olines:<EOL><INDENT>wobj = textwrap.wrap(line, width=LINE_WIDTH, subsequent_indent="<STR_LIT:U+0020>")<EOL>ret.append("<STR_LIT:\n>".join([item for item in wobj]))<EOL><DEDENT>mobj.out("<STR_LIT:\n>".join(ret))<EOL>


unsupp_ops = ["<STR_LIT>", "<STR_LIT>"]<EOL>supp_ops = ["<STR_LIT>", "<STR_LIT:>>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT:<>", "<STR_LIT>"]<EOL>tokens = sorted(item.split("<STR_LIT:U+002C>"), reverse=True)<EOL>actual_tokens = []<EOL>for req in tokens:<EOL><INDENT>for op in unsupp_ops:<EOL><INDENT>if req.startswith(op):<EOL><INDENT>raise RuntimeError("<STR_LIT>".format(op))<EOL><DEDENT><DEDENT>for op in supp_ops:<EOL><INDENT>if req.startswith(op):<EOL><INDENT>actual_tokens.append(op)<EOL>break<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise RuntimeError("<STR_LIT>".format(op))<EOL><DEDENT><DEDENT>if len(list(set(actual_tokens))) != len(actual_tokens):<EOL><INDENT>raise RuntimeError("<STR_LIT>")<EOL><DEDENT>if "<STR_LIT>" in actual_tokens:<EOL><INDENT>return (<EOL>"<STR_LIT>".join([op_to_words(token) for token in tokens[:-<NUM_LIT:1>]])<EOL>+ "<STR_LIT:U+0020>"<EOL>+ op_to_words(tokens[-<NUM_LIT:1>])<EOL>)<EOL><DEDENT>return "<STR_LIT>".join([op_to_words(token) for token in tokens])<EOL>

Translate requirement specification to words.


def make_multi_entry(plist, pkg_pyvers, ver_dict):

for pyver in pkg_pyvers:<EOL><INDENT>pver = pyver[<NUM_LIT:2>] + "<STR_LIT:.>" + pyver[<NUM_LIT:3>:]<EOL>plist.append("<STR_LIT>".format(pver, ops_to_words(ver_dict[pyver])))<EOL><DEDENT>

Generate Python interpreter version entries.


sdicts = [<EOL>{"<STR_LIT>": "<STR_LIT>"},<EOL>{"<STR_LIT>": "<STR_LIT>"},<EOL>{"<STR_LIT:>>": "<STR_LIT>"},<EOL>{"<STR_LIT>": "<STR_LIT>"},<EOL>{"<STR_LIT:<>": "<STR_LIT>"},<EOL>{"<STR_LIT>": "<STR_LIT>"},<EOL>]<EOL>for sdict in sdicts:<EOL><INDENT>prefix = list(sdict.keys())[<NUM_LIT:0>]<EOL>suffix = sdict[prefix]<EOL>if item.startswith(prefix):<EOL><INDENT>if prefix == "<STR_LIT>":<EOL><INDENT>return item[<NUM_LIT:2>:]<EOL><DEDENT>if prefix == "<STR_LIT>":<EOL><INDENT>return suffix + item[<NUM_LIT:2>:]<EOL><DEDENT>if prefix in ["<STR_LIT:>>", "<STR_LIT:<>"]:<EOL><INDENT>return suffix + item[<NUM_LIT:1>:]<EOL><DEDENT>return item[<NUM_LIT:2>:] + suffix<EOL><DEDENT><DEDENT>raise RuntimeError("<STR_LIT>")<EOL>


pyvers = ["<STR_LIT>".format(item.replace("<STR_LIT:.>", "<STR_LIT>")) for item in get_supported_interps()]<EOL>py2vers = sorted([item for item in pyvers if item.startswith("<STR_LIT>")])<EOL>py3vers = sorted([item for item in pyvers if item.startswith("<STR_LIT>")])<EOL>fdict = json_load(os.path.join("<STR_LIT:data>", "<STR_LIT>"))<EOL>olines = ["<STR_LIT>"]<EOL>sdict = dict([(item["<STR_LIT:name>"], item) for item in fdict.values()])<EOL>for real_name in sorted(sdict.keys()):<EOL><INDENT>pkg_dict = sdict[real_name]<EOL>if pkg_dict["<STR_LIT>"] == ["<STR_LIT>"]:<EOL><INDENT>continue<EOL><DEDENT>plist = [] if not pkg_dict["<STR_LIT>"] else ["<STR_LIT>"]<EOL>if isinstance(pkg_dict["<STR_LIT>"], str):<EOL><INDENT>pkg_dict["<STR_LIT>"] = dict([(pyver, pkg_dict["<STR_LIT>"]) for pyver in pyvers])<EOL><DEDENT>pkg_pyvers = sorted(pkg_dict["<STR_LIT>"].keys())<EOL>pkg_py2vers = sorted(<EOL>[item for item in pkg_dict["<STR_LIT>"].keys() if item.startswith("<STR_LIT>")]<EOL>)<EOL>req_vers = list(set(pkg_dict["<STR_LIT>"].values()))<EOL>req_py2vers = list(<EOL>set([pkg_dict["<STR_LIT>"][item] for item in py2vers if item in pkg_dict["<STR_LIT>"]])<EOL>)<EOL>req_py3vers = list(<EOL>set([pkg_dict["<STR_LIT>"][item] for item in py3vers if item in pkg_dict["<STR_LIT>"]])<EOL>)<EOL>if (len(req_vers) == <NUM_LIT:1>) and (pkg_pyvers == pyvers):<EOL><INDENT>plist.append(ops_to_words(req_vers[<NUM_LIT:0>]))<EOL><DEDENT>elif (<EOL>(pkg_pyvers == pyvers)<EOL>and (len(req_py2vers) == <NUM_LIT:1>)<EOL>and (len(req_py3vers) == <NUM_LIT:1>)<EOL>):<EOL><INDENT>make_common_entry(plist, "<STR_LIT:2>", "<STR_LIT>", req_py2vers[<NUM_LIT:0>])<EOL>make_common_entry(plist, "<STR_LIT:3>", "<STR_LIT>", req_py3vers[<NUM_LIT:0>])<EOL><DEDENT>elif (<EOL>(pkg_pyvers == pyvers)<EOL>and (len(req_py2vers) == len(py2vers))<EOL>and (len(req_py3vers) == <NUM_LIT:1>)<EOL>and (pkg_dict["<STR_LIT>"][pkg_py2vers[-<NUM_LIT:1>]] == req_py3vers[<NUM_LIT:0>])<EOL>):<EOL><INDENT>py2dict = dict(<EOL>[<EOL>(key, value)<EOL>for key, value in pkg_dict["<STR_LIT>"].items()<EOL>if key.startswith("<STR_LIT>") and (key != pkg_py2vers[-<NUM_LIT:1>])<EOL>]<EOL>)<EOL>make_multi_entry(plist, py2vers[:-<NUM_LIT:1>], py2dict)<EOL>pver = pkg_py2vers[-<NUM_LIT:1>][<NUM_LIT:2>] + "<STR_LIT:.>" + pkg_py2vers[-<NUM_LIT:1>][<NUM_LIT:3>:]<EOL>plist.append(<EOL>"<STR_LIT>".format(<EOL>pyver=pver, ver=ops_to_words(req_py3vers[<NUM_LIT:0>])<EOL>)<EOL>)<EOL><DEDENT>elif (<EOL>(pkg_pyvers == pyvers)<EOL>and (len(req_py2vers) == len(py2vers))<EOL>and (len(req_py3vers) == <NUM_LIT:1>)<EOL>):<EOL><INDENT>py2dict = dict(<EOL>[<EOL>(key, value)<EOL>for key, value in pkg_dict["<STR_LIT>"].items()<EOL>if key.startswith("<STR_LIT>")<EOL>]<EOL>)<EOL>make_multi_entry(plist, py2vers, py2dict)<EOL>make_common_entry(plist, "<STR_LIT:3>", "<STR_LIT>", req_py3vers[<NUM_LIT:0>])<EOL><DEDENT>elif (<EOL>(pkg_pyvers == pyvers)<EOL>and (len(req_py3vers) == len(py3vers))<EOL>and (len(req_py2vers) == <NUM_LIT:1>)<EOL>):<EOL><INDENT>py3dict = dict(<EOL>[<EOL>(key, value)<EOL>for key, value in pkg_dict["<STR_LIT>"].items()<EOL>if key.startswith("<STR_LIT>")<EOL>]<EOL>)<EOL>make_common_entry(plist, "<STR_LIT:2>", "<STR_LIT>", req_py2vers[<NUM_LIT:0>])<EOL>make_multi_entry(plist, py3vers, py3dict)<EOL><DEDENT>elif (len(req_vers) == <NUM_LIT:1>) and (pkg_pyvers == py2vers):<EOL><INDENT>make_common_entry(plist, "<STR_LIT:2>", "<STR_LIT>", req_vers[<NUM_LIT:0>])<EOL><DEDENT>elif (len(req_vers) == <NUM_LIT:1>) and (pkg_pyvers == py3vers):<EOL><INDENT>make_common_entry(plist, "<STR_LIT:3>", "<STR_LIT>", req_vers[<NUM_LIT:0>])<EOL><DEDENT>else:<EOL><INDENT>make_multi_entry(plist, pkg_pyvers, pkg_dict["<STR_LIT>"])<EOL><DEDENT>olines.append(<EOL>"<STR_LIT>".format(<EOL>name=pkg_dict["<STR_LIT:name>"], par="<STR_LIT:U+002CU+0020>".join(plist)<EOL>)<EOL>)<EOL><DEDENT>ret = []<EOL>for line in olines:<EOL><INDENT>wobj = textwrap.wrap(line, width=LINE_WIDTH, subsequent_indent="<STR_LIT:U+0020>")<EOL>ret.append("<STR_LIT:\n>".join([item for item in wobj]))<EOL><DEDENT>mobj.out("<STR_LIT>".join(ret) + "<STR_LIT>")<EOL>

Get requirements in reStructuredText format.


mname = "<STR_LIT>"<EOL>fname = "<STR_LIT>"<EOL>module_prefix = "<STR_LIT>".format(mname)<EOL>callable_names = (<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>"<STR_LIT>",<EOL>)<EOL>return docs.support.trace_support.run_trace(<EOL>mname, fname, module_prefix, callable_names, no_print<EOL>)<EOL>


def incfile(fname, fpointer, lrange="<STR_LIT>", sdir=None):

<EOL>file_dir = (<EOL>sdir<EOL>if sdir<EOL>else os.environ.get("<STR_LIT>", os.path.abspath(os.path.dirname(__file__)))<EOL>)<EOL>fname = os.path.join(file_dir, fname)<EOL>with open(fname) as fobj:<EOL><INDENT>lines = fobj.readlines()<EOL><DEDENT>tokens = [item.strip() for item in lrange.split("<STR_LIT:U+002C>")]<EOL>inc_lines = []<EOL>for token in tokens:<EOL><INDENT>if "<STR_LIT:->" in token:<EOL><INDENT>subtokens = token.split("<STR_LIT:->")<EOL>lmin, lmax = (<EOL>int(subtokens[<NUM_LIT:0>]),<EOL>int(subtokens[<NUM_LIT:1>]) if subtokens[<NUM_LIT:1>] else len(lines),<EOL>)<EOL>for num in range(lmin, lmax + <NUM_LIT:1>):<EOL><INDENT>inc_lines.append(num)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>inc_lines.append(int(token))<EOL><DEDENT><DEDENT>fpointer("<STR_LIT>")<EOL>fpointer("<STR_LIT:\n>")<EOL>for num, line in enumerate(lines):<EOL><INDENT>if num + <NUM_LIT:1> in inc_lines:<EOL><INDENT>fpointer("<STR_LIT:U+0020>" + line.replace("<STR_LIT:\t>", "<STR_LIT:U+0020>") if line.strip() else "<STR_LIT:\n>")<EOL><DEDENT><DEDENT>fpointer("<STR_LIT:\n>")<EOL>

r"""
    Include a Python source file in a docstring formatted in reStructuredText.

    :param fname: File name, relative to environment variable
                  :bash:`${TRACER_DIR}`
    :type  fname: string

    :param fpointer: Output function pointer. Normally is :code:`cog.out` but
                     :code:`print` or other functions can be used for
                     debugging
    :type  fpointer: function object

    :param lrange: Line range to include, similar to Sphinx
                   `literalinclude <http://sphinx-doc.org/markup/code.html
                   #directive-literalinclude>`_ directive
    :type  lrange: string

    :param sdir: Source file directory. If None the :bash:`${TRACER_DIR}`
                 environment variable is used if it is defined, otherwise
                 the directory where the :code:`docs.support.incfile` module
                 is located is used
    :type  sdir: string

    For example:

    .. code-block:: python

        def func():
            \"\"\"
            This is a docstring. This file shows how to use it:

            .. =[=cog
            .. import docs.support.incfile
            .. docs.support.incfile.incfile('func_example.py', cog.out)
            .. =]=
            .. code-block:: python

                # func_example.py
                if __name__ == '__main__':
                    func()

            .. =[=end=]=
            \"\"\"
            return 'This is func output'


def filter_glyph_names( alist, filter ):

count  = <NUM_LIT:0><EOL>extras = []<EOL>for name in alist:<EOL><INDENT>try:<EOL><INDENT>filtered_index = filter.index( name )<EOL><DEDENT>except:<EOL><INDENT>extras.append( name )<EOL><DEDENT><DEDENT>return extras<EOL>

filter `alist' by taking _out_ all glyph names that are in `filter


self.reset()<EOL>self.sections = {}    <EOL>self.section  = None  <EOL>self.chapters = []    <EOL>self.headers  = {}<EOL>


line = "<STR_LIT>"<EOL>if words:<EOL><INDENT>line = html_quote( words[<NUM_LIT:0>] )<EOL>for w in words[<NUM_LIT:1>:]:<EOL><INDENT>line = line + "<STR_LIT:U+0020>" + html_quote( w )<EOL><DEDENT><DEDENT>return line<EOL>

convert a series of simple words into some HTML text


<EOL>m = re_crossref.match( word )<EOL>if m:<EOL><INDENT>try:<EOL><INDENT>name = m.group( <NUM_LIT:1> )<EOL>rest = m.group( <NUM_LIT:2> )<EOL>block = self.identifiers[name]<EOL>url   = self.make_block_url( block )<EOL>return '<STR_LIT>' + url + '<STR_LIT>' + name + '<STR_LIT>' + rest<EOL><DEDENT>except:<EOL><INDENT>sys.stderr.write("<STR_LIT>" + name + "<STR_LIT>" )<EOL>return '<STR_LIT:?>' + name + '<STR_LIT:?>' + rest<EOL><DEDENT><DEDENT>m = re_italic.match( word )<EOL>if m:<EOL><INDENT>name = m.group( <NUM_LIT:1> )<EOL>rest = m.group( <NUM_LIT:3> )<EOL>return '<STR_LIT>' + name + '<STR_LIT>' + rest<EOL><DEDENT>m = re_bold.match( word )<EOL>if m:<EOL><INDENT>name = m.group( <NUM_LIT:1> )<EOL>rest = m.group( <NUM_LIT:3> )<EOL>return '<STR_LIT>' + name + '<STR_LIT>' + rest<EOL><DEDENT>return html_quote( word )<EOL>

analyze a simple word to detect cross-references and styling


result = <NUM_LIT:1><EOL>try:<EOL><INDENT>file = open( pathname, "<STR_LIT:r>" )<EOL>file.close()<EOL><DEDENT>except:<EOL><INDENT>result = None<EOL>sys.stderr.write( pathname + "<STR_LIT>" )<EOL><DEDENT>return result<EOL>


global output_dir<EOL>try:<EOL><INDENT>opts, args = getopt.getopt( sys.argv[<NUM_LIT:1>:],"<STR_LIT>",["<STR_LIT>", "<STR_LIT>", "<STR_LIT>", "<STR_LIT>"] )<EOL><DEDENT>except getopt.GetoptError:<EOL><INDENT>usage()<EOL>sys.exit( <NUM_LIT:2> )<EOL><DEDENT>if args == []:<EOL><INDENT>usage()<EOL>sys.exit( <NUM_LIT:1> )<EOL><DEDENT>project_title  = "<STR_LIT>"<EOL>project_prefix = None<EOL>output_dir     = None<EOL>for opt in opts:<EOL><INDENT>if opt[<NUM_LIT:0>] in ( "<STR_LIT>", "<STR_LIT>" ):<EOL><INDENT>usage()<EOL>sys.exit( <NUM_LIT:0> )<EOL><DEDENT>if opt[<NUM_LIT:0>] in ( "<STR_LIT>", "<STR_LIT>" ):<EOL><INDENT>project_title = opt[<NUM_LIT:1>]<EOL><DEDENT>if opt[<NUM_LIT:0>] in ( "<STR_LIT>", "<STR_LIT>" ):<EOL><INDENT>utils.output_dir = opt[<NUM_LIT:1>]<EOL><DEDENT>if opt[<NUM_LIT:0>] in ( "<STR_LIT>", "<STR_LIT>" ):<EOL><INDENT>project_prefix = opt[<NUM_LIT:1>]<EOL><DEDENT><DEDENT>check_output()<EOL>source_processor  = SourceProcessor()<EOL>content_processor = ContentProcessor()<EOL>file_list = make_file_list( args )<EOL>for filename in file_list:<EOL><INDENT>source_processor.parse_file( filename )<EOL>content_processor.parse_sources( source_processor )<EOL><DEDENT>content_processor.finish()<EOL>formatter = HtmlFormatter( content_processor, project_title, project_prefix )<EOL>formatter.toc_dump()<EOL>formatter.index_dump()<EOL>formatter.section_dump_all()<EOL>


return (axis & self._supported_axes_mask) != <NUM_LIT:0><EOL>

Returns ``True`` if the controller has the requested axis, a value of enumeration :class:`ControllerAxes`.


return self._buttons & ControllerButtons.action_left<EOL>

``True`` if the left action button ("X" on Xbox 360) is pressed.  Available only on game controllers with
        the ``standard`` or ``extended`` profiles.


return self.get_axis(ControllerAxes.right_trigger)<EOL>

The absolute right trigger value, between 0.0 and 1.0.  Available only on game controllers with the
        ``extended`` profile.


return self._controller_index<EOL>

The index of the controller, between 0 and 4 (read-only).  Typically this is assigned in the order the
        controllers are detected, however some controllers may have an intrinsic "player number" that is exposed
        through this number.  No two controllers will have the same controller index.


return (button & self._supported_buttons_mask) != <NUM_LIT:0><EOL>

Returns ``True`` if the controller has the requested button, a value of enumeration :class:`ControllerButtons`.


return self.get_axis(ControllerAxes.left_thumb_x)<EOL>

The absolute X axis value of the left thumb-stick, or the main stick on a joystick.


return self._buttons & ControllerButtons.action_up<EOL>

``True`` if the up action button ("Y" on Xbox 360) is pressed.  Available only on game controllers with
        the ``standard`` or ``extended`` profiles.


return self._height<EOL>

The height of the image, in texels (read-only).


lib.SetTransform((c_float * <NUM_LIT:16>)(*matrix))<EOL>

Replace the current graphics transform with the given 4x4 matrix.  For example, to replace
    the transform with a translation by ``(x, y)``::

        bacon.set_transform([1, 0, 0, x,
                             0, 1, 0, y,
                             0, 0, 1, 0,
                             0, 0, 0, 1])

    :param matrix: a 4x4 matrix in column major order, represented as a flat 16 element sequence.


return self.button_mask & (<NUM_LIT:1> << <NUM_LIT:2>)<EOL>

``True`` if the right mouse button is currently pressed.


Start running the game.  The window is created and shown at this point, and then
    the main event loop is entered.  'game.on_tick' and other event handlers are called
    repeatedly until the game exits.

    If a game is already running, this function replaces the :class:`Game` instance that
    receives events.


pass<EOL>

Called when a game controller is disconnected.  You should use the `controller` parameter only
        to identify a previously used controller; its properties and values will no longer be available.

        :param controller: the :class:`Controller` that was disconnected


clear(<NUM_LIT:1>, <NUM_LIT:0>, <NUM_LIT:1>, <NUM_LIT:1>)<EOL>

Called once per frame to update and render the game.  You may only call
        drawing functions within the scope of this method.


def on_controller_axis(self, controller, axis, value):

pass<EOL>

Called when an axis on a game controller is moved.

        :param controller: the :class:`Controller` containing the axis
        :param button: axis index, of :class:`ControllerAxes` enumeration
        :param value: absolute position of the axis, between ``-1.0`` and ``1.0``


def on_controller_button(self, controller, button, pressed):

pass<EOL>

Called when a button on a game controller is pressed or released.

        :param controller: the :class:`Controller` containing the button
        :param button: button index, of :class:`ControllerButtons` enumeration
        :param pressed: ``True`` if the button was pressed, otherwise ``False``


def draw_string(font, text, x, y, width=None, height=None, align=Alignment.left, vertical_align=VerticalAlignment.baseline):

style = Style(font)<EOL>run = GlyphRun(style, text)<EOL>glyph_layout = GlyphLayout([run], x, y, width, height, align, vertical_align)<EOL>draw_glyph_layout(glyph_layout)<EOL>

Draw a string with the given font.

    :note: Text alignment and word-wrapping is not yet implemented.  The text is rendered with the left edge and
        baseline at ``(x, y)``.

    :param font: the :class:`Font` to render text with
    :param text: a string of text to render.


return self._fragment_source<EOL>

Get the fragment shader source

        :type: ``str``


return self._vertex_source<EOL>

Get the vertex shader source

        :type: ``str``


return self._metrics<EOL>

Retrieves the pixel-space design metrics of the font.

        :return: :class:`FontMetrics`


return self._ascent<EOL>

Ascent of the font above the baseline, in pixels; typically negative


return [self.get_glyph(c) for c in str]<EOL>

Retrieves a list of :class:`Glyph` for the given string.

        :param str: the string to render


def arc_distance(theta_1, phi_1, theta_2, phi_2):

temp = (np.sin((theta_2-theta_1)/<NUM_LIT:2>)**<NUM_LIT:2><EOL>+ np.cos(theta_1)*np.cos(theta_2) * np.sin((phi_2-phi_1)/<NUM_LIT:2>)**<NUM_LIT:2>)<EOL>distance_matrix = <NUM_LIT:2> * np.arctan2(np.sqrt(temp), np.sqrt(<NUM_LIT:1>-temp))<EOL>return distance_matrix<EOL>

Calculates the pairwise arc distance
between all points in vector a and b.


def export_hdf5_v1(dataset, path, column_names=None, byteorder="<STR_LIT:=>", shuffle=False, selection=False, progress=None, virtual=True):

if selection:<EOL><INDENT>if selection == True:  <EOL><INDENT>selection = "<STR_LIT:default>"<EOL><DEDENT><DEDENT>with h5py.File(path, "<STR_LIT:w>") as h5file_output:<EOL><INDENT>h5data_output = h5file_output.require_group("<STR_LIT:data>")<EOL>N = len(dataset) if not selection else dataset.selected_length(selection)<EOL>if N == <NUM_LIT:0>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>logger.debug("<STR_LIT>", virtual)<EOL>logger.debug("<STR_LIT>" % (N, path))<EOL>column_names = column_names or dataset.get_column_names(virtual=virtual, strings=True)<EOL>logger.debug("<STR_LIT>" % column_names)<EOL>for column_name in column_names:<EOL><INDENT>dtype = dataset.dtype(column_name)<EOL>if column_name in dataset.get_column_names(strings=True):<EOL><INDENT>column = dataset.columns[column_name]<EOL>shape = (N,) + column.shape[<NUM_LIT:1>:]<EOL><DEDENT>else:<EOL><INDENT>shape = (N,)<EOL><DEDENT>if dtype.type == np.datetime64:<EOL><INDENT>array = h5file_output.require_dataset("<STR_LIT>" % column_name, shape=shape, dtype=np.int64)<EOL>array.attrs["<STR_LIT>"] = dtype.name<EOL><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>array = h5file_output.require_dataset("<STR_LIT>" % column_name, shape=shape, dtype=dtype.newbyteorder(byteorder))<EOL><DEDENT>except:<EOL><INDENT>logging.exception("<STR_LIT>" % (column_name, dtype))<EOL><DEDENT><DEDENT>array[<NUM_LIT:0>] = array[<NUM_LIT:0>]  <EOL><DEDENT>random_index_name = None<EOL>column_order = list(column_names)  <EOL>if shuffle:<EOL><INDENT>random_index_name = "<STR_LIT>"<EOL>while random_index_name in dataset.get_column_names():<EOL><INDENT>random_index_name += "<STR_LIT>"<EOL><DEDENT>shuffle_array = h5file_output.require_dataset("<STR_LIT>" + random_index_name, shape=(N,), dtype=byteorder + "<STR_LIT>")<EOL>shuffle_array[<NUM_LIT:0>] = shuffle_array[<NUM_LIT:0>]<EOL>column_order.append(random_index_name)  <EOL><DEDENT>h5data_output.attrs["<STR_LIT>"] = "<STR_LIT:U+002C>".join(column_order)  <EOL><DEDENT>dataset_output = vaex.hdf5.dataset.Hdf5MemoryMapped(path, write=True)<EOL>column_names = vaex.export._export(dataset_input=dataset, dataset_output=dataset_output, path=path, random_index_column=random_index_name,<EOL>column_names=column_names, selection=selection, shuffle=shuffle, byteorder=byteorder,<EOL>progress=progress)<EOL>import getpass<EOL>import datetime<EOL>user = getpass.getuser()<EOL>date = str(datetime.datetime.now())<EOL>source = dataset.path<EOL>description = "<STR_LIT>" % (user, date, source)<EOL>if dataset.description:<EOL><INDENT>description += "<STR_LIT>" + dataset.description<EOL><DEDENT>dataset_output.copy_metadata(dataset)<EOL>dataset_output.description = description<EOL>logger.debug("<STR_LIT>")<EOL>dataset_output.write_meta()<EOL>dataset_output.close_files()<EOL>return<EOL>

:param DatasetLocal dataset: dataset to export
:param str path: path for file
:param lis[str] column_names: list of column names to export or None for all columns
:param str byteorder: = for native, < for little endian and > for big endian
:param bool shuffle: export rows in random order
:param bool selection: export selection or not
:param progress: progress callback that gets a progress fraction as argument and should return True to continue,
        or a default progress bar when progress=True
:param: bool virtual: When True, export virtual columns
:return:


with h5py.File(self.filename, "<STR_LIT>") as h5file_output:<EOL><INDENT>h5table_root = h5file_output[self.h5table_root_name]<EOL>if self.description is not None:<EOL><INDENT>h5table_root.attrs["<STR_LIT:description>"] = self.description<EOL><DEDENT>h5columns = h5table_root if self._version == <NUM_LIT:1> else h5table_root['<STR_LIT>']<EOL>for column_name in self.columns.keys():<EOL><INDENT>h5dataset = None<EOL>if column_name in h5columns:<EOL><INDENT>h5dataset = h5columns[column_name]<EOL><DEDENT>else:<EOL><INDENT>for group in h5columns.values():<EOL><INDENT>if '<STR_LIT:type>' in group.attrs:<EOL><INDENT>if group.attrs['<STR_LIT:type>'] in ['<STR_LIT>']: <EOL><INDENT>for name, column in group.items():<EOL><INDENT>if name == column_name:<EOL><INDENT>h5dataset = column<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>if h5dataset is None:<EOL><INDENT>raise ValueError('<STR_LIT>'.format(column_name))<EOL><DEDENT>for name, values in [("<STR_LIT>", self.ucds), ("<STR_LIT>", self.units), ("<STR_LIT:description>", self.descriptions)]:<EOL><INDENT>if column_name in values:<EOL><INDENT>value = ensure_string(values[column_name], cast=True)<EOL>h5dataset.attrs[name] = value<EOL><DEDENT>else:<EOL><INDENT>if name in h5columns.attrs:<EOL><INDENT>del h5dataset.attrs[name]<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>

ucds, descriptions and units are written as attributes in the hdf5 file, instead of a seperate file as
         the default :func:`Dataset.write_meta`.


column = _ensure_string_from_expression(column)<EOL>new_name = self._find_valid_name('<STR_LIT>' + column)<EOL>self._rename(column, new_name)<EOL>

Hides a column by prefixing the name with \'__\


names = _ensure_strings_from_expressions(columns)<EOL>virtual_columns = self._expr(*columns, always_list=True)<EOL>if depending_variables is None:<EOL><INDENT>depending_variables = set()<EOL>for expression in virtual_columns:<EOL><INDENT>depending_variables |= expression.variables()<EOL><DEDENT>depending_variables = list(sorted(list(depending_variables)))<EOL><DEDENT>fs = [self[self.virtual_columns[name]] for name in names]<EOL>jacobian = self._jacobian(fs, depending_variables)<EOL>m = len(fs)<EOL>n = len(depending_variables)<EOL>cov_matrix = self._covariance_matrix_guess(depending_variables, full=cov_matrix == "<STR_LIT>", as_expression=True)<EOL>cov_matrix_out = [[self['<STR_LIT:0>'] for __ in range(m)] for __ in range(m)]<EOL>for i in range(m):<EOL><INDENT>for j in range(m):<EOL><INDENT>for k in range(n):<EOL><INDENT>for l in range(n):<EOL><INDENT>if jacobian[i][k].expression == '<STR_LIT:0>' or jacobian[j][l].expression == '<STR_LIT:0>' or cov_matrix[k][l].expression == '<STR_LIT:0>':<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>cov_matrix_out[i][j] = cov_matrix_out[i][j] + jacobian[i][k] * cov_matrix[k][l] * jacobian[j][l]<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>for i in range(m):<EOL><INDENT>for j in range(i + <NUM_LIT:1>):<EOL><INDENT>sigma = cov_matrix_out[i][j]<EOL>sigma = self._expr(vaex.expresso.simplify(_ensure_string_from_expression(sigma)))<EOL>if i != j:<EOL><INDENT>self.add_virtual_column(covariance_format.format(names[i], names[j]), sigma)<EOL><DEDENT>else:<EOL><INDENT>self.add_virtual_column(uncertainty_format.format(names[i]), np.sqrt(sigma))<EOL><DEDENT><DEDENT><DEDENT>

Propagates uncertainties (full covariance matrix) for a set of virtual columns.

        Covariance matrix of the depending variables is guessed by finding columns prefixed by "e"
        or `"e_"` or postfixed by "_error", "_uncertainty", "e" and `"_e"`.
        Off diagonals (covariance or correlation) by postfixes with "_correlation" or "_corr" for
        correlation or "_covariance" or "_cov" for covariances.
        (Note that x_y_cov = x_e * y_e * x_y_correlation.)

        Example

        >>> df = vaex.from_scalars(x=1, y=2, e_x=0.1, e_y=0.2)
        >>> df["u"] = df.x + df.y
        >>> df["v"] = np.log10(df.x)
        >>> df.propagate_uncertainties([df.u, df.v])
        >>> df.u_uncertainty, df.v_uncertainty

        :param columns: list of columns for which to calculate the covariance matrix.
        :param depending_variables: If not given, it is found out automatically, otherwise a list of columns which have uncertainties.
        :param cov_matrix: List of list with expressions giving the covariance matrix, in the same order as depending_variables. If 'full' or 'auto',
            the covariance matrix for the depending_variables will be guessed, where 'full' gives an error if an entry was not found.


@vaex.utils.deprecated('<STR_LIT>')<EOL><INDENT>def _hstack(self, other, prefix=None):<DEDENT>

assert len(self) == len(other), "<STR_LIT>"<EOL>for name in other.get_column_names():<EOL><INDENT>if prefix:<EOL><INDENT>new_name = prefix + name<EOL><DEDENT>else:<EOL><INDENT>new_name = name<EOL><DEDENT>self.add_column(new_name, other.columns[name])<EOL><DEDENT>

Join the columns of the other DataFrame to this one, assuming the ordering is the same


@docsubst<EOL><INDENT>@stat_1d<EOL>def minmax(self, expression, binby=[], limits=None, shape=default_shape, selection=False, delay=False, progress=None):<DEDENT>

<EOL>@delayed<EOL>def finish(*minmax_list):<EOL><INDENT>value = vaex.utils.unlistify(waslist, np.array(minmax_list))<EOL>value = value.astype(dtype0)<EOL>return value<EOL><DEDENT>@delayed<EOL>def calculate(expression, limits):<EOL><INDENT>task = tasks.TaskStatistic(self, binby, shape, limits, weight=expression, op=tasks.OP_MIN_MAX, selection=selection)<EOL>self.executor.schedule(task)<EOL>progressbar.add_task(task, "<STR_LIT>" % expression)<EOL>return task<EOL><DEDENT>@delayed<EOL>def finish(*minmax_list):<EOL><INDENT>value = vaex.utils.unlistify(waslist, np.array(minmax_list))<EOL>value = value.astype(dtype0)<EOL>return value<EOL><DEDENT>expression = _ensure_strings_from_expressions(expression)<EOL>binby = _ensure_strings_from_expressions(binby)<EOL>waslist, [expressions, ] = vaex.utils.listify(expression)<EOL>dtypes = [self.dtype(expr) for expr in expressions]<EOL>dtype0 = dtypes[<NUM_LIT:0>]<EOL>if not all([k.kind == dtype0.kind for k in dtypes]):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>progressbar = vaex.utils.progressbars(progress, name="<STR_LIT>")<EOL>limits = self.limits(binby, limits, selection=selection, delay=True)<EOL>all_tasks = [calculate(expression, limits) for expression in expressions]<EOL>result = finish(*all_tasks)<EOL>return self._delay(delay, result)<EOL>

Calculate the minimum and maximum for expressions, possibly on a grid defined by binby.

        Example:

        >>> df.minmax("x")
        array([-128.293991,  271.365997])
        >>> df.minmax(["x", "y"])
        array([[-128.293991 ,  271.365997 ],
                   [ -71.5523682,  146.465836 ]])
        >>> df.minmax("x", binby="x", shape=5, limits=[-10, 10])
        array([[-9.99919128, -6.00010443],
                   [-5.99972439, -2.00002384],
                   [-1.99991322,  1.99998057],
                   [ 2.0000093 ,  5.99983597],
                   [ 6.0004878 ,  9.99984646]])

        :param expression: {expression}
        :param binby: {binby}
        :param limits: {limits}
        :param shape: {shape}
        :param selection: {selection}
        :param delay: {delay}
        :param progress: {progress}
        :return: {return_stat_scalar}, the last dimension is of shape (2)


def dtype(self, expression, internal=False):

expression = _ensure_string_from_expression(expression)<EOL>if expression in self.variables:<EOL><INDENT>return np.float64(<NUM_LIT:1>).dtype<EOL><DEDENT>elif expression in self.columns.keys():<EOL><INDENT>column = self.columns[expression]<EOL>data = column[<NUM_LIT:0>:<NUM_LIT:1>]<EOL>dtype = data.dtype<EOL><DEDENT>else:<EOL><INDENT>data = self.evaluate(expression, <NUM_LIT:0>, <NUM_LIT:1>, filtered=False)<EOL>dtype = data.dtype<EOL><DEDENT>if not internal:<EOL><INDENT>if dtype != str_type:<EOL><INDENT>if dtype.kind in '<STR_LIT>':<EOL><INDENT>return str_type<EOL><DEDENT>if dtype.kind == '<STR_LIT:O>':<EOL><INDENT>if isinstance(data[<NUM_LIT:0>], six.string_types):<EOL><INDENT>return str_type<EOL><DEDENT><DEDENT><DEDENT><DEDENT>return dtype<EOL>

Return the numpy dtype for the given expression, if not a column, the first row will be evaluated to get the dtype.


@docsubst<EOL><INDENT>@stat_1d<EOL>def sum(self, expression, binby=[], limits=None, shape=default_shape, selection=False, delay=False, progress=None, edges=False):<DEDENT>

return self._compute_agg('<STR_LIT>', expression, binby, limits, shape, selection, delay, edges, progress)<EOL>@delayed<EOL>def finish(*sums):<EOL><INDENT>return vaex.utils.unlistify(waslist, sums)<EOL><DEDENT>expression = _ensure_strings_from_expressions(expression)<EOL>binby = _ensure_strings_from_expressions(binby)<EOL>waslist, [expressions, ] = vaex.utils.listify(expression)<EOL>progressbar = vaex.utils.progressbars(progress)<EOL>limits = self.limits(binby, limits, delay=True)<EOL>sums = [self._sum_calculation(expression, binby=binby, limits=limits, shape=shape, selection=selection, progressbar=progressbar) for expression in expressions]<EOL>s = finish(*sums)<EOL>return self._delay(delay, s)<EOL>

Calculate the sum for the given expression, possible on a grid defined by binby

        Example:

        >>> df.sum("L")
        304054882.49378014
        >>> df.sum("L", binby="E", shape=4)
        array([  8.83517994e+06,   5.92217598e+07,   9.55218726e+07,
                         1.40008776e+08])

        :param expression: {expression}
        :param binby: {binby}
        :param limits: {limits}
        :param shape: {shape}
        :param selection: {selection}
        :param delay: {delay}
        :param progress: {progress}
        :return: {return_stat_scalar}


raise NotImplementedError<EOL>

Returns the number of rows that are selected.


def evaluate(self, expression, i1=None, i2=None, out=None, selection=None, filtered=True, internal=False):

expression = _ensure_string_from_expression(expression)<EOL>selection = _ensure_strings_from_expressions(selection)<EOL>i1 = i1 or <NUM_LIT:0><EOL>i2 = i2 or (len(self) if (self.filtered and filtered) else self.length_unfiltered())<EOL>mask = None<EOL>if self.filtered and filtered:  <EOL><INDENT>indices = self._filtered_range_to_unfiltered_indices(i1, i2)<EOL>i1 = indices[<NUM_LIT:0>]<EOL>i2 = indices[-<NUM_LIT:1>] + <NUM_LIT:1>  <EOL><DEDENT>if selection is not None or (self.filtered and filtered):<EOL><INDENT>mask = self.evaluate_selection_mask(selection, i1, i2)<EOL><DEDENT>scope = scopes._BlockScope(self, i1, i2, mask=mask, **self.variables)<EOL>if out is not None:<EOL><INDENT>scope.buffers[expression] = out<EOL><DEDENT>value = scope.evaluate(expression)<EOL>if isinstance(value, ColumnString) and not internal:<EOL><INDENT>value = value.to_numpy()<EOL><DEDENT>return value<EOL>

The local implementation of :func:`DataFrame.evaluate`


@docsubst<EOL><INDENT>def to_dict(self, column_names=None, selection=None, strings=True, virtual=False):<DEDENT>

return dict(self.to_items(column_names=column_names, selection=selection, strings=strings, virtual=virtual))<EOL>

Return a dict containing the ndarray corresponding to the evaluated data

        :param column_names: list of column names, to export, when None DataFrame.get_column_names(strings=strings, virtual=virtual) is used
        :param selection: {selection}
        :param strings: argument passed to DataFrame.get_column_names when column_names is None
        :param virtual: argument passed to DataFrame.get_column_names when column_names is None
        :return: dict


@_hidden<EOL><INDENT>def add_virtual_columns_cartesian_to_spherical(self, x="<STR_LIT:x>", y="<STR_LIT:y>", z="<STR_LIT:z>", alpha="<STR_LIT:l>", delta="<STR_LIT:b>", distance="<STR_LIT>", radians=False, center=None, center_name="<STR_LIT>"):<DEDENT>

transform = "<STR_LIT>" if radians else "<STR_LIT>"<EOL>if center is not None:<EOL><INDENT>self.add_variable(center_name, center)<EOL><DEDENT>if center is not None and center[<NUM_LIT:0>] != <NUM_LIT:0>:<EOL><INDENT>x = "<STR_LIT>".format(**locals())<EOL><DEDENT>if center is not None and center[<NUM_LIT:1>] != <NUM_LIT:0>:<EOL><INDENT>y = "<STR_LIT>".format(**locals())<EOL><DEDENT>if center is not None and center[<NUM_LIT:2>] != <NUM_LIT:0>:<EOL><INDENT>z = "<STR_LIT>".format(**locals())<EOL><DEDENT>self.add_virtual_column(distance, "<STR_LIT>".format(**locals()))<EOL>self.add_virtual_column(alpha, "<STR_LIT>".format(**locals()))<EOL>self.add_virtual_column(delta, "<STR_LIT>".format(**locals()))<EOL>

Convert cartesian to spherical coordinates.

        :param x:
        :param y:
        :param z:
        :param alpha:
        :param delta: name for polar angle, ranges from -90 to 90 (or -pi to pi when radians is True).
        :param distance:
        :param radians:
        :param center:
        :param center_name:
        :return:


if isinstance(item, int):<EOL><INDENT>names = self.get_column_names()<EOL>return [self.evaluate(name, item, item+<NUM_LIT:1>)[<NUM_LIT:0>] for name in names]<EOL><DEDENT>elif isinstance(item, six.string_types):<EOL><INDENT>if hasattr(self, item) and isinstance(getattr(self, item), Expression):<EOL><INDENT>return getattr(self, item)<EOL><DEDENT>return Expression(self, item)  <EOL><DEDENT>elif isinstance(item, Expression):<EOL><INDENT>expression = item.expression<EOL>df = self.copy()<EOL>df.select(expression, name=FILTER_SELECTION_NAME, mode='<STR_LIT>')<EOL>return df<EOL><DEDENT>elif isinstance(item, (tuple, list)):<EOL><INDENT>df = self.copy(column_names=item)<EOL>return df<EOL><DEDENT>elif isinstance(item, slice):<EOL><INDENT>df = self.extract()<EOL>start, stop, step = item.start, item.stop, item.step<EOL>start = start or <NUM_LIT:0><EOL>stop = stop or len(df)<EOL>assert step in [None, <NUM_LIT:1>]<EOL>df.set_active_range(start, stop)<EOL>return df.trim()<EOL><DEDENT>

Convenient way to get expressions, (shallow) copies of a few columns, or to apply filtering.

        Example:

        >>> df['Lz']  # the expression 'Lz
        >>> df['Lz/2'] # the expression 'Lz/2'
        >>> df[["Lz", "E"]] # a shallow copy with just two columns
        >>> df[df.Lz < 0]  # a shallow copy with the filter Lz < 0 applied


@docsubst<EOL><INDENT>@stat_1d<EOL>def var(self, expression, binby=[], limits=None, shape=default_shape, selection=False, delay=False, progress=None):<DEDENT>

expression = _ensure_strings_from_expressions(expression)<EOL>@delayed<EOL>def calculate(expression, limits):<EOL><INDENT>task = tasks.TaskStatistic(self, binby, shape, limits, weight=expression, op=tasks.OP_ADD_WEIGHT_MOMENTS_012, selection=selection)<EOL>progressbar.add_task(task, "<STR_LIT>" % expression)<EOL>self.executor.schedule(task)<EOL>return task<EOL><DEDENT>@delayed<EOL>def finish(*stats_args):<EOL><INDENT>stats = np.array(stats_args)<EOL>counts = stats[..., <NUM_LIT:0>]<EOL>with np.errstate(divide='<STR_LIT:ignore>'):<EOL><INDENT>with np.errstate(divide='<STR_LIT:ignore>', invalid='<STR_LIT:ignore>'):  <EOL><INDENT>mean = stats[..., <NUM_LIT:1>] / counts<EOL>raw_moments2 = stats[..., <NUM_LIT:2>] / counts<EOL><DEDENT><DEDENT>variance = (raw_moments2 - mean**<NUM_LIT:2>)<EOL>return vaex.utils.unlistify(waslist, variance)<EOL><DEDENT>binby = _ensure_strings_from_expressions(binby)<EOL>waslist, [expressions, ] = vaex.utils.listify(expression)<EOL>progressbar = vaex.utils.progressbars(progress)<EOL>limits = self.limits(binby, limits, delay=True)<EOL>stats = [calculate(expression, limits) for expression in expressions]<EOL>var = finish(*stats)<EOL>return self._delay(delay, var)<EOL>


@docsubst<EOL><INDENT>@stat_1d<EOL>def _agg(self, aggregator, grid, selection=False, delay=False, progress=None):<DEDENT>

task_agg = self._get_task_agg(grid)<EOL>sub_task = aggregator.add_operations(task_agg)<EOL>return self._delay(delay, sub_task)<EOL>

:param selection: {selection}
:param delay: {delay}
:param progress: {progress}
:return: {return_stat_scalar}


@docsubst<EOL><INDENT>def covar(self, x, y, binby=[], limits=None, shape=default_shape, selection=False, delay=False, progress=None):<DEDENT>

@delayed<EOL>def cov(mean_x, mean_y, mean_xy):<EOL><INDENT>return mean_xy - mean_x * mean_y<EOL><DEDENT>waslist, [xlist, ylist] = vaex.utils.listify(x, y)<EOL>limits = self.limits(binby, limits, selection=selection, delay=True)<EOL>@delayed<EOL>def calculate(limits):<EOL><INDENT>results = []<EOL>for x, y in zip(xlist, ylist):<EOL><INDENT>mx = self.mean(x, binby=binby, limits=limits, shape=shape, selection=selection, delay=True, progress=progressbar)<EOL>my = self.mean(y, binby=binby, limits=limits, shape=shape, selection=selection, delay=True, progress=progressbar)<EOL>cxy = self.mean("<STR_LIT>" % (x, y), binby=binby, limits=limits, shape=shape, selection=selection,<EOL>delay=True, progress=progressbar)<EOL>results.append(cov(mx, my, cxy))<EOL><DEDENT>return results<EOL><DEDENT>progressbar = vaex.utils.progressbars(progress)<EOL>covars = calculate(limits)<EOL>@delayed<EOL>def finish(covars):<EOL><INDENT>value = np.array(vaex.utils.unlistify(waslist, covars))<EOL>return value<EOL><DEDENT>return self._delay(delay, finish(delayed_list(covars)))<EOL>

Calculate the covariance cov[x,y] between and x and y, possibly on a grid defined by binby.

        Example:

        >>> df.covar("x**2+y**2+z**2", "-log(-E+1)")
        array(52.69461456005138)
        >>> df.covar("x**2+y**2+z**2", "-log(-E+1)")/(df.std("x**2+y**2+z**2") * df.std("-log(-E+1)"))
        0.63666373822156686
        >>> df.covar("x**2+y**2+z**2", "-log(-E+1)", binby="Lz", shape=4)
        array([ 10.17387143,  51.94954078,  51.24902796,  20.2163929 ])

        :param x: {expression}
        :param y: {expression}
        :param binby: {binby}
        :param limits: {limits}
        :param shape: {shape}
        :param selection: {selection}
        :param delay: {delay}
        :param progress: {progress}
        :return: {return_stat_scalar}


def nop(self, expression, progress=False, delay=False):

expression = _ensure_string_from_expression(expression)<EOL>def map(ar):<EOL><INDENT>pass<EOL><DEDENT>def reduce(a, b):<EOL><INDENT>pass<EOL><DEDENT>return self.map_reduce(map, reduce, [expression], delay=delay, progress=progress, name='<STR_LIT>', to_numpy=False)<EOL>

Evaluates expression, and drop the result, usefull for benchmarking, since vaex is usually lazy


@_hidden<EOL><INDENT>def add_column_healpix(self, name="<STR_LIT>", longitude="<STR_LIT>", latitude="<STR_LIT>", degrees=True, healpix_order=<NUM_LIT:12>, nest=True):<DEDENT>

import healpy as hp<EOL>if degrees:<EOL><INDENT>scale = "<STR_LIT>"<EOL><DEDENT>else:<EOL><INDENT>scale = "<STR_LIT>"<EOL><DEDENT>phi = self.evaluate("<STR_LIT>" % (longitude, scale))<EOL>theta = self.evaluate("<STR_LIT>" % (latitude, scale))<EOL>hp_index = hp.ang2pix(hp.order2nside(healpix_order), theta, phi, nest=nest)<EOL>self.add_column("<STR_LIT>", hp_index)<EOL>

Add a healpix (in memory) column based on a longitude and latitude

        :param name: Name of column
        :param longitude: longitude expression
        :param latitude: latitude expression  (astronomical convenction latitude=90 is north pole)
        :param degrees: If lon/lat are in degrees (default) or radians.
        :param healpix_order: healpix order, >= 0
        :param nest: Nested healpix (default) or ring.


@docsubst<EOL><INDENT>def to_items(self, column_names=None, selection=None, strings=True, virtual=False):<DEDENT>

items = []<EOL>for name in column_names or self.get_column_names(strings=strings, virtual=virtual):<EOL><INDENT>items.append((name, self.evaluate(name, selection=selection)))<EOL><DEDENT>return items<EOL>

Return a list of [(column_name, ndarray), ...)] pairs where the ndarray corresponds to the evaluated data

        :param column_names: list of column names, to export, when None DataFrame.get_column_names(strings=strings, virtual=virtual) is used
        :param selection: {selection}
        :param strings: argument passed to DataFrame.get_column_names when column_names is None
        :param virtual: argument passed to DataFrame.get_column_names when column_names is None
        :return: list of (name, ndarray) pairs


def select_circle(self, x, y, xc, yc, r, mode="<STR_LIT:replace>", name="<STR_LIT:default>", inclusive=True):

<EOL>if inclusive:<EOL><INDENT>expr = (self[x] - xc)**<NUM_LIT:2> + (self[y] - yc)**<NUM_LIT:2> <= r**<NUM_LIT:2><EOL><DEDENT>else:<EOL><INDENT>expr = (self[x] - xc)**<NUM_LIT:2> + (self[y] - yc)**<NUM_LIT:2> < r**<NUM_LIT:2><EOL><DEDENT>self.select(boolean_expression=expr, mode=mode, name=name)<EOL>

Select a circular region centred on xc, yc, with a radius of r.

Example:

>>> df.select_circle('x','y',2,3,1)

:param x: expression for the x space
:param y: expression for the y space
:param xc: location of the centre of the circle in x
:param yc: location of the centre of the circle in y
:param r: the radius of the circle
:param name: name of the selection
:param mode:
:return:


def select_non_missing(self, drop_nan=True, drop_masked=True, column_names=None, mode="<STR_LIT:replace>", name="<STR_LIT:default>"):

column_names = column_names or self.get_column_names(virtual=False)<EOL>def create(current):<EOL><INDENT>return selections.SelectionDropNa(drop_nan, drop_masked, column_names, current, mode)<EOL><DEDENT>self._selection(create, name)<EOL>

Create a selection that selects rows having non missing values for all columns in column_names.

        The name reflect Panda's, no rows are really dropped, but a mask is kept to keep track of the selection

        :param drop_nan: drop rows when there is a NaN in any of the columns (will only affect float values)
        :param drop_masked: drop rows when there is a masked value in any of the columns
        :param column_names: The columns to consider, default: all (real, non-virtual) columns
        :param str mode: Possible boolean operator: replace/and/or/xor/subtract
        :param str name: history tree or selection 'slot' to use
        :return:


return <NUM_LIT:0><EOL>


def select_ellipse(self, x, y, xc, yc, width, height, angle=<NUM_LIT:0>, mode="<STR_LIT:replace>", name="<STR_LIT:default>", radians=False, inclusive=True):

<EOL>if radians:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>alpha = np.deg2rad(angle)<EOL><DEDENT>xr = width / <NUM_LIT:2><EOL>yr = height / <NUM_LIT:2><EOL>r = max(xr, yr)<EOL>a = xr / r<EOL>b = yr / r<EOL>expr = "<STR_LIT>".format(**locals())<EOL>if inclusive:<EOL><INDENT>expr = ((self[x] - xc) * np.cos(alpha) + (self[y] - yc) * np.sin(alpha))**<NUM_LIT:2> / a**<NUM_LIT:2> + ((self[x] - xc) * np.sin(alpha) - (self[y] - yc) * np.cos(alpha))**<NUM_LIT:2> / b**<NUM_LIT:2> <= r**<NUM_LIT:2><EOL><DEDENT>else:<EOL><INDENT>expr = ((self[x] - xc) * np.cos(alpha) + (self[y] - yc) * np.sin(alpha))**<NUM_LIT:2> / a**<NUM_LIT:2> + ((self[x] - xc) * np.sin(alpha) - (self[y] - yc) * np.cos(alpha))**<NUM_LIT:2> / b**<NUM_LIT:2> < r**<NUM_LIT:2><EOL><DEDENT>self.select(boolean_expression=expr, mode=mode, name=name)<EOL>

Select an elliptical region centred on xc, yc, with a certain width, height
and angle.

Example:

>>> df.select_ellipse('x','y', 2, -1, 5,1, 30, name='my_ellipse')

:param x: expression for the x space
:param y: expression for the y space
:param xc: location of the centre of the ellipse in x
:param yc: location of the centre of the ellipse in y
:param width: the width of the ellipse (diameter)
:param height: the width of the ellipse (diameter)
:param angle: (degrees) orientation of the ellipse, counter-clockwise
              measured from the y axis
:param name: name of the selection
:param mode:
:return:


def select(self, boolean_expression, mode="<STR_LIT:replace>", name="<STR_LIT:default>"):

raise NotImplementedError<EOL>

Select rows based on the boolean_expression, if there was a previous selection, the mode is taken into account.

        if boolean_expression is None, remove the selection, has_selection() will returns false

        Note that per DataFrame, only one selection is possible.

        :param str boolean_expression: boolean expression, such as 'x < 0', '(x < 0) || (y > -10)' or None to remove the selection
        :param str mode: boolean operation to perform with the previous selection, "replace", "and", "or", "xor", "subtract"
        :return: None


if self.is_local():<EOL><INDENT>name = os.path.abspath(self.path).replace(os.path.sep, "<STR_LIT:_>")[:<NUM_LIT>]  <EOL>name = name.replace("<STR_LIT::>", "<STR_LIT:_>")  <EOL><DEDENT>else:<EOL><INDENT>server = self.server<EOL>name = "<STR_LIT>" % (server.hostname, server.port, server.base_path.replace("<STR_LIT:/>", "<STR_LIT:_>"), self.name)<EOL><DEDENT>dir = os.path.join(vaex.utils.get_private_dir(), "<STR_LIT>", name)<EOL>if create and not os.path.exists(dir):<EOL><INDENT>os.makedirs(dir)<EOL><DEDENT>return dir<EOL>

Each DataFrame has a directory where files are stored for metadata etc.

        Example

        >>> import vaex
        >>> ds = vaex.example()
        >>> vaex.get_private_dir()
        '/Users/users/breddels/.vaex/dfs/_Users_users_breddels_vaex-testing_data_helmi-dezeeuw-2000-10p.hdf5'

        :param bool create: is True, it will create the directory if it does not exist


def export(self, path, column_names=None, byteorder="<STR_LIT:=>", shuffle=False, selection=False, progress=None, virtual=False, sort=None, ascending=True):

if path.endswith('<STR_LIT>'):<EOL><INDENT>self.export_arrow(path, column_names, byteorder, shuffle, selection, progress=progress, virtual=virtual, sort=sort, ascending=ascending)<EOL><DEDENT>elif path.endswith('<STR_LIT>'):<EOL><INDENT>self.export_hdf5(path, column_names, byteorder, shuffle, selection, progress=progress, virtual=virtual, sort=sort, ascending=ascending)<EOL><DEDENT>elif path.endswith('<STR_LIT>'):<EOL><INDENT>self.export_fits(path, column_names, shuffle, selection, progress=progress, virtual=virtual, sort=sort, ascending=ascending)<EOL><DEDENT>if path.endswith('<STR_LIT>'):<EOL><INDENT>self.export_parquet(path, column_names, shuffle, selection, progress=progress, virtual=virtual, sort=sort, ascending=ascending)<EOL><DEDENT>

Exports the DataFrame to a file written with arrow

        :param DataFrameLocal df: DataFrame to export
        :param str path: path for file
        :param lis[str] column_names: list of column names to export or None for all columns
        :param str byteorder: = for native, < for little endian and > for big endian (not supported for fits)
        :param bool shuffle: export rows in random order
        :param bool selection: export selection or not
        :param progress: progress callback that gets a progress fraction as argument and should return True to continue,
                or a default progress bar when progress=True
        :param: bool virtual: When True, export virtual columns
        :param str sort: expression used for sorting the output
        :param bool ascending: sort ascending (True) or descending
        :return:


return self.byte_size()<EOL>

Alias for `df.byte_size()`, see :meth:`DataFrame.byte_size`.


return self.get_selection(name) is not None<EOL>

Returns True if there is a selection with the given name.


column = _ensure_string_from_expression(column)<EOL>return column in self._categories<EOL>


@vaex.utils.deprecated('<STR_LIT>')<EOL><INDENT>@_hidden<EOL>def __call__(self, *expressions, **kwargs):<DEDENT>

raise NotImplementedError<EOL>


column = _ensure_string_from_expression(column)<EOL>if column in self.columns:<EOL><INDENT>return np.ma.isMaskedArray(self.columns[column])<EOL><DEDENT>return False<EOL>

Return if a column is a masked (numpy.ma) column.


def dropna(self, drop_nan=True, drop_masked=True, column_names=None):

copy = self.copy()<EOL>copy.select_non_missing(drop_nan=drop_nan, drop_masked=drop_masked, column_names=column_names,<EOL>name=FILTER_SELECTION_NAME, mode='<STR_LIT>')<EOL>return copy<EOL>

Create a shallow copy of a DataFrame, with filtering set using select_non_missing.

        :param drop_nan: drop rows when there is a NaN in any of the columns (will only affect float values)
        :param drop_masked: drop rows when there is a masked value in any of the columns
        :param column_names: The columns to consider, default: all (real, non-virtual) columns
        :rtype: DataFrame


<EOL>path = os.path.join(self.get_private_dir(create=True), "<STR_LIT>")<EOL>units = {key: str(value) for key, value in self.units.items()}<EOL>meta_info = dict(description=self.description,<EOL>ucds=self.ucds, units=units, descriptions=self.descriptions,<EOL>)<EOL>vaex.utils.write_json_or_yaml(path, meta_info)<EOL>

Writes all meta data, ucd,description and units

        The default implementation is to write this to a file called meta.yaml in the directory defined by
        :func:`DataFrame.get_private_dir`. Other implementation may store this in the DataFrame file itself.
        (For instance the vaex hdf5 implementation does this)

        This method is called after virtual columns or variables are added. Upon opening a file, :func:`DataFrame.update_meta`
        is called, so that the information is not lost between sessions.

        Note: opening a DataFrame twice may result in corruption of this file.


def select_rectangle(self, x, y, limits, mode="<STR_LIT:replace>", name="<STR_LIT:default>"):

self.select_box([x, y], limits, mode=mode, name=name)<EOL>

Select a 2d rectangular box in the space given by x and y, bounds by limits.

        Example:

        >>> df.select_box('x', 'y', [(0, 10), (0, 1)])

        :param x: expression for the x space
        :param y: expression fo the y space
        :param limits: sequence of shape [(x1, x2), (y1, y2)]
        :param mode:


@_hidden<EOL><INDENT>def __call__(self, *expressions, **kwargs):<DEDENT>

import vaex.legacy<EOL>return vaex.legacy.SubspaceLocal(self, expressions, kwargs.get("<STR_LIT>") or self.executor, delay=kwargs.get("<STR_LIT>", False))<EOL>

The local implementation of :func:`DataFrame.__call__`


def selection_redo(self, name="<STR_LIT:default>", executor=None):

logger.debug("<STR_LIT>")<EOL>executor = executor or self.executor<EOL>assert self.selection_can_redo(name=name)<EOL>selection_history = self.selection_histories[name]<EOL>index = self.selection_history_indices[name]<EOL>next = selection_history[index + <NUM_LIT:1>]<EOL>self.selection_history_indices[name] += <NUM_LIT:1><EOL>self.signal_selection_changed.emit(self)<EOL>logger.debug("<STR_LIT>", selection_history, index)<EOL>


return self.selection_history_indices[name] > -<NUM_LIT:1><EOL>


@_hidden<EOL><INDENT>def subspaces(self, expressions_list=None, dimensions=None, exclude=None, **kwargs):<DEDENT>

if dimensions is not None:<EOL><INDENT>expressions_list = list(itertools.combinations(self.get_column_names(), dimensions))<EOL>if exclude is not None:<EOL><INDENT>import six<EOL>def excluded(expressions):<EOL><INDENT>if callable(exclude):<EOL><INDENT>return exclude(expressions)<EOL><DEDENT>elif isinstance(exclude, six.string_types):<EOL><INDENT>return exclude in expressions<EOL><DEDENT>elif isinstance(exclude, (list, tuple)):<EOL><INDENT>for e in exclude:<EOL><INDENT>if isinstance(e, six.string_types):<EOL><INDENT>if e in expressions:<EOL><INDENT>return True<EOL><DEDENT><DEDENT>elif isinstance(e, (list, tuple)):<EOL><INDENT>if set(e).issubset(expressions):<EOL><INDENT>return True<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>return False<EOL><DEDENT>expressions_list = [expr for expr in expressions_list if not excluded(expr)]<EOL><DEDENT>logger.debug("<STR_LIT>", expressions_list)<EOL><DEDENT>import vaex.legacy<EOL>return vaex.legacy.Subspaces([self(*expressions, **kwargs) for expressions in expressions_list])<EOL>

Generate a Subspaces object, based on a custom list of expressions or all possible combinations based on
        dimension

        :param expressions_list: list of list of expressions, where the inner list defines the subspace
        :param dimensions: if given, generates a subspace with all possible combinations for that dimension
        :param exclude: list of


@docsubst<EOL><INDENT>def limits_percentage(self, expression, percentage=<NUM_LIT>, square=False, delay=False):<DEDENT>

<EOL>import scipy<EOL>logger.info("<STR_LIT>", expression, percentage)<EOL>waslist, [expressions, ] = vaex.utils.listify(expression)<EOL>limits = []<EOL>for expr in expressions:<EOL><INDENT>subspace = self(expr)<EOL>limits_minmax = subspace.minmax()<EOL>vmin, vmax = limits_minmax[<NUM_LIT:0>]<EOL>size = <NUM_LIT> * <NUM_LIT:16><EOL>counts = subspace.histogram(size=size, limits=limits_minmax)<EOL>cumcounts = np.concatenate([[<NUM_LIT:0>], np.cumsum(counts)])<EOL>cumcounts /= cumcounts.max()<EOL>f = (<NUM_LIT:1> - percentage / <NUM_LIT>) / <NUM_LIT:2><EOL>x = np.linspace(vmin, vmax, size + <NUM_LIT:1>)<EOL>l = scipy.interp([f, <NUM_LIT:1> - f], cumcounts, x)<EOL>limits.append(l)<EOL><DEDENT>return vaex.utils.unlistify(waslist, limits)<EOL>

Calculate the [min, max] range for expression, containing approximately a percentage of the data as defined
        by percentage.

        The range is symmetric around the median, i.e., for a percentage of 90, this gives the same results as:

        Example:

        >>> df.limits_percentage("x", 90)
        array([-12.35081376,  12.14858052]
        >>> df.percentile_approx("x", 5), df.percentile_approx("x", 95)
        (array([-12.36813152]), array([ 12.13275818]))

        NOTE: this value is approximated by calculating the cumulative distribution on a grid.
        NOTE 2: The values above are not exactly the same, since percentile and limits_percentage do not share the same code

        :param expression: {expression_limits}
        :param float percentage: Value between 0 and 100
        :param delay: {delay}
        :return: {return_limits}


def add_virtual_column(self, name, expression, unique=False):

type = "<STR_LIT>" if name in self.virtual_columns else "<STR_LIT>"<EOL>expression = _ensure_string_from_expression(expression)<EOL>if name in self.get_column_names(virtual=False):<EOL><INDENT>renamed = '<STR_LIT>' +vaex.utils.find_valid_name(name, used=self.get_column_names())<EOL>expression = self._rename(name, renamed, expression)[<NUM_LIT:0>].expression<EOL><DEDENT>name = vaex.utils.find_valid_name(name, used=[] if not unique else self.get_column_names())<EOL>self.virtual_columns[name] = expression<EOL>self.column_names.append(name)<EOL>self._save_assign_expression(name)<EOL>self.signal_column_changed.emit(self, name, "<STR_LIT>")<EOL>

Add a virtual column to the DataFrame.

        Example:

        >>> df.add_virtual_column("r", "sqrt(x**2 + y**2 + z**2)")
        >>> df.select("r < 10")

        :param: str name: name of virtual column
        :param: expression: expression for the column
        :param str unique: if name is already used, make it unique by adding a postfix, e.g. _1, or _2


def add_variable(self, name, expression, overwrite=True, unique=True):

if unique or overwrite or name not in self.variables:<EOL><INDENT>existing_names = self.get_column_names(virtual=False) + list(self.variables.keys())<EOL>name = vaex.utils.find_valid_name(name, used=[] if not unique else existing_names)<EOL>self.variables[name] = expression<EOL>self.signal_variable_changed.emit(self, name, "<STR_LIT>")<EOL>if unique:<EOL><INDENT>return name<EOL><DEDENT><DEDENT>

Add a variable to to a DataFrame.

        A variable may refer to other variables, and virtual columns and expression may refer to variables.

        Example

        >>> df.add_variable('center', 0)
        >>> df.add_virtual_column('x_prime', 'x-center')
        >>> df.select('x_prime < 0')

        :param: str name: name of virtual varible
        :param: expression: expression for the variable


if not self.filtered:<EOL><INDENT>return self._length_unfiltered<EOL><DEDENT>else:<EOL><INDENT>return int(self.count())<EOL><DEDENT>

Returns the number of rows in the DataFrame (filtering applied).


dfs = []<EOL>if isinstance(self, DataFrameConcatenated):<EOL><INDENT>dfs.extend(self.dfs)<EOL><DEDENT>else:<EOL><INDENT>dfs.extend([self])<EOL><DEDENT>if isinstance(other, DataFrameConcatenated):<EOL><INDENT>dfs.extend(other.dfs)<EOL><DEDENT>else:<EOL><INDENT>dfs.extend([other])<EOL><DEDENT>return DataFrameConcatenated(dfs)<EOL>

Concatenates two DataFrames, adding the rows of one the other DataFrame to the current, returned in a new DataFrame.

        No copy of the data is made.

        :param other: The other DataFrame that is concatenated with this DataFrame
        :return: New DataFrame with the rows concatenated
        :rtype: DataFrameConcatenated


def select(self, boolean_expression, mode="<STR_LIT:replace>", name="<STR_LIT:default>", executor=None):

boolean_expression = _ensure_string_from_expression(boolean_expression)<EOL>if boolean_expression is None and not self.has_selection(name=name):<EOL><INDENT>pass  <EOL>self.signal_selection_changed.emit(self)  <EOL><DEDENT>else:<EOL><INDENT>def create(current):<EOL><INDENT>return selections.SelectionExpression(boolean_expression, current, mode) if boolean_expression else None<EOL><DEDENT>self._selection(create, name)<EOL><DEDENT>

Perform a selection, defined by the boolean expression, and combined with the previous selection using the given mode.

        Selections are recorded in a history tree, per name, undo/redo can be done for them separately.

        :param str boolean_expression: Any valid column expression, with comparison operators
        :param str mode: Possible boolean operator: replace/and/or/xor/subtract
        :param str name: history tree or selection 'slot' to use
        :param executor:
        :return:


def describe(self, strings=True, virtual=True, selection=None):

import pandas as pd<EOL>N = len(self)<EOL>columns = {}<EOL>for feature in self.get_column_names(strings=strings, virtual=virtual)[:]:<EOL><INDENT>dtype = str(self.dtype(feature)) if self.dtype(feature) != str else '<STR_LIT:str>'<EOL>if self.dtype(feature) == str_type or self.dtype(feature).kind in ['<STR_LIT:S>', '<STR_LIT>', '<STR_LIT:O>']:<EOL><INDENT>count = self.count(feature, selection=selection, delay=True)<EOL>self.execute()<EOL>count = count.get()<EOL>columns[feature] = ((dtype, count, N-count, '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>'))<EOL><DEDENT>else:<EOL><INDENT>count = self.count(feature, selection=selection, delay=True)<EOL>mean = self.mean(feature, selection=selection, delay=True)<EOL>std = self.std(feature, selection=selection, delay=True)<EOL>minmax = self.minmax(feature, selection=selection, delay=True)<EOL>self.execute()<EOL>count, mean, std, minmax = count.get(), mean.get(), std.get(), minmax.get()<EOL>count = int(count)<EOL>columns[feature] = ((dtype, count, N-count, mean, std, minmax[<NUM_LIT:0>], minmax[<NUM_LIT:1>]))<EOL><DEDENT><DEDENT>return pd.DataFrame(data=columns, index=['<STR_LIT>', '<STR_LIT:count>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>'])<EOL>

Give a description of the DataFrame.

        >>> import vaex
        >>> df = vaex.example()[['x', 'y', 'z']]
        >>> df.describe()
                         x          y          z
        dtype      float64    float64    float64
        count       330000     330000     330000
        missing          0          0          0
        mean    -0.0671315 -0.0535899  0.0169582
        std        7.31746    7.78605    5.05521
        min       -128.294   -71.5524   -44.3342
        max        271.366    146.466    50.7185
        >>> df.describe(selection=df.x > 0)
                           x         y          z
        dtype        float64   float64    float64
        count         164060    164060     164060
        missing       165940    165940     165940
        mean         5.13572 -0.486786 -0.0868073
        std          5.18701   7.61621    5.02831
        min      1.51635e-05  -71.5524   -44.3342
        max          271.366   78.0724    40.2191

        :param bool strings: Describe string columns or not
        :param bool virtual: Describe virtual columns or not
        :param selection: Optional selection to use.
        :return: Pandas dataframe