def diagonal(a, offset=<NUM_LIT:0>, axis1=<NUM_LIT:0>, axis2=<NUM_LIT:1>):

return asarray(a).diagonal(offset, axis1, axis2)<EOL>

Return specified diagonals.

If `a` is 2-D, returns the diagonal of `a` with the given offset,
i.e., the collection of elements of the form ``a[i, i+offset]``.  If
`a` has more than two dimensions, then the axes specified by `axis1`
and `axis2` are used to determine the 2-D sub-array whose diagonal is
returned.  The shape of the resulting array can be determined by
removing `axis1` and `axis2` and appending an index to the right equal
to the size of the resulting diagonals.

In versions of NumPy prior to 1.7, this function always returned a new,
independent array containing a copy of the values in the diagonal.

In NumPy 1.7 and 1.8, it continues to return a copy of the diagonal,
but depending on this fact is deprecated. Writing to the resulting
array continues to work as it used to, but a FutureWarning is issued.

In NumPy 1.9 it returns a read-only view on the original array.
Attempting to write to the resulting array will produce an error.

In NumPy 1.10, it will return a read/write view, Writing to the returned
array will alter your original array.

If you don't write to the array returned by this function, then you can
just ignore all of the above.

If you depend on the current behavior, then we suggest copying the
returned array explicitly, i.e., use ``np.diagonal(a).copy()`` instead of
just ``np.diagonal(a)``. This will work with both past and future versions
of NumPy.

Parameters
----------
a : array_like
    Array from which the diagonals are taken.
offset : int, optional
    Offset of the diagonal from the main diagonal.  Can be positive or
    negative.  Defaults to main diagonal (0).
axis1 : int, optional
    Axis to be used as the first axis of the 2-D sub-arrays from which
    the diagonals should be taken.  Defaults to first axis (0).
axis2 : int, optional
    Axis to be used as the second axis of the 2-D sub-arrays from
    which the diagonals should be taken. Defaults to second axis (1).

Returns
-------
array_of_diagonals : ndarray
    If `a` is 2-D, a 1-D array containing the diagonal is returned.
    If the dimension of `a` is larger, then an array of diagonals is
    returned, "packed" from left-most dimension to right-most (e.g.,
    if `a` is 3-D, then the diagonals are "packed" along rows).

Raises
------
ValueError
    If the dimension of `a` is less than 2.

See Also
--------
diag : MATLAB work-a-like for 1-D and 2-D arrays.
diagflat : Create diagonal arrays.
trace : Sum along diagonals.

Examples
--------
>>> a = np.arange(4).reshape(2,2)
>>> a
array([[0, 1],
       [2, 3]])
>>> a.diagonal()
array([0, 3])
>>> a.diagonal(1)
array([1])

A 3-D example:

>>> a = np.arange(8).reshape(2,2,2); a
array([[[0, 1],
        [2, 3]],
       [[4, 5],
        [6, 7]]])
>>> a.diagonal(0, # Main diagonals of two arrays created by skipping
...            0, # across the outer(left)-most axis last and
...            1) # the "middle" (row) axis first.
array([[0, 6],
       [1, 7]])

The sub-arrays whose main diagonals we just obtained; note that each
corresponds to fixing the right-most (column) axis, and that the
diagonals are "packed" in rows.

>>> a[:,:,0] # main diagonal is [0 6]
array([[0, 2],
       [4, 6]])
>>> a[:,:,1] # main diagonal is [1 7]
array([[1, 3],
       [5, 7]])


def trace(a, offset=<NUM_LIT:0>, axis1=<NUM_LIT:0>, axis2=<NUM_LIT:1>, dtype=None, out=None):

return asarray(a).trace(offset, axis1, axis2, dtype, out)<EOL>

Return the sum along diagonals of the array.

If `a` is 2-D, the sum along its diagonal with the given offset
is returned, i.e., the sum of elements ``a[i,i+offset]`` for all i.

If `a` has more than two dimensions, then the axes specified by axis1 and
axis2 are used to determine the 2-D sub-arrays whose traces are returned.
The shape of the resulting array is the same as that of `a` with `axis1`
and `axis2` removed.

Parameters
----------
a : array_like
    Input array, from which the diagonals are taken.
offset : int, optional
    Offset of the diagonal from the main diagonal. Can be both positive
    and negative. Defaults to 0.
axis1, axis2 : int, optional
    Axes to be used as the first and second axis of the 2-D sub-arrays
    from which the diagonals should be taken. Defaults are the first two
    axes of `a`.
dtype : dtype, optional
    Determines the data-type of the returned array and of the accumulator
    where the elements are summed. If dtype has the value None and `a` is
    of integer type of precision less than the default integer
    precision, then the default integer precision is used. Otherwise,
    the precision is the same as that of `a`.
out : ndarray, optional
    Array into which the output is placed. Its type is preserved and
    it must be of the right shape to hold the output.

Returns
-------
sum_along_diagonals : ndarray
    If `a` is 2-D, the sum along the diagonal is returned.  If `a` has
    larger dimensions, then an array of sums along diagonals is returned.

See Also
--------
diag, diagonal, diagflat

Examples
--------
>>> np.trace(np.eye(3))
3.0
>>> a = np.arange(8).reshape((2,2,2))
>>> np.trace(a)
array([6, 8])

>>> a = np.arange(24).reshape((2,2,2,3))
>>> np.trace(a).shape
(2, 3)


return asarray(a).ravel(order)<EOL>

Return a flattened array.

A 1-D array, containing the elements of the input, is returned.  A copy is
made only if needed.

Parameters
----------
a : array_like
    Input array.  The elements in `a` are read in the order specified by
    `order`, and packed as a 1-D array.
order : {'C','F', 'A', 'K'}, optional
    The elements of `a` are read using this index order. 'C' means to
    index the elements in C-like order, with the last axis index changing
    fastest, back to the first axis index changing slowest.   'F' means to
    index the elements in Fortran-like index order, with the first index
    changing fastest, and the last index changing slowest. Note that the 'C'
    and 'F' options take no account of the memory layout of the underlying
    array, and only refer to the order of axis indexing.  'A' means to read
    the elements in Fortran-like index order if `a` is Fortran *contiguous*
    in memory, C-like order otherwise.  'K' means to read the elements in
    the order they occur in memory, except for reversing the data when
    strides are negative.  By default, 'C' index order is used.

Returns
-------
1d_array : ndarray
    Output of the same dtype as `a`, and of shape ``(a.size,)``.

See Also
--------
ndarray.flat : 1-D iterator over an array.
ndarray.flatten : 1-D array copy of the elements of an array
                  in row-major order.

Notes
-----
In C-like (row-major) order, in two dimensions, the row index varies the
slowest, and the column index the quickest.  This can be generalized to
multiple dimensions, where row-major order implies that the index along the
first axis varies slowest, and the index along the last quickest.  The
opposite holds for Fortran-like, or column-major, index ordering.

Examples
--------
It is equivalent to ``reshape(-1, order=order)``.

>>> x = np.array([[1, 2, 3], [4, 5, 6]])
>>> print np.ravel(x)
[1 2 3 4 5 6]

>>> print x.reshape(-1)
[1 2 3 4 5 6]

>>> print np.ravel(x, order='F')
[1 4 2 5 3 6]

When ``order`` is 'A', it will preserve the array's 'C' or 'F' ordering:

>>> print np.ravel(x.T)
[1 4 2 5 3 6]
>>> print np.ravel(x.T, order='A')
[1 2 3 4 5 6]

When ``order`` is 'K', it will preserve orderings that are neither 'C'
nor 'F', but won't reverse axes:

>>> a = np.arange(3)[::-1]; a
array([2, 1, 0])
>>> a.ravel(order='C')
array([2, 1, 0])
>>> a.ravel(order='K')
array([2, 1, 0])

>>> a = np.arange(12).reshape(2,3,2).swapaxes(1,2); a
array([[[ 0,  2,  4],
        [ 1,  3,  5]],
       [[ 6,  8, 10],
        [ 7,  9, 11]]])
>>> a.ravel(order='C')
array([ 0,  2,  4,  1,  3,  5,  6,  8, 10,  7,  9, 11])
>>> a.ravel(order='K')
array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11])


try:<EOL><INDENT>nonzero = a.nonzero<EOL><DEDENT>except AttributeError:<EOL><INDENT>res = _wrapit(a, '<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>res = nonzero()<EOL><DEDENT>return res<EOL>

Return the indices of the elements that are non-zero.

Returns a tuple of arrays, one for each dimension of `a`, containing
the indices of the non-zero elements in that dimension. The
corresponding non-zero values can be obtained with::

    a[nonzero(a)]

To group the indices by element, rather than dimension, use::

    transpose(nonzero(a))

The result of this is always a 2-D array, with a row for
each non-zero element.

Parameters
----------
a : array_like
    Input array.

Returns
-------
tuple_of_arrays : tuple
    Indices of elements that are non-zero.

See Also
--------
flatnonzero :
    Return indices that are non-zero in the flattened version of the input
    array.
ndarray.nonzero :
    Equivalent ndarray method.
count_nonzero :
    Counts the number of non-zero elements in the input array.

Examples
--------
>>> x = np.eye(3)
>>> x
array([[ 1.,  0.,  0.],
       [ 0.,  1.,  0.],
       [ 0.,  0.,  1.]])
>>> np.nonzero(x)
(array([0, 1, 2]), array([0, 1, 2]))

>>> x[np.nonzero(x)]
array([ 1.,  1.,  1.])
>>> np.transpose(np.nonzero(x))
array([[0, 0],
       [1, 1],
       [2, 2]])

A common use for ``nonzero`` is to find the indices of an array, where
a condition is True.  Given an array `a`, the condition `a` > 3 is a
boolean array and since False is interpreted as 0, np.nonzero(a > 3)
yields the indices of the `a` where the condition is true.

>>> a = np.array([[1,2,3],[4,5,6],[7,8,9]])
>>> a > 3
array([[False, False, False],
       [ True,  True,  True],
       [ True,  True,  True]], dtype=bool)
>>> np.nonzero(a > 3)
(array([1, 1, 1, 2, 2, 2]), array([0, 1, 2, 0, 1, 2]))

The ``nonzero`` method of the boolean array can also be called.

>>> (a > 3).nonzero()
(array([1, 1, 1, 2, 2, 2]), array([0, 1, 2, 0, 1, 2]))


try:<EOL><INDENT>result = a.shape<EOL><DEDENT>except AttributeError:<EOL><INDENT>result = asarray(a).shape<EOL><DEDENT>return result<EOL>

Return the shape of an array.

Parameters
----------
a : array_like
    Input array.

Returns
-------
shape : tuple of ints
    The elements of the shape tuple give the lengths of the
    corresponding array dimensions.

See Also
--------
alen
ndarray.shape : Equivalent array method.

Examples
--------
>>> np.shape(np.eye(3))
(3, 3)
>>> np.shape([[1, 2]])
(1, 2)
>>> np.shape([0])
(1,)
>>> np.shape(0)
()

>>> a = np.array([(1, 2), (3, 4)], dtype=[('x', 'i4'), ('y', 'i4')])
>>> np.shape(a)
(2,)
>>> a.shape
(2,)


def compress(condition, a, axis=None, out=None):

try:<EOL><INDENT>compress = a.compress<EOL><DEDENT>except AttributeError:<EOL><INDENT>return _wrapit(a, '<STR_LIT>', condition, axis, out)<EOL><DEDENT>return compress(condition, axis, out)<EOL>

Return selected slices of an array along given axis.

When working along a given axis, a slice along that axis is returned in
`output` for each index where `condition` evaluates to True. When
working on a 1-D array, `compress` is equivalent to `extract`.

Parameters
----------
condition : 1-D array of bools
    Array that selects which entries to return. If len(condition)
    is less than the size of `a` along the given axis, then output is
    truncated to the length of the condition array.
a : array_like
    Array from which to extract a part.
axis : int, optional
    Axis along which to take slices. If None (default), work on the
    flattened array.
out : ndarray, optional
    Output array.  Its type is preserved and it must be of the right
    shape to hold the output.

Returns
-------
compressed_array : ndarray
    A copy of `a` without the slices along axis for which `condition`
    is false.

See Also
--------
take, choose, diag, diagonal, select
ndarray.compress : Equivalent method in ndarray
np.extract: Equivalent method when working on 1-D arrays
numpy.doc.ufuncs : Section "Output arguments"

Examples
--------
>>> a = np.array([[1, 2], [3, 4], [5, 6]])
>>> a
array([[1, 2],
       [3, 4],
       [5, 6]])
>>> np.compress([0, 1], a, axis=0)
array([[3, 4]])
>>> np.compress([False, True, True], a, axis=0)
array([[3, 4],
       [5, 6]])
>>> np.compress([False, True], a, axis=1)
array([[2],
       [4],
       [6]])

Working on the flattened array does not return slices along an axis but
selects elements.

>>> np.compress([False, True], a)
array([2])


try:<EOL><INDENT>clip = a.clip<EOL><DEDENT>except AttributeError:<EOL><INDENT>return _wrapit(a, '<STR_LIT>', a_min, a_max, out)<EOL><DEDENT>return clip(a_min, a_max, out)<EOL>

Clip (limit) the values in an array.

Given an interval, values outside the interval are clipped to
the interval edges.  For example, if an interval of ``[0, 1]``
is specified, values smaller than 0 become 0, and values larger
than 1 become 1.

Parameters
----------
a : array_like
    Array containing elements to clip.
a_min : scalar or array_like
    Minimum value.
a_max : scalar or array_like
    Maximum value.  If `a_min` or `a_max` are array_like, then they will
    be broadcasted to the shape of `a`.
out : ndarray, optional
    The results will be placed in this array. It may be the input
    array for in-place clipping.  `out` must be of the right shape
    to hold the output.  Its type is preserved.

Returns
-------
clipped_array : ndarray
    An array with the elements of `a`, but where values
    < `a_min` are replaced with `a_min`, and those > `a_max`
    with `a_max`.

See Also
--------
numpy.doc.ufuncs : Section "Output arguments"

Examples
--------
>>> a = np.arange(10)
>>> np.clip(a, 1, 8)
array([1, 1, 2, 3, 4, 5, 6, 7, 8, 8])
>>> a
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> np.clip(a, 3, 6, out=a)
array([3, 3, 3, 3, 4, 5, 6, 6, 6, 6])
>>> a = np.arange(10)
>>> a
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> np.clip(a, [3,4,1,1,1,4,4,4,4,4], 8)
array([3, 4, 2, 3, 4, 5, 6, 7, 8, 8])


def sum(a, axis=None, dtype=None, out=None, keepdims=False):

if isinstance(a, _gentype):<EOL><INDENT>res = _sum_(a)<EOL>if out is not None:<EOL><INDENT>out[...] = res<EOL>return out<EOL><DEDENT>return res<EOL><DEDENT>elif type(a) is not mu.ndarray:<EOL><INDENT>try:<EOL><INDENT>sum = a.sum<EOL><DEDENT>except AttributeError:<EOL><INDENT>return _methods._sum(a, axis=axis, dtype=dtype,<EOL>out=out, keepdims=keepdims)<EOL><DEDENT>return sum(axis=axis, dtype=dtype, out=out)<EOL><DEDENT>else:<EOL><INDENT>return _methods._sum(a, axis=axis, dtype=dtype,<EOL>out=out, keepdims=keepdims)<EOL><DEDENT>

Sum of array elements over a given axis.

Parameters
----------
a : array_like
    Elements to sum.
axis : None or int or tuple of ints, optional
    Axis or axes along which a sum is performed.
    The default (`axis` = `None`) is perform a sum over all
    the dimensions of the input array. `axis` may be negative, in
    which case it counts from the last to the first axis.

    .. versionadded:: 1.7.0

    If this is a tuple of ints, a sum is performed on multiple
    axes, instead of a single axis or all the axes as before.
dtype : dtype, optional
    The type of the returned array and of the accumulator in which
    the elements are summed.  By default, the dtype of `a` is used.
    An exception is when `a` has an integer type with less precision
    than the default platform integer.  In that case, the default
    platform integer is used instead.
out : ndarray, optional
    Array into which the output is placed.  By default, a new array is
    created.  If `out` is given, it must be of the appropriate shape
    (the shape of `a` with `axis` removed, i.e.,
    ``numpy.delete(a.shape, axis)``).  Its type is preserved. See
    `doc.ufuncs` (Section "Output arguments") for more details.
keepdims : bool, optional
    If this is set to True, the axes which are reduced are left
    in the result as dimensions with size one. With this option,
    the result will broadcast correctly against the original `arr`.

Returns
-------
sum_along_axis : ndarray
    An array with the same shape as `a`, with the specified
    axis removed.   If `a` is a 0-d array, or if `axis` is None, a scalar
    is returned.  If an output array is specified, a reference to
    `out` is returned.

See Also
--------
ndarray.sum : Equivalent method.

cumsum : Cumulative sum of array elements.

trapz : Integration of array values using the composite trapezoidal rule.

mean, average

Notes
-----
Arithmetic is modular when using integer types, and no error is
raised on overflow.

Examples
--------
>>> np.sum([0.5, 1.5])
2.0
>>> np.sum([0.5, 0.7, 0.2, 1.5], dtype=np.int32)
1
>>> np.sum([[0, 1], [0, 5]])
6
>>> np.sum([[0, 1], [0, 5]], axis=0)
array([0, 6])
>>> np.sum([[0, 1], [0, 5]], axis=1)
array([1, 5])

If the accumulator is too small, overflow occurs:

>>> np.ones(128, dtype=np.int8).sum(dtype=np.int8)
-128


def product (a, axis=None, dtype=None, out=None, keepdims=False):

return um.multiply.reduce(a, axis=axis, dtype=dtype, out=out, keepdims=keepdims)<EOL>

Return the product of array elements over a given axis.

See Also
--------
prod : equivalent function; see for details.


def sometrue(a, axis=None, out=None, keepdims=False):

arr = asanyarray(a)<EOL>try:<EOL><INDENT>return arr.any(axis=axis, out=out, keepdims=keepdims)<EOL><DEDENT>except TypeError:<EOL><INDENT>return arr.any(axis=axis, out=out)<EOL><DEDENT>

Check whether some values are true.

Refer to `any` for full documentation.

See Also
--------
any : equivalent function


def alltrue (a, axis=None, out=None, keepdims=False):

arr = asanyarray(a)<EOL>try:<EOL><INDENT>return arr.all(axis=axis, out=out, keepdims=keepdims)<EOL><DEDENT>except TypeError:<EOL><INDENT>return arr.all(axis=axis, out=out)<EOL><DEDENT>

Check if all elements of input array are true.

See Also
--------
numpy.all : Equivalent function; see for details.


def any(a, axis=None, out=None, keepdims=False):

Test whether any array element along a given axis evaluates to True.

Returns single boolean unless `axis` is not ``None``

Parameters
----------
a : array_like
    Input array or object that can be converted to an array.
axis : None or int or tuple of ints, optional
    Axis or axes along which a logical OR reduction is performed.
    The default (`axis` = `None`) is to perform a logical OR over all
    the dimensions of the input array. `axis` may be negative, in
    which case it counts from the last to the first axis.

    .. versionadded:: 1.7.0

    If this is a tuple of ints, a reduction is performed on multiple
    axes, instead of a single axis or all the axes as before.
out : ndarray, optional
    Alternate output array in which to place the result.  It must have
    the same shape as the expected output and its type is preserved
    (e.g., if it is of type float, then it will remain so, returning
    1.0 for True and 0.0 for False, regardless of the type of `a`).
    See `doc.ufuncs` (Section "Output arguments") for details.
keepdims : bool, optional
    If this is set to True, the axes which are reduced are left
    in the result as dimensions with size one. With this option,
    the result will broadcast correctly against the original `arr`.

Returns
-------
any : bool or ndarray
    A new boolean or `ndarray` is returned unless `out` is specified,
    in which case a reference to `out` is returned.

See Also
--------
ndarray.any : equivalent method

all : Test whether all elements along a given axis evaluate to True.

Notes
-----
Not a Number (NaN), positive infinity and negative infinity evaluate
to `True` because these are not equal to zero.

Examples
--------
>>> np.any([[True, False], [True, True]])
True

>>> np.any([[True, False], [False, False]], axis=0)
array([ True, False], dtype=bool)

>>> np.any([-1, 0, 5])
True

>>> np.any(np.nan)
True

>>> o=np.array([False])
>>> z=np.any([-1, 4, 5], out=o)
>>> z, o
(array([ True], dtype=bool), array([ True], dtype=bool))
>>> # Check now that z is a reference to o
>>> z is o
True
>>> id(z), id(o) # identity of z and o              # doctest: +SKIP
(191614240, 191614240)


def all(a, axis=None, out=None, keepdims=False):

Test whether all array elements along a given axis evaluate to True.

Parameters
----------
a : array_like
    Input array or object that can be converted to an array.
axis : None or int or tuple of ints, optional
    Axis or axes along which a logical AND reduction is performed.
    The default (`axis` = `None`) is to perform a logical AND over all
    the dimensions of the input array. `axis` may be negative, in
    which case it counts from the last to the first axis.

    .. versionadded:: 1.7.0

    If this is a tuple of ints, a reduction is performed on multiple
    axes, instead of a single axis or all the axes as before.
out : ndarray, optional
    Alternate output array in which to place the result.
    It must have the same shape as the expected output and its
    type is preserved (e.g., if ``dtype(out)`` is float, the result
    will consist of 0.0's and 1.0's).  See `doc.ufuncs` (Section
    "Output arguments") for more details.
keepdims : bool, optional
    If this is set to True, the axes which are reduced are left
    in the result as dimensions with size one. With this option,
    the result will broadcast correctly against the original `arr`.

Returns
-------
all : ndarray, bool
    A new boolean or array is returned unless `out` is specified,
    in which case a reference to `out` is returned.

See Also
--------
ndarray.all : equivalent method

any : Test whether any element along a given axis evaluates to True.

Notes
-----
Not a Number (NaN), positive infinity and negative infinity
evaluate to `True` because these are not equal to zero.

Examples
--------
>>> np.all([[True,False],[True,True]])
False

>>> np.all([[True,False],[True,True]], axis=0)
array([ True, False], dtype=bool)

>>> np.all([-1, 4, 5])
True

>>> np.all([1.0, np.nan])
True

>>> o=np.array([False])
>>> z=np.all([-1, 4, 5], out=o)
>>> id(z), id(o), z                             # doctest: +SKIP
(28293632, 28293632, array([ True], dtype=bool))


def cumsum (a, axis=None, dtype=None, out=None):

try:<EOL><INDENT>cumsum = a.cumsum<EOL><DEDENT>except AttributeError:<EOL><INDENT>return _wrapit(a, '<STR_LIT>', axis, dtype, out)<EOL><DEDENT>return cumsum(axis, dtype, out)<EOL>

Return the cumulative sum of the elements along a given axis.

Parameters
----------
a : array_like
    Input array.
axis : int, optional
    Axis along which the cumulative sum is computed. The default
    (None) is to compute the cumsum over the flattened array.
dtype : dtype, optional
    Type of the returned array and of the accumulator in which the
    elements are summed.  If `dtype` is not specified, it defaults
    to the dtype of `a`, unless `a` has an integer dtype with a
    precision less than that of the default platform integer.  In
    that case, the default platform integer is used.
out : ndarray, optional
    Alternative output array in which to place the result. It must
    have the same shape and buffer length as the expected output
    but the type will be cast if necessary. See `doc.ufuncs`
    (Section "Output arguments") for more details.

Returns
-------
cumsum_along_axis : ndarray.
    A new array holding the result is returned unless `out` is
    specified, in which case a reference to `out` is returned. The
    result has the same size as `a`, and the same shape as `a` if
    `axis` is not None or `a` is a 1-d array.

See Also
--------
sum : Sum array elements.

trapz : Integration of array values using the composite trapezoidal rule.

diff :  Calculate the n-th order discrete difference along given axis.

Notes
-----
Arithmetic is modular when using integer types, and no error is
raised on overflow.

Examples
--------
>>> a = np.array([[1,2,3], [4,5,6]])
>>> a
array([[1, 2, 3],
       [4, 5, 6]])
>>> np.cumsum(a)
array([ 1,  3,  6, 10, 15, 21])
>>> np.cumsum(a, dtype=float)     # specifies type of output value(s)
array([  1.,   3.,   6.,  10.,  15.,  21.])

>>> np.cumsum(a,axis=0)      # sum over rows for each of the 3 columns
array([[1, 2, 3],
       [5, 7, 9]])
>>> np.cumsum(a,axis=1)      # sum over columns for each of the 2 rows
array([[ 1,  3,  6],
       [ 4,  9, 15]])


def cumproduct(a, axis=None, dtype=None, out=None):

try:<EOL><INDENT>cumprod = a.cumprod<EOL><DEDENT>except AttributeError:<EOL><INDENT>return _wrapit(a, '<STR_LIT>', axis, dtype, out)<EOL><DEDENT>return cumprod(axis, dtype, out)<EOL>

Return the cumulative product over the given axis.

See Also
--------
cumprod : equivalent function; see for details.


try:<EOL><INDENT>ptp = a.ptp<EOL><DEDENT>except AttributeError:<EOL><INDENT>return _wrapit(a, '<STR_LIT>', axis, out)<EOL><DEDENT>return ptp(axis, out)<EOL>

Range of values (maximum - minimum) along an axis.

The name of the function comes from the acronym for 'peak to peak'.

Parameters
----------
a : array_like
    Input values.
axis : int, optional
    Axis along which to find the peaks.  By default, flatten the
    array.
out : array_like
    Alternative output array in which to place the result. It must
    have the same shape and buffer length as the expected output,
    but the type of the output values will be cast if necessary.

Returns
-------
ptp : ndarray
    A new array holding the result, unless `out` was
    specified, in which case a reference to `out` is returned.

Examples
--------
>>> x = np.arange(4).reshape((2,2))
>>> x
array([[0, 1],
       [2, 3]])

>>> np.ptp(x, axis=0)
array([2, 2])

>>> np.ptp(x, axis=1)
array([1, 1])


def amax(a, axis=None, out=None, keepdims=False):

if type(a) is not mu.ndarray:<EOL><INDENT>try:<EOL><INDENT>amax = a.max<EOL><DEDENT>except AttributeError:<EOL><INDENT>return _methods._amax(a, axis=axis,<EOL>out=out, keepdims=keepdims)<EOL><DEDENT>return amax(axis=axis, out=out)<EOL><DEDENT>else:<EOL><INDENT>return _methods._amax(a, axis=axis,<EOL>out=out, keepdims=keepdims)<EOL><DEDENT>

Return the maximum of an array or maximum along an axis.

Parameters
----------
a : array_like
    Input data.
axis : int, optional
    Axis along which to operate.  By default, flattened input is used.
out : ndarray, optional
    Alternative output array in which to place the result.  Must
    be of the same shape and buffer length as the expected output.
    See `doc.ufuncs` (Section "Output arguments") for more details.
keepdims : bool, optional
    If this is set to True, the axes which are reduced are left
    in the result as dimensions with size one. With this option,
    the result will broadcast correctly against the original `arr`.

Returns
-------
amax : ndarray or scalar
    Maximum of `a`. If `axis` is None, the result is a scalar value.
    If `axis` is given, the result is an array of dimension
    ``a.ndim - 1``.

See Also
--------
amin :
    The minimum value of an array along a given axis, propagating any NaNs.
nanmax :
    The maximum value of an array along a given axis, ignoring any NaNs.
maximum :
    Element-wise maximum of two arrays, propagating any NaNs.
fmax :
    Element-wise maximum of two arrays, ignoring any NaNs.
argmax :
    Return the indices of the maximum values.

nanmin, minimum, fmin

Notes
-----
NaN values are propagated, that is if at least one item is NaN, the
corresponding max value will be NaN as well. To ignore NaN values
(MATLAB behavior), please use nanmax.

Don't use `amax` for element-wise comparison of 2 arrays; when
``a.shape[0]`` is 2, ``maximum(a[0], a[1])`` is faster than
``amax(a, axis=0)``.

Examples
--------
>>> a = np.arange(4).reshape((2,2))
>>> a
array([[0, 1],
       [2, 3]])
>>> np.amax(a)           # Maximum of the flattened array
3
>>> np.amax(a, axis=0)   # Maxima along the first axis
array([2, 3])
>>> np.amax(a, axis=1)   # Maxima along the second axis
array([1, 3])

>>> b = np.arange(5, dtype=np.float)
>>> b[2] = np.NaN
>>> np.amax(b)
nan
>>> np.nanmax(b)
4.0


def amin(a, axis=None, out=None, keepdims=False):

if type(a) is not mu.ndarray:<EOL><INDENT>try:<EOL><INDENT>amin = a.min<EOL><DEDENT>except AttributeError:<EOL><INDENT>return _methods._amin(a, axis=axis,<EOL>out=out, keepdims=keepdims)<EOL><DEDENT>return amin(axis=axis, out=out)<EOL><DEDENT>else:<EOL><INDENT>return _methods._amin(a, axis=axis,<EOL>out=out, keepdims=keepdims)<EOL><DEDENT>

Return the minimum of an array or minimum along an axis.

Parameters
----------
a : array_like
    Input data.
axis : int, optional
    Axis along which to operate.  By default, flattened input is used.
out : ndarray, optional
    Alternative output array in which to place the result.  Must
    be of the same shape and buffer length as the expected output.
    See `doc.ufuncs` (Section "Output arguments") for more details.
keepdims : bool, optional
    If this is set to True, the axes which are reduced are left
    in the result as dimensions with size one. With this option,
    the result will broadcast correctly against the original `arr`.

Returns
-------
amin : ndarray or scalar
    Minimum of `a`. If `axis` is None, the result is a scalar value.
    If `axis` is given, the result is an array of dimension
    ``a.ndim - 1``.

See Also
--------
amax :
    The maximum value of an array along a given axis, propagating any NaNs.
nanmin :
    The minimum value of an array along a given axis, ignoring any NaNs.
minimum :
    Element-wise minimum of two arrays, propagating any NaNs.
fmin :
    Element-wise minimum of two arrays, ignoring any NaNs.
argmin :
    Return the indices of the minimum values.

nanmax, maximum, fmax

Notes
-----
NaN values are propagated, that is if at least one item is NaN, the
corresponding min value will be NaN as well. To ignore NaN values
(MATLAB behavior), please use nanmin.

Don't use `amin` for element-wise comparison of 2 arrays; when
``a.shape[0]`` is 2, ``minimum(a[0], a[1])`` is faster than
``amin(a, axis=0)``.

Examples
--------
>>> a = np.arange(4).reshape((2,2))
>>> a
array([[0, 1],
       [2, 3]])
>>> np.amin(a)           # Minimum of the flattened array
0
>>> np.amin(a, axis=0)   # Minima along the first axis
array([0, 1])
>>> np.amin(a, axis=1)   # Minima along the second axis
array([0, 2])

>>> b = np.arange(5, dtype=np.float)
>>> b[2] = np.NaN
>>> np.amin(b)
nan
>>> np.nanmin(b)
0.0


try:<EOL><INDENT>return len(a)<EOL><DEDENT>except TypeError:<EOL><INDENT>return len(array(a, ndmin=<NUM_LIT:1>))<EOL><DEDENT>

Return the length of the first dimension of the input array.

Parameters
----------
a : array_like
   Input array.

Returns
-------
alen : int
   Length of the first dimension of `a`.

See Also
--------
shape, size

Examples
--------
>>> a = np.zeros((7,4,5))
>>> a.shape[0]
7
>>> np.alen(a)
7


def prod(a, axis=None, dtype=None, out=None, keepdims=False):

if type(a) is not mu.ndarray:<EOL><INDENT>try:<EOL><INDENT>prod = a.prod<EOL><DEDENT>except AttributeError:<EOL><INDENT>return _methods._prod(a, axis=axis, dtype=dtype,<EOL>out=out, keepdims=keepdims)<EOL><DEDENT>return prod(axis=axis, dtype=dtype, out=out)<EOL><DEDENT>else:<EOL><INDENT>return _methods._prod(a, axis=axis, dtype=dtype,<EOL>out=out, keepdims=keepdims)<EOL><DEDENT>

Return the product of array elements over a given axis.

Parameters
----------
a : array_like
    Input data.
axis : None or int or tuple of ints, optional
    Axis or axes along which a product is performed.
    The default (`axis` = `None`) is perform a product over all
    the dimensions of the input array. `axis` may be negative, in
    which case it counts from the last to the first axis.

    .. versionadded:: 1.7.0

    If this is a tuple of ints, a product is performed on multiple
    axes, instead of a single axis or all the axes as before.
dtype : data-type, optional
    The data-type of the returned array, as well as of the accumulator
    in which the elements are multiplied.  By default, if `a` is of
    integer type, `dtype` is the default platform integer. (Note: if
    the type of `a` is unsigned, then so is `dtype`.)  Otherwise,
    the dtype is the same as that of `a`.
out : ndarray, optional
    Alternative output array in which to place the result. It must have
    the same shape as the expected output, but the type of the
    output values will be cast if necessary.
keepdims : bool, optional
    If this is set to True, the axes which are reduced are left
    in the result as dimensions with size one. With this option,
    the result will broadcast correctly against the original `arr`.

Returns
-------
product_along_axis : ndarray, see `dtype` parameter above.
    An array shaped as `a` but with the specified axis removed.
    Returns a reference to `out` if specified.

See Also
--------
ndarray.prod : equivalent method
numpy.doc.ufuncs : Section "Output arguments"

Notes
-----
Arithmetic is modular when using integer types, and no error is
raised on overflow.  That means that, on a 32-bit platform:

>>> x = np.array([536870910, 536870910, 536870910, 536870910])
>>> np.prod(x) #random
16

Examples
--------
By default, calculate the product of all elements:

>>> np.prod([1.,2.])
2.0

Even when the input array is two-dimensional:

>>> np.prod([[1.,2.],[3.,4.]])
24.0

But we can also specify the axis over which to multiply:

>>> np.prod([[1.,2.],[3.,4.]], axis=1)
array([  2.,  12.])

If the type of `x` is unsigned, then the output type is
the unsigned platform integer:

>>> x = np.array([1, 2, 3], dtype=np.uint8)
>>> np.prod(x).dtype == np.uint
True

If `x` is of a signed integer type, then the output type
is the default platform integer:

>>> x = np.array([1, 2, 3], dtype=np.int8)
>>> np.prod(x).dtype == np.int
True


def cumprod(a, axis=None, dtype=None, out=None):

Return the cumulative product of elements along a given axis.

Parameters
----------
a : array_like
    Input array.
axis : int, optional
    Axis along which the cumulative product is computed.  By default
    the input is flattened.
dtype : dtype, optional
    Type of the returned array, as well as of the accumulator in which
    the elements are multiplied.  If *dtype* is not specified, it
    defaults to the dtype of `a`, unless `a` has an integer dtype with
    a precision less than that of the default platform integer.  In
    that case, the default platform integer is used instead.
out : ndarray, optional
    Alternative output array in which to place the result. It must
    have the same shape and buffer length as the expected output
    but the type of the resulting values will be cast if necessary.

Returns
-------
cumprod : ndarray
    A new array holding the result is returned unless `out` is
    specified, in which case a reference to out is returned.

See Also
--------
numpy.doc.ufuncs : Section "Output arguments"

Notes
-----
Arithmetic is modular when using integer types, and no error is
raised on overflow.

Examples
--------
>>> a = np.array([1,2,3])
>>> np.cumprod(a) # intermediate results 1, 1*2
...               # total product 1*2*3 = 6
array([1, 2, 6])
>>> a = np.array([[1, 2, 3], [4, 5, 6]])
>>> np.cumprod(a, dtype=float) # specify type of output
array([   1.,    2.,    6.,   24.,  120.,  720.])

The cumulative product for each column (i.e., over the rows) of `a`:

>>> np.cumprod(a, axis=0)
array([[ 1,  2,  3],
       [ 4, 10, 18]])

The cumulative product for each row (i.e. over the columns) of `a`:

>>> np.cumprod(a,axis=1)
array([[  1,   2,   6],
       [  4,  20, 120]])


try:<EOL><INDENT>return a.ndim<EOL><DEDENT>except AttributeError:<EOL><INDENT>return asarray(a).ndim<EOL><DEDENT>

Return the number of dimensions of an array.

Parameters
----------
a : array_like
    Input array.  If it is not already an ndarray, a conversion is
    attempted.

Returns
-------
number_of_dimensions : int
    The number of dimensions in `a`.  Scalars are zero-dimensional.

See Also
--------
ndarray.ndim : equivalent method
shape : dimensions of array
ndarray.shape : dimensions of array

Examples
--------
>>> np.ndim([[1,2,3],[4,5,6]])
2
>>> np.ndim(np.array([[1,2,3],[4,5,6]]))
2
>>> np.ndim(1)
0


warnings.warn(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>",<EOL>VisibleDeprecationWarning)<EOL>try:<EOL><INDENT>return a.ndim<EOL><DEDENT>except AttributeError:<EOL><INDENT>return asarray(a).ndim<EOL><DEDENT>

Return the number of dimensions of an array.

If `a` is not already an array, a conversion is attempted.
Scalars are zero dimensional.

.. note::
    This function is deprecated in NumPy 1.9 to avoid confusion with
    `numpy.linalg.matrix_rank`. The ``ndim`` attribute or function
    should be used instead.

Parameters
----------
a : array_like
    Array whose number of dimensions is desired. If `a` is not an array,
    a conversion is attempted.

Returns
-------
number_of_dimensions : int
    The number of dimensions in the array.

See Also
--------
ndim : equivalent function
ndarray.ndim : equivalent property
shape : dimensions of array
ndarray.shape : dimensions of array

Notes
-----
In the old Numeric package, `rank` was the term used for the number of
dimensions, but in Numpy `ndim` is used instead.

Examples
--------
>>> np.rank([1,2,3])
1
>>> np.rank(np.array([[1,2,3],[4,5,6]]))
2
>>> np.rank(1)
0


if axis is None:<EOL><INDENT>try:<EOL><INDENT>return a.size<EOL><DEDENT>except AttributeError:<EOL><INDENT>return asarray(a).size<EOL><DEDENT><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>return a.shape[axis]<EOL><DEDENT>except AttributeError:<EOL><INDENT>return asarray(a).shape[axis]<EOL><DEDENT><DEDENT>

Return the number of elements along a given axis.

Parameters
----------
a : array_like
    Input data.
axis : int, optional
    Axis along which the elements are counted.  By default, give
    the total number of elements.

Returns
-------
element_count : int
    Number of elements along the specified axis.

See Also
--------
shape : dimensions of array
ndarray.shape : dimensions of array
ndarray.size : number of elements in array

Examples
--------
>>> a = np.array([[1,2,3],[4,5,6]])
>>> np.size(a)
6
>>> np.size(a,1)
3
>>> np.size(a,0)
2


def around(a, decimals=<NUM_LIT:0>, out=None):

try:<EOL><INDENT>round = a.round<EOL><DEDENT>except AttributeError:<EOL><INDENT>return _wrapit(a, '<STR_LIT>', decimals, out)<EOL><DEDENT>return round(decimals, out)<EOL>

Evenly round to the given number of decimals.

Parameters
----------
a : array_like
    Input data.
decimals : int, optional
    Number of decimal places to round to (default: 0).  If
    decimals is negative, it specifies the number of positions to
    the left of the decimal point.
out : ndarray, optional
    Alternative output array in which to place the result. It must have
    the same shape as the expected output, but the type of the output
    values will be cast if necessary. See `doc.ufuncs` (Section
    "Output arguments") for details.

Returns
-------
rounded_array : ndarray
    An array of the same type as `a`, containing the rounded values.
    Unless `out` was specified, a new array is created.  A reference to
    the result is returned.

    The real and imaginary parts of complex numbers are rounded
    separately.  The result of rounding a float is a float.

See Also
--------
ndarray.round : equivalent method

ceil, fix, floor, rint, trunc

Notes
-----
For values exactly halfway between rounded decimal values, Numpy
rounds to the nearest even value. Thus 1.5 and 2.5 round to 2.0,
-0.5 and 0.5 round to 0.0, etc. Results may also be surprising due
to the inexact representation of decimal fractions in the IEEE
floating point standard [1]_ and errors introduced when scaling
by powers of ten.

References
----------
.. [1] "Lecture Notes on the Status of  IEEE 754", William Kahan,
       http://www.cs.berkeley.edu/~wkahan/ieee754status/IEEE754.PDF
.. [2] "How Futile are Mindless Assessments of
       Roundoff in Floating-Point Computation?", William Kahan,
       http://www.cs.berkeley.edu/~wkahan/Mindless.pdf

Examples
--------
>>> np.around([0.37, 1.64])
array([ 0.,  2.])
>>> np.around([0.37, 1.64], decimals=1)
array([ 0.4,  1.6])
>>> np.around([.5, 1.5, 2.5, 3.5, 4.5]) # rounds to nearest even value
array([ 0.,  2.,  2.,  4.,  4.])
>>> np.around([1,2,3,11], decimals=1) # ndarray of ints is returned
array([ 1,  2,  3, 11])
>>> np.around([1,2,3,11], decimals=-1)
array([ 0,  0,  0, 10])


def round_(a, decimals=<NUM_LIT:0>, out=None):

Round an array to the given number of decimals.

Refer to `around` for full documentation.

See Also
--------
around : equivalent function


def mean(a, axis=None, dtype=None, out=None, keepdims=False):

if type(a) is not mu.ndarray:<EOL><INDENT>try:<EOL><INDENT>mean = a.mean<EOL>return mean(axis=axis, dtype=dtype, out=out)<EOL><DEDENT>except AttributeError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>return _methods._mean(a, axis=axis, dtype=dtype,<EOL>out=out, keepdims=keepdims)<EOL>

Compute the arithmetic mean along the specified axis.

Returns the average of the array elements.  The average is taken over
the flattened array by default, otherwise over the specified axis.
`float64` intermediate and return values are used for integer inputs.

Parameters
----------
a : array_like
    Array containing numbers whose mean is desired. If `a` is not an
    array, a conversion is attempted.
axis : int, optional
    Axis along which the means are computed. The default is to compute
    the mean of the flattened array.
dtype : data-type, optional
    Type to use in computing the mean.  For integer inputs, the default
    is `float64`; for floating point inputs, it is the same as the
    input dtype.
out : ndarray, optional
    Alternate output array in which to place the result.  The default
    is ``None``; if provided, it must have the same shape as the
    expected output, but the type will be cast if necessary.
    See `doc.ufuncs` for details.
keepdims : bool, optional
    If this is set to True, the axes which are reduced are left
    in the result as dimensions with size one. With this option,
    the result will broadcast correctly against the original `arr`.

Returns
-------
m : ndarray, see dtype parameter above
    If `out=None`, returns a new array containing the mean values,
    otherwise a reference to the output array is returned.

See Also
--------
average : Weighted average
std, var, nanmean, nanstd, nanvar

Notes
-----
The arithmetic mean is the sum of the elements along the axis divided
by the number of elements.

Note that for floating-point input, the mean is computed using the
same precision the input has.  Depending on the input data, this can
cause the results to be inaccurate, especially for `float32` (see
example below).  Specifying a higher-precision accumulator using the
`dtype` keyword can alleviate this issue.

Examples
--------
>>> a = np.array([[1, 2], [3, 4]])
>>> np.mean(a)
2.5
>>> np.mean(a, axis=0)
array([ 2.,  3.])
>>> np.mean(a, axis=1)
array([ 1.5,  3.5])

In single precision, `mean` can be inaccurate:

>>> a = np.zeros((2, 512*512), dtype=np.float32)
>>> a[0, :] = 1.0
>>> a[1, :] = 0.1
>>> np.mean(a)
0.546875

Computing the mean in float64 is more accurate:

>>> np.mean(a, dtype=np.float64)
0.55000000074505806


def std(a, axis=None, dtype=None, out=None, ddof=<NUM_LIT:0>, keepdims=False):

if type(a) is not mu.ndarray:<EOL><INDENT>try:<EOL><INDENT>std = a.std<EOL>return std(axis=axis, dtype=dtype, out=out, ddof=ddof)<EOL><DEDENT>except AttributeError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>return _methods._std(a, axis=axis, dtype=dtype, out=out, ddof=ddof,<EOL>keepdims=keepdims)<EOL>

Compute the standard deviation along the specified axis.

Returns the standard deviation, a measure of the spread of a distribution,
of the array elements. The standard deviation is computed for the
flattened array by default, otherwise over the specified axis.

Parameters
----------
a : array_like
    Calculate the standard deviation of these values.
axis : int, optional
    Axis along which the standard deviation is computed. The default is
    to compute the standard deviation of the flattened array.
dtype : dtype, optional
    Type to use in computing the standard deviation. For arrays of
    integer type the default is float64, for arrays of float types it is
    the same as the array type.
out : ndarray, optional
    Alternative output array in which to place the result. It must have
    the same shape as the expected output but the type (of the calculated
    values) will be cast if necessary.
ddof : int, optional
    Means Delta Degrees of Freedom.  The divisor used in calculations
    is ``N - ddof``, where ``N`` represents the number of elements.
    By default `ddof` is zero.
keepdims : bool, optional
    If this is set to True, the axes which are reduced are left
    in the result as dimensions with size one. With this option,
    the result will broadcast correctly against the original `arr`.

Returns
-------
standard_deviation : ndarray, see dtype parameter above.
    If `out` is None, return a new array containing the standard deviation,
    otherwise return a reference to the output array.

See Also
--------
var, mean, nanmean, nanstd, nanvar
numpy.doc.ufuncs : Section "Output arguments"

Notes
-----
The standard deviation is the square root of the average of the squared
deviations from the mean, i.e., ``std = sqrt(mean(abs(x - x.mean())**2))``.

The average squared deviation is normally calculated as
``x.sum() / N``, where ``N = len(x)``.  If, however, `ddof` is specified,
the divisor ``N - ddof`` is used instead. In standard statistical
practice, ``ddof=1`` provides an unbiased estimator of the variance
of the infinite population. ``ddof=0`` provides a maximum likelihood
estimate of the variance for normally distributed variables. The
standard deviation computed in this function is the square root of
the estimated variance, so even with ``ddof=1``, it will not be an
unbiased estimate of the standard deviation per se.

Note that, for complex numbers, `std` takes the absolute
value before squaring, so that the result is always real and nonnegative.

For floating-point input, the *std* is computed using the same
precision the input has. Depending on the input data, this can cause
the results to be inaccurate, especially for float32 (see example below).
Specifying a higher-accuracy accumulator using the `dtype` keyword can
alleviate this issue.

Examples
--------
>>> a = np.array([[1, 2], [3, 4]])
>>> np.std(a)
1.1180339887498949
>>> np.std(a, axis=0)
array([ 1.,  1.])
>>> np.std(a, axis=1)
array([ 0.5,  0.5])

In single precision, std() can be inaccurate:

>>> a = np.zeros((2,512*512), dtype=np.float32)
>>> a[0,:] = 1.0
>>> a[1,:] = 0.1
>>> np.std(a)
0.45172946707416706

Computing the standard deviation in float64 is more accurate:

>>> np.std(a, dtype=np.float64)
0.44999999925552653


def var(a, axis=None, dtype=None, out=None, ddof=<NUM_LIT:0>,<EOL>keepdims=False):

if type(a) is not mu.ndarray:<EOL><INDENT>try:<EOL><INDENT>var = a.var<EOL>return var(axis=axis, dtype=dtype, out=out, ddof=ddof)<EOL><DEDENT>except AttributeError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>return _methods._var(a, axis=axis, dtype=dtype, out=out, ddof=ddof,<EOL>keepdims=keepdims)<EOL>

Compute the variance along the specified axis.

Returns the variance of the array elements, a measure of the spread of a
distribution.  The variance is computed for the flattened array by
default, otherwise over the specified axis.

Parameters
----------
a : array_like
    Array containing numbers whose variance is desired.  If `a` is not an
    array, a conversion is attempted.
axis : int, optional
    Axis along which the variance is computed.  The default is to compute
    the variance of the flattened array.
dtype : data-type, optional
    Type to use in computing the variance.  For arrays of integer type
    the default is `float32`; for arrays of float types it is the same as
    the array type.
out : ndarray, optional
    Alternate output array in which to place the result.  It must have
    the same shape as the expected output, but the type is cast if
    necessary.
ddof : int, optional
    "Delta Degrees of Freedom": the divisor used in the calculation is
    ``N - ddof``, where ``N`` represents the number of elements. By
    default `ddof` is zero.
keepdims : bool, optional
    If this is set to True, the axes which are reduced are left
    in the result as dimensions with size one. With this option,
    the result will broadcast correctly against the original `arr`.

Returns
-------
variance : ndarray, see dtype parameter above
    If ``out=None``, returns a new array containing the variance;
    otherwise, a reference to the output array is returned.

See Also
--------
std , mean, nanmean, nanstd, nanvar
numpy.doc.ufuncs : Section "Output arguments"

Notes
-----
The variance is the average of the squared deviations from the mean,
i.e.,  ``var = mean(abs(x - x.mean())**2)``.

The mean is normally calculated as ``x.sum() / N``, where ``N = len(x)``.
If, however, `ddof` is specified, the divisor ``N - ddof`` is used
instead.  In standard statistical practice, ``ddof=1`` provides an
unbiased estimator of the variance of a hypothetical infinite population.
``ddof=0`` provides a maximum likelihood estimate of the variance for
normally distributed variables.

Note that for complex numbers, the absolute value is taken before
squaring, so that the result is always real and nonnegative.

For floating-point input, the variance is computed using the same
precision the input has.  Depending on the input data, this can cause
the results to be inaccurate, especially for `float32` (see example
below).  Specifying a higher-accuracy accumulator using the ``dtype``
keyword can alleviate this issue.

Examples
--------
>>> a = np.array([[1,2],[3,4]])
>>> np.var(a)
1.25
>>> np.var(a, axis=0)
array([ 1.,  1.])
>>> np.var(a, axis=1)
array([ 0.25,  0.25])

In single precision, var() can be inaccurate:

>>> a = np.zeros((2,512*512), dtype=np.float32)
>>> a[0,:] = 1.0
>>> a[1,:] = 0.1
>>> np.var(a)
0.20405951142311096

Computing the variance in float64 is more accurate:

>>> np.var(a, dtype=np.float64)
0.20249999932997387
>>> ((1-0.55)**2 + (0.1-0.55)**2)/2
0.20250000000000001


lowered = s.translate(LOWER_TABLE)<EOL>return lowered<EOL>

Apply English case rules to convert ASCII strings to all lower case.

    This is an internal utility function to replace calls to str.lower() such
    that we can avoid changing behavior with changing locales. In particular,
    Turkish has distinct dotted and dotless variants of the Latin letter "I" in
    both lowercase and uppercase. Thus, "I".lower() != "i" in a "tr" locale.

    Parameters
    ----------
    s : str

    Returns
    -------
    lowered : str

    Examples
    --------
    >>> from numpy.core.numerictypes import english_lower
    >>> english_lower('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_')
    'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789_'
    >>> english_lower('')
    ''


uppered = s.translate(UPPER_TABLE)<EOL>return uppered<EOL>

Apply English case rules to convert ASCII strings to all upper case.

    This is an internal utility function to replace calls to str.upper() such
    that we can avoid changing behavior with changing locales. In particular,
    Turkish has distinct dotted and dotless variants of the Latin letter "I" in
    both lowercase and uppercase. Thus, "i".upper() != "I" in a "tr" locale.

    Parameters
    ----------
    s : str

    Returns
    -------
    uppered : str

    Examples
    --------
    >>> from numpy.core.numerictypes import english_upper
    >>> english_upper('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_')
    'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_'
    >>> english_upper('')
    ''


if s:<EOL><INDENT>return english_upper(s[<NUM_LIT:0>]) + s[<NUM_LIT:1>:]<EOL><DEDENT>else:<EOL><INDENT>return s<EOL><DEDENT>

Apply English case rules to convert the first character of an ASCII
    string to upper case.

    This is an internal utility function to replace calls to str.capitalize()
    such that we can avoid changing behavior with changing locales.

    Parameters
    ----------
    s : str

    Returns
    -------
    capitalized : str

    Examples
    --------
    >>> from numpy.core.numerictypes import english_capitalize
    >>> english_capitalize('int8')
    'Int8'
    >>> english_capitalize('Int8')
    'Int8'
    >>> english_capitalize('')
    ''


name = obj.__name__<EOL>base = '<STR_LIT>'<EOL>char = '<STR_LIT>'<EOL>try:<EOL><INDENT>if name[-<NUM_LIT:1>] == '<STR_LIT:_>':<EOL><INDENT>newname = name[:-<NUM_LIT:1>]<EOL><DEDENT>else:<EOL><INDENT>newname = name<EOL><DEDENT>info = typeinfo[english_upper(newname)]<EOL>assert(info[-<NUM_LIT:1>] == obj)  <EOL>bits = info[<NUM_LIT:2>]<EOL><DEDENT>except KeyError:     <EOL><INDENT>base, bits = _evalname(name)<EOL>char = base[<NUM_LIT:0>]<EOL><DEDENT>if name == '<STR_LIT>':<EOL><INDENT>char = '<STR_LIT:b>'<EOL>base = '<STR_LIT:bool>'<EOL><DEDENT>elif name=='<STR_LIT>':<EOL><INDENT>char = '<STR_LIT>'<EOL>base = '<STR_LIT>'<EOL><DEDENT>elif name=='<STR_LIT>':<EOL><INDENT>char = '<STR_LIT:O>'<EOL>base = '<STR_LIT:object>'<EOL>bits = <NUM_LIT:0><EOL><DEDENT>elif name=='<STR_LIT>':<EOL><INDENT>char = '<STR_LIT:M>'<EOL><DEDENT>elif name=='<STR_LIT>':<EOL><INDENT>char = '<STR_LIT:m>'<EOL><DEDENT>if sys.version_info[<NUM_LIT:0>] >= <NUM_LIT:3>:<EOL><INDENT>if name=='<STR_LIT>':<EOL><INDENT>char = '<STR_LIT:S>'<EOL>base = '<STR_LIT>'<EOL><DEDENT>elif name=='<STR_LIT>':<EOL><INDENT>char = '<STR_LIT>'<EOL>base = '<STR_LIT:str>'<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if name=='<STR_LIT>':<EOL><INDENT>char = '<STR_LIT:S>'<EOL>base = '<STR_LIT:string>'<EOL><DEDENT>elif name=='<STR_LIT>':<EOL><INDENT>char = '<STR_LIT>'<EOL>base = '<STR_LIT>'<EOL><DEDENT><DEDENT>bytes = bits // <NUM_LIT:8><EOL>if char != '<STR_LIT>' and bytes != <NUM_LIT:0>:<EOL><INDENT>char = "<STR_LIT>" % (char, bytes)<EOL><DEDENT>return base, bits, char<EOL>

Return a bit-width name for a given type object


g = obj2sctype(t)<EOL>if g is None:<EOL><INDENT>return t<EOL><DEDENT>t = g<EOL>name = t.__name__<EOL>base, bits = _evalname(name)<EOL>if bits == <NUM_LIT:0>:<EOL><INDENT>return t<EOL><DEDENT>else:<EOL><INDENT>return sctypes[base][-<NUM_LIT:1>]<EOL><DEDENT>

Return the scalar type of highest precision of the same kind as the input.

Parameters
----------
t : dtype or dtype specifier
    The input data type. This can be a `dtype` object or an object that
    is convertible to a `dtype`.

Returns
-------
out : dtype
    The highest precision data type of the same kind (`dtype.kind`) as `t`.

See Also
--------
obj2sctype, mintypecode, sctype2char
dtype

Examples
--------
>>> np.maximum_sctype(np.int)
<type 'numpy.int64'>
>>> np.maximum_sctype(np.uint8)
<type 'numpy.uint64'>
>>> np.maximum_sctype(np.complex)
<type 'numpy.complex192'>

>>> np.maximum_sctype(str)
<type 'numpy.string_'>

>>> np.maximum_sctype('i2')
<type 'numpy.int64'>
>>> np.maximum_sctype('f4')
<type 'numpy.float96'>


if not isinstance(rep, (type, dtype)):<EOL><INDENT>return False<EOL><DEDENT>try:<EOL><INDENT>res = obj2sctype(rep)<EOL>if res and res != object_:<EOL><INDENT>return True<EOL><DEDENT>return False<EOL><DEDENT>except:<EOL><INDENT>return False<EOL><DEDENT>

Determines whether the given object represents a scalar data-type.

Parameters
----------
rep : any
    If `rep` is an instance of a scalar dtype, True is returned. If not,
    False is returned.

Returns
-------
out : bool
    Boolean result of check whether `rep` is a scalar dtype.

See Also
--------
issubsctype, issubdtype, obj2sctype, sctype2char

Examples
--------
>>> np.issctype(np.int32)
True
>>> np.issctype(list)
False
>>> np.issctype(1.1)
False

Strings are also a scalar type:

>>> np.issctype(np.dtype('str'))
True


try:<EOL><INDENT>if issubclass(rep, generic):<EOL><INDENT>return rep<EOL><DEDENT><DEDENT>except TypeError:<EOL><INDENT>pass<EOL><DEDENT>if isinstance(rep, dtype):<EOL><INDENT>return rep.type<EOL><DEDENT>if isinstance(rep, type):<EOL><INDENT>return _python_type(rep)<EOL><DEDENT>if isinstance(rep, ndarray):<EOL><INDENT>return rep.dtype.type<EOL><DEDENT>try:<EOL><INDENT>res = dtype(rep)<EOL><DEDENT>except:<EOL><INDENT>return default<EOL><DEDENT>return res.type<EOL>

Return the scalar dtype or NumPy equivalent of Python type of an object.

Parameters
----------
rep : any
    The object of which the type is returned.
default : any, optional
    If given, this is returned for objects whose types can not be
    determined. If not given, None is returned for those objects.

Returns
-------
dtype : dtype or Python type
    The data type of `rep`.

See Also
--------
sctype2char, issctype, issubsctype, issubdtype, maximum_sctype

Examples
--------
>>> np.obj2sctype(np.int32)
<type 'numpy.int32'>
>>> np.obj2sctype(np.array([1., 2.]))
<type 'numpy.float64'>
>>> np.obj2sctype(np.array([1.j]))
<type 'numpy.complex128'>

>>> np.obj2sctype(dict)
<type 'numpy.object_'>
>>> np.obj2sctype('string')
<type 'numpy.string_'>

>>> np.obj2sctype(1, default=list)
<type 'list'>


try:<EOL><INDENT>return issubclass(arg1, arg2)<EOL><DEDENT>except TypeError:<EOL><INDENT>return False<EOL><DEDENT>

Determine if a class is a subclass of a second class.

`issubclass_` is equivalent to the Python built-in ``issubclass``,
except that it returns False instead of raising a TypeError is one
of the arguments is not a class.

Parameters
----------
arg1 : class
    Input class. True is returned if `arg1` is a subclass of `arg2`.
arg2 : class or tuple of classes.
    Input class. If a tuple of classes, True is returned if `arg1` is a
    subclass of any of the tuple elements.

Returns
-------
out : bool
    Whether `arg1` is a subclass of `arg2` or not.

See Also
--------
issubsctype, issubdtype, issctype

Examples
--------
>>> np.issubclass_(np.int32, np.int)
True
>>> np.issubclass_(np.int32, np.float)
False


return issubclass(obj2sctype(arg1), obj2sctype(arg2))<EOL>

Determine if the first argument is a subclass of the second argument.

Parameters
----------
arg1, arg2 : dtype or dtype specifier
    Data-types.

Returns
-------
out : bool
    The result.

See Also
--------
issctype, issubdtype,obj2sctype

Examples
--------
>>> np.issubsctype('S8', str)
True
>>> np.issubsctype(np.array([1]), np.int)
True
>>> np.issubsctype(np.array([1]), np.float)
False


if issubclass_(arg2, generic):<EOL><INDENT>return issubclass(dtype(arg1).type, arg2)<EOL><DEDENT>mro = dtype(arg2).type.mro()<EOL>if len(mro) > <NUM_LIT:1>:<EOL><INDENT>val = mro[<NUM_LIT:1>]<EOL><DEDENT>else:<EOL><INDENT>val = mro[<NUM_LIT:0>]<EOL><DEDENT>return issubclass(dtype(arg1).type, val)<EOL>

Returns True if first argument is a typecode lower/equal in type hierarchy.

Parameters
----------
arg1, arg2 : dtype_like
    dtype or string representing a typecode.

Returns
-------
out : bool

See Also
--------
issubsctype, issubclass_
numpy.core.numerictypes : Overview of numpy type hierarchy.

Examples
--------
>>> np.issubdtype('S1', str)
True
>>> np.issubdtype(np.float64, np.float32)
False


sctype = obj2sctype(sctype)<EOL>if sctype is None:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>return _sctype2char_dict[sctype]<EOL>

Return the string representation of a scalar dtype.

Parameters
----------
sctype : scalar dtype or object
    If a scalar dtype, the corresponding string character is
    returned. If an object, `sctype2char` tries to infer its scalar type
    and then return the corresponding string character.

Returns
-------
typechar : str
    The string character corresponding to the scalar type.

Raises
------
ValueError
    If `sctype` is an object for which the type can not be inferred.

See Also
--------
obj2sctype, issctype, issubsctype, mintypecode

Examples
--------
>>> for sctype in [np.int32, np.float, np.complex, np.string_, np.ndarray]:
...     print np.sctype2char(sctype)
l
d
D
S
O

>>> x = np.array([1., 2-1.j])
>>> np.sctype2char(x)
'D'
>>> np.sctype2char(list)
'O'


array_types = [dtype(x) for x in array_types]<EOL>scalar_types = [dtype(x) for x in scalar_types]<EOL>maxa = _can_coerce_all(array_types)<EOL>maxsc = _can_coerce_all(scalar_types)<EOL>if maxa is None:<EOL><INDENT>return maxsc<EOL><DEDENT>if maxsc is None:<EOL><INDENT>return maxa<EOL><DEDENT>try:<EOL><INDENT>index_a = _kind_list.index(maxa.kind)<EOL>index_sc = _kind_list.index(maxsc.kind)<EOL><DEDENT>except ValueError:<EOL><INDENT>return None<EOL><DEDENT>if index_sc > index_a:<EOL><INDENT>return _find_common_coerce(maxsc, maxa)<EOL><DEDENT>else:<EOL><INDENT>return maxa<EOL><DEDENT>

Determine common type following standard coercion rules.

Parameters
----------
array_types : sequence
    A list of dtypes or dtype convertible objects representing arrays.
scalar_types : sequence
    A list of dtypes or dtype convertible objects representing scalars.

Returns
-------
datatype : dtype
    The common data type, which is the maximum of `array_types` ignoring
    `scalar_types`, unless the maximum of `scalar_types` is of a
    different kind (`dtype.kind`). If the kind is not understood, then
    None is returned.

See Also
--------
dtype, common_type, can_cast, mintypecode

Examples
--------
>>> np.find_common_type([], [np.int64, np.float32, np.complex])
dtype('complex128')
>>> np.find_common_type([np.int64, np.float32], [])
dtype('float64')

The standard casting rules ensure that a scalar cannot up-cast an
array unless the scalar is of a fundamentally different kind of data
(i.e. under a different hierarchy in the data type hierarchy) then
the array:

>>> np.find_common_type([np.float32], [np.int64, np.float64])
dtype('float32')

Complex is of a different type, so it up-casts the float in the
`array_types` argument:

>>> np.find_common_type([np.float32], [np.complex])
dtype('complex128')

Type specifier strings are convertible to dtypes and can therefore
be used instead of dtypes:

>>> np.find_common_type(['f4', 'f4', 'i4'], ['c8'])
dtype('complex128')


dup = []<EOL>for i in range(len(list)):<EOL><INDENT>if (list[i] in list[i + <NUM_LIT:1>:]):<EOL><INDENT>if (list[i] not in dup):<EOL><INDENT>dup.append(list[i])<EOL><DEDENT><DEDENT><DEDENT>return dup<EOL>

Find duplication in a list, return a list of duplicated elements


def fromarrays(arrayList, dtype=None, shape=None, formats=None,<EOL>names=None, titles=None, aligned=False, byteorder=None):

arrayList = [sb.asarray(x) for x in arrayList]<EOL>if shape is None or shape == <NUM_LIT:0>:<EOL><INDENT>shape = arrayList[<NUM_LIT:0>].shape<EOL><DEDENT>if isinstance(shape, int):<EOL><INDENT>shape = (shape,)<EOL><DEDENT>if formats is None and dtype is None:<EOL><INDENT>formats = []<EOL>for obj in arrayList:<EOL><INDENT>if not isinstance(obj, ndarray):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>formats.append(obj.dtype.str)<EOL><DEDENT>formats = '<STR_LIT:U+002C>'.join(formats)<EOL><DEDENT>if dtype is not None:<EOL><INDENT>descr = sb.dtype(dtype)<EOL>_names = descr.names<EOL><DEDENT>else:<EOL><INDENT>parsed = format_parser(formats, names, titles, aligned, byteorder)<EOL>_names = parsed._names<EOL>descr = parsed._descr<EOL><DEDENT>if len(descr) != len(arrayList):<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>d0 = descr[<NUM_LIT:0>].shape<EOL>nn = len(d0)<EOL>if nn > <NUM_LIT:0>:<EOL><INDENT>shape = shape[:-nn]<EOL><DEDENT>for k, obj in enumerate(arrayList):<EOL><INDENT>nn = len(descr[k].shape)<EOL>testshape = obj.shape[:len(obj.shape) - nn]<EOL>if testshape != shape:<EOL><INDENT>raise ValueError("<STR_LIT>" % k)<EOL><DEDENT><DEDENT>_array = recarray(shape, descr)<EOL>for i in range(len(arrayList)):<EOL><INDENT>_array[_names[i]] = arrayList[i]<EOL><DEDENT>return _array<EOL>


def fromrecords(recList, dtype=None, shape=None, formats=None, names=None,<EOL>titles=None, aligned=False, byteorder=None):

nfields = len(recList[<NUM_LIT:0>])<EOL>if formats is None and dtype is None:  <EOL><INDENT>obj = sb.array(recList, dtype=object)<EOL>arrlist = [sb.array(obj[..., i].tolist()) for i in range(nfields)]<EOL>return fromarrays(arrlist, formats=formats, shape=shape, names=names,<EOL>titles=titles, aligned=aligned, byteorder=byteorder)<EOL><DEDENT>if dtype is not None:<EOL><INDENT>descr = sb.dtype((record, dtype))<EOL><DEDENT>else:<EOL><INDENT>descr = format_parser(formats, names, titles, aligned, byteorder)._descr<EOL><DEDENT>try:<EOL><INDENT>retval = sb.array(recList, dtype=descr)<EOL><DEDENT>except TypeError:  <EOL><INDENT>if (shape is None or shape == <NUM_LIT:0>):<EOL><INDENT>shape = len(recList)<EOL><DEDENT>if isinstance(shape, (int, long)):<EOL><INDENT>shape = (shape,)<EOL><DEDENT>if len(shape) > <NUM_LIT:1>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>_array = recarray(shape, descr)<EOL>for k in range(_array.size):<EOL><INDENT>_array[k] = tuple(recList[k])<EOL><DEDENT>return _array<EOL><DEDENT>else:<EOL><INDENT>if shape is not None and retval.shape != shape:<EOL><INDENT>retval.shape = shape<EOL><DEDENT><DEDENT>res = retval.view(recarray)<EOL>return res<EOL>

create a recarray from a list of records in text form

        The data in the same field can be heterogeneous, they will be promoted
        to the highest data type.  This method is intended for creating
        smaller record arrays.  If used to create large array without formats
        defined

        r=fromrecords([(2,3.,'abc')]*100000)

        it can be slow.

        If formats is None, then this will auto-detect formats. Use list of
        tuples rather than list of lists for faster processing.

    >>> r=np.core.records.fromrecords([(456,'dbe',1.2),(2,'de',1.3)],
    ... names='col1,col2,col3')
    >>> print r[0]
    (456, 'dbe', 1.2)
    >>> r.col1
    array([456,   2])
    >>> r.col2
    chararray(['dbe', 'de'],
          dtype='|S3')
    >>> import pickle
    >>> print pickle.loads(pickle.dumps(r))
    [(456, 'dbe', 1.2) (2, 'de', 1.3)]


def fromstring(datastring, dtype=None, shape=None, offset=<NUM_LIT:0>, formats=None,<EOL>names=None, titles=None, aligned=False, byteorder=None):

if dtype is None and formats is None:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if dtype is not None:<EOL><INDENT>descr = sb.dtype(dtype)<EOL><DEDENT>else:<EOL><INDENT>descr = format_parser(formats, names, titles, aligned, byteorder)._descr<EOL><DEDENT>itemsize = descr.itemsize<EOL>if (shape is None or shape == <NUM_LIT:0> or shape == -<NUM_LIT:1>):<EOL><INDENT>shape = (len(datastring) - offset) / itemsize<EOL><DEDENT>_array = recarray(shape, descr, buf=datastring, offset=offset)<EOL>return _array<EOL>

create a (read-only) record array from binary data contained in
    a string


def fromfile(fd, dtype=None, shape=None, offset=<NUM_LIT:0>, formats=None,<EOL>names=None, titles=None, aligned=False, byteorder=None):

if (shape is None or shape == <NUM_LIT:0>):<EOL><INDENT>shape = (-<NUM_LIT:1>,)<EOL><DEDENT>elif isinstance(shape, (int, long)):<EOL><INDENT>shape = (shape,)<EOL><DEDENT>name = <NUM_LIT:0><EOL>if isinstance(fd, str):<EOL><INDENT>name = <NUM_LIT:1><EOL>fd = open(fd, '<STR_LIT:rb>')<EOL><DEDENT>if (offset > <NUM_LIT:0>):<EOL><INDENT>fd.seek(offset, <NUM_LIT:1>)<EOL><DEDENT>size = get_remaining_size(fd)<EOL>if dtype is not None:<EOL><INDENT>descr = sb.dtype(dtype)<EOL><DEDENT>else:<EOL><INDENT>descr = format_parser(formats, names, titles, aligned, byteorder)._descr<EOL><DEDENT>itemsize = descr.itemsize<EOL>shapeprod = sb.array(shape).prod()<EOL>shapesize = shapeprod * itemsize<EOL>if shapesize < <NUM_LIT:0>:<EOL><INDENT>shape = list(shape)<EOL>shape[ shape.index(-<NUM_LIT:1>) ] = size / -shapesize<EOL>shape = tuple(shape)<EOL>shapeprod = sb.array(shape).prod()<EOL><DEDENT>nbytes = shapeprod * itemsize<EOL>if nbytes > size:<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>")<EOL><DEDENT>_array = recarray(shape, descr)<EOL>nbytesread = fd.readinto(_array.data)<EOL>if nbytesread != nbytes:<EOL><INDENT>raise IOError("<STR_LIT>")<EOL><DEDENT>if name:<EOL><INDENT>fd.close()<EOL><DEDENT>return _array<EOL>

Create an array from binary file data

    If file is a string then that file is opened, else it is assumed
    to be a file object.

    >>> from tempfile import TemporaryFile
    >>> a = np.empty(10,dtype='f8,i4,a5')
    >>> a[5] = (0.5,10,'abcde')
    >>>
    >>> fd=TemporaryFile()
    >>> a = a.newbyteorder('<')
    >>> a.tofile(fd)
    >>>
    >>> fd.seek(0)
    >>> r=np.core.records.fromfile(fd, formats='f8,i4,a5', shape=10,
    ... byteorder='<')
    >>> print r[5]
    (0.5, 10, 'abcde')
    >>> r.shape
    (10,)


def array(obj, dtype=None, shape=None, offset=<NUM_LIT:0>, strides=None, formats=None,<EOL>names=None, titles=None, aligned=False, byteorder=None, copy=True):

if (isinstance(obj, (type(None), str)) or isfileobj(obj))and (formats is None)and (dtype is None):<EOL><INDENT>raise ValueError("<STR_LIT>""<STR_LIT>")<EOL><DEDENT>kwds = {}<EOL>if dtype is not None:<EOL><INDENT>dtype = sb.dtype(dtype)<EOL><DEDENT>elif formats is not None:<EOL><INDENT>dtype = format_parser(formats, names, titles,<EOL>aligned, byteorder)._descr<EOL><DEDENT>else:<EOL><INDENT>kwds = {'<STR_LIT>': formats,<EOL>'<STR_LIT>' : names,<EOL>'<STR_LIT>' : titles,<EOL>'<STR_LIT>' : aligned,<EOL>'<STR_LIT>' : byteorder<EOL>}<EOL><DEDENT>if obj is None:<EOL><INDENT>if shape is None:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>return recarray(shape, dtype, buf=obj, offset=offset, strides=strides)<EOL><DEDENT>elif isinstance(obj, bytes):<EOL><INDENT>return fromstring(obj, dtype, shape=shape, offset=offset, **kwds)<EOL><DEDENT>elif isinstance(obj, (list, tuple)):<EOL><INDENT>if isinstance(obj[<NUM_LIT:0>], (tuple, list)):<EOL><INDENT>return fromrecords(obj, dtype=dtype, shape=shape, **kwds)<EOL><DEDENT>else:<EOL><INDENT>return fromarrays(obj, dtype=dtype, shape=shape, **kwds)<EOL><DEDENT><DEDENT>elif isinstance(obj, recarray):<EOL><INDENT>if dtype is not None and (obj.dtype != dtype):<EOL><INDENT>new = obj.view(dtype)<EOL><DEDENT>else:<EOL><INDENT>new = obj<EOL><DEDENT>if copy:<EOL><INDENT>new = new.copy()<EOL><DEDENT>return new<EOL><DEDENT>elif isfileobj(obj):<EOL><INDENT>return fromfile(obj, dtype=dtype, shape=shape, offset=offset)<EOL><DEDENT>elif isinstance(obj, ndarray):<EOL><INDENT>if dtype is not None and (obj.dtype != dtype):<EOL><INDENT>new = obj.view(dtype)<EOL><DEDENT>else:<EOL><INDENT>new = obj<EOL><DEDENT>if copy:<EOL><INDENT>new = new.copy()<EOL><DEDENT>res = new.view(recarray)<EOL>if issubclass(res.dtype.type, nt.void):<EOL><INDENT>res.dtype = sb.dtype((record, res.dtype))<EOL><DEDENT>return res<EOL><DEDENT>else:<EOL><INDENT>interface = getattr(obj, "<STR_LIT>", None)<EOL>if interface is None or not isinstance(interface, dict):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>obj = sb.array(obj)<EOL>if dtype is not None and (obj.dtype != dtype):<EOL><INDENT>obj = obj.view(dtype)<EOL><DEDENT>res = obj.view(recarray)<EOL>if issubclass(res.dtype.type, nt.void):<EOL><INDENT>res.dtype = sb.dtype((record, res.dtype))<EOL><DEDENT>return res<EOL><DEDENT>

Construct a record array from a wide-variety of objects.


def _parseFormats(self, formats, aligned=<NUM_LIT:0>):

if formats is None:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if isinstance(formats, list):<EOL><INDENT>if len(formats) < <NUM_LIT:2>:<EOL><INDENT>formats.append('<STR_LIT>')<EOL><DEDENT>formats = '<STR_LIT:U+002C>'.join(formats)<EOL><DEDENT>dtype = sb.dtype(formats, aligned)<EOL>fields = dtype.fields<EOL>if fields is None:<EOL><INDENT>dtype = sb.dtype([('<STR_LIT>', dtype)], aligned)<EOL>fields = dtype.fields<EOL><DEDENT>keys = dtype.names<EOL>self._f_formats = [fields[key][<NUM_LIT:0>] for key in keys]<EOL>self._offsets = [fields[key][<NUM_LIT:1>] for key in keys]<EOL>self._nfields = len(keys)<EOL>


def _setfieldnames(self, names, titles):

if (names):<EOL><INDENT>if (type(names) in [list, tuple]):<EOL><INDENT>pass<EOL><DEDENT>elif isinstance(names, str):<EOL><INDENT>names = names.split('<STR_LIT:U+002C>')<EOL><DEDENT>else:<EOL><INDENT>raise NameError("<STR_LIT>" % repr(names))<EOL><DEDENT>self._names = [n.strip() for n in names[:self._nfields]]<EOL><DEDENT>else:<EOL><INDENT>self._names = []<EOL><DEDENT>self._names += ['<STR_LIT>' % i for i in range(len(self._names),<EOL>self._nfields)]<EOL>_dup = find_duplicate(self._names)<EOL>if _dup:<EOL><INDENT>raise ValueError("<STR_LIT>" % _dup)<EOL><DEDENT>if (titles):<EOL><INDENT>self._titles = [n.strip() for n in titles[:self._nfields]]<EOL><DEDENT>else:<EOL><INDENT>self._titles = []<EOL>titles = []<EOL><DEDENT>if (self._nfields > len(titles)):<EOL><INDENT>self._titles += [None] * (self._nfields - len(titles))<EOL><DEDENT>

convert input field names into a list and assign to the _names
        attribute


<EOL>names = self.dtype.names<EOL>maxlen = max([len(name) for name in names])<EOL>rows = []<EOL>fmt = '<STR_LIT>' % maxlen<EOL>for name in names:<EOL><INDENT>rows.append(fmt % (name, getattr(self, name)))<EOL><DEDENT>return "<STR_LIT:\n>".join(rows)<EOL>


def __init__(self, float_conv=float,int_conv=int,<EOL>float_to_float=float,<EOL>float_to_str = lambda v:'<STR_LIT>' % v,<EOL>title = '<STR_LIT>'):

<EOL>with errstate(under='<STR_LIT:ignore>'):<EOL><INDENT>self._do_init(float_conv, int_conv, float_to_float, float_to_str, title)<EOL><DEDENT>

float_conv - convert integer to float (array)
int_conv   - convert float (array) to integer
float_to_float - convert float array to float
float_to_str - convert array float to str
title        - description of used floating point numbers


if a.ndim == <NUM_LIT:0>: a.shape = (<NUM_LIT:1>,)<EOL>return a<EOL>


if self.kind == '<STR_LIT:u>':<EOL><INDENT>return <NUM_LIT:0><EOL><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>val = iinfo._min_vals[self.key]<EOL><DEDENT>except KeyError:<EOL><INDENT>val = int(-(<NUM_LIT:1> << (self.bits-<NUM_LIT:1>)))<EOL>iinfo._min_vals[self.key] = val<EOL><DEDENT>return val<EOL><DEDENT>


try:<EOL><INDENT>val = iinfo._max_vals[self.key]<EOL><DEDENT>except KeyError:<EOL><INDENT>if self.kind == '<STR_LIT:u>':<EOL><INDENT>val = int((<NUM_LIT:1> << self.bits) - <NUM_LIT:1>)<EOL><DEDENT>else:<EOL><INDENT>val = int((<NUM_LIT:1> << (self.bits-<NUM_LIT:1>)) - <NUM_LIT:1>)<EOL><DEDENT>iinfo._max_vals[self.key] = val<EOL><DEDENT>return val<EOL>


return


def linspace(start, stop, num=<NUM_LIT:50>, endpoint=True, retstep=False, dtype=None):

num = int(num)<EOL>start = start * <NUM_LIT:1.><EOL>stop = stop * <NUM_LIT:1.><EOL>if dtype is None:<EOL><INDENT>dtype = result_type(start, stop, float(num))<EOL><DEDENT>if num <= <NUM_LIT:0>:<EOL><INDENT>return array([], dtype)<EOL><DEDENT>if endpoint:<EOL><INDENT>if num == <NUM_LIT:1>:<EOL><INDENT>return array([start], dtype=dtype)<EOL><DEDENT>step = (stop-start)/float((num-<NUM_LIT:1>))<EOL>y = _nx.arange(<NUM_LIT:0>, num, dtype=dtype) * step + start<EOL>y[-<NUM_LIT:1>] = stop<EOL><DEDENT>else:<EOL><INDENT>step = (stop-start)/float(num)<EOL>y = _nx.arange(<NUM_LIT:0>, num, dtype=dtype) * step + start<EOL><DEDENT>if retstep:<EOL><INDENT>return y.astype(dtype), step<EOL><DEDENT>else:<EOL><INDENT>return y.astype(dtype)<EOL><DEDENT>

Return evenly spaced numbers over a specified interval.

Returns `num` evenly spaced samples, calculated over the
interval [`start`, `stop` ].

The endpoint of the interval can optionally be excluded.

Parameters
----------
start : scalar
    The starting value of the sequence.
stop : scalar
    The end value of the sequence, unless `endpoint` is set to False.
    In that case, the sequence consists of all but the last of ``num + 1``
    evenly spaced samples, so that `stop` is excluded.  Note that the step
    size changes when `endpoint` is False.
num : int, optional
    Number of samples to generate. Default is 50.
endpoint : bool, optional
    If True, `stop` is the last sample. Otherwise, it is not included.
    Default is True.
retstep : bool, optional
    If True, return (`samples`, `step`), where `step` is the spacing
    between samples.
dtype : dtype, optional
    The type of the output array.  If `dtype` is not given, infer the data
    type from the other input arguments.

    .. versionadded:: 1.9.0

Returns
-------
samples : ndarray
    There are `num` equally spaced samples in the closed interval
    ``[start, stop]`` or the half-open interval ``[start, stop)``
    (depending on whether `endpoint` is True or False).
step : float
    Only returned if `retstep` is True

    Size of spacing between samples.

See Also
--------
arange : Similar to `linspace`, but uses a step size (instead of the
         number of samples).
logspace : Samples uniformly distributed in log space.

Examples
--------
>>> np.linspace(2.0, 3.0, num=5)
    array([ 2.  ,  2.25,  2.5 ,  2.75,  3.  ])
>>> np.linspace(2.0, 3.0, num=5, endpoint=False)
    array([ 2. ,  2.2,  2.4,  2.6,  2.8])
>>> np.linspace(2.0, 3.0, num=5, retstep=True)
    (array([ 2.  ,  2.25,  2.5 ,  2.75,  3.  ]), 0.25)

Graphical illustration:

>>> import matplotlib.pyplot as plt
>>> N = 8
>>> y = np.zeros(N)
>>> x1 = np.linspace(0, 10, N, endpoint=True)
>>> x2 = np.linspace(0, 10, N, endpoint=False)
>>> plt.plot(x1, y, 'o')
[<matplotlib.lines.Line2D object at 0x...>]
>>> plt.plot(x2, y + 0.5, 'o')
[<matplotlib.lines.Line2D object at 0x...>]
>>> plt.ylim([-0.5, 1])
(-0.5, 1)
>>> plt.show()


def logspace(start, stop, num=<NUM_LIT:50>, endpoint=True, base=<NUM_LIT>, dtype=None):

y = linspace(start, stop, num=num, endpoint=endpoint)<EOL>if dtype is None:<EOL><INDENT>return _nx.power(base, y)<EOL><DEDENT>return _nx.power(base, y).astype(dtype)<EOL>

Return numbers spaced evenly on a log scale.

In linear space, the sequence starts at ``base ** start``
(`base` to the power of `start`) and ends with ``base ** stop``
(see `endpoint` below).

Parameters
----------
start : float
    ``base ** start`` is the starting value of the sequence.
stop : float
    ``base ** stop`` is the final value of the sequence, unless `endpoint`
    is False.  In that case, ``num + 1`` values are spaced over the
    interval in log-space, of which all but the last (a sequence of
    length ``num``) are returned.
num : integer, optional
    Number of samples to generate.  Default is 50.
endpoint : boolean, optional
    If true, `stop` is the last sample. Otherwise, it is not included.
    Default is True.
base : float, optional
    The base of the log space. The step size between the elements in
    ``ln(samples) / ln(base)`` (or ``log_base(samples)``) is uniform.
    Default is 10.0.
dtype : dtype
    The type of the output array.  If `dtype` is not given, infer the data
    type from the other input arguments.

Returns
-------
samples : ndarray
    `num` samples, equally spaced on a log scale.

See Also
--------
arange : Similar to linspace, with the step size specified instead of the
         number of samples. Note that, when used with a float endpoint, the
         endpoint may or may not be included.
linspace : Similar to logspace, but with the samples uniformly distributed
           in linear space, instead of log space.

Notes
-----
Logspace is equivalent to the code

>>> y = np.linspace(start, stop, num=num, endpoint=endpoint)
... # doctest: +SKIP
>>> power(base, y).astype(dtype)
... # doctest: +SKIP

Examples
--------
>>> np.logspace(2.0, 3.0, num=4)
    array([  100.        ,   215.443469  ,   464.15888336,  1000.        ])
>>> np.logspace(2.0, 3.0, num=4, endpoint=False)
    array([ 100.        ,  177.827941  ,  316.22776602,  562.34132519])
>>> np.logspace(2.0, 3.0, num=4, base=2.0)
    array([ 4.        ,  5.0396842 ,  6.34960421,  8.        ])

Graphical illustration:

>>> import matplotlib.pyplot as plt
>>> N = 10
>>> x1 = np.logspace(0.1, 1, N, endpoint=True)
>>> x2 = np.logspace(0.1, 1, N, endpoint=False)
>>> y = np.zeros(N)
>>> plt.plot(x1, y, 'o')
[<matplotlib.lines.Line2D object at 0x...>]
>>> plt.plot(x2, y + 0.5, 'o')
[<matplotlib.lines.Line2D object at 0x...>]
>>> plt.ylim([-0.5, 1])
(-0.5, 1)
>>> plt.show()


for x in args:<EOL><INDENT>if (isinstance(x, _unicode)<EOL>or issubclass(numpy.asarray(x).dtype.type, unicode_)):<EOL><INDENT>return unicode_<EOL><DEDENT><DEDENT>return string_<EOL>

Helper function for determining the output type of some string
operations.

For an operation on two ndarrays, if at least one is unicode, the
result should be unicode.


return numpy.asarray(result.tolist())<EOL>

Helper function to cast a result back into a string or unicode array
if an object array must be used as an intermediary.


newargs = []<EOL>for chk in args:<EOL><INDENT>if chk is None:<EOL><INDENT>break<EOL><DEDENT>newargs.append(chk)<EOL><DEDENT>return newargs<EOL>

Helper function for delegating arguments to Python string
functions.

Many of the Python string operations that have optional arguments
do not use 'None' to indicate a default value.  In these cases,
we need to remove all `None` arguments, and those following them.


if issubclass(a.dtype.type, unicode_):<EOL><INDENT>return a.itemsize // <NUM_LIT:4><EOL><DEDENT>return a.itemsize<EOL>

Helper function that returns the number of characters per field in
a string or unicode array.  This is to abstract out the fact that
for a unicode array this is itemsize / 4.


return compare_chararrays(x1, x2, '<STR_LIT>', True)<EOL>

Return (x1 == x2) element-wise.

Unlike `numpy.equal`, this comparison is performed by first
stripping whitespace characters from the end of the string.  This
behavior is provided for backward-compatibility with numarray.

Parameters
----------
x1, x2 : array_like of str or unicode
    Input arrays of the same shape.

Returns
-------
out : {ndarray, bool}
    Output array of bools, or a single bool if x1 and x2 are scalars.

See Also
--------
not_equal, greater_equal, less_equal, greater, less


Return (x1 != x2) element-wise.

Unlike `numpy.not_equal`, this comparison is performed by first
stripping whitespace characters from the end of the string.  This
behavior is provided for backward-compatibility with numarray.

Parameters
----------
x1, x2 : array_like of str or unicode
    Input arrays of the same shape.

Returns
-------
out : {ndarray, bool}
    Output array of bools, or a single bool if x1 and x2 are scalars.

See Also
--------
equal, greater_equal, less_equal, greater, less


Return (x1 >= x2) element-wise.

Unlike `numpy.greater_equal`, this comparison is performed by
first stripping whitespace characters from the end of the string.
This behavior is provided for backward-compatibility with
numarray.

Parameters
----------
x1, x2 : array_like of str or unicode
    Input arrays of the same shape.

Returns
-------
out : {ndarray, bool}
    Output array of bools, or a single bool if x1 and x2 are scalars.

See Also
--------
equal, not_equal, less_equal, greater, less


Return (x1 <= x2) element-wise.

Unlike `numpy.less_equal`, this comparison is performed by first
stripping whitespace characters from the end of the string.  This
behavior is provided for backward-compatibility with numarray.

Parameters
----------
x1, x2 : array_like of str or unicode
    Input arrays of the same shape.

Returns
-------
out : {ndarray, bool}
    Output array of bools, or a single bool if x1 and x2 are scalars.

See Also
--------
equal, not_equal, greater_equal, greater, less


return compare_chararrays(x1, x2, '<STR_LIT:>>', True)<EOL>

Return (x1 > x2) element-wise.

Unlike `numpy.greater`, this comparison is performed by first
stripping whitespace characters from the end of the string.  This
behavior is provided for backward-compatibility with numarray.

Parameters
----------
x1, x2 : array_like of str or unicode
    Input arrays of the same shape.

Returns
-------
out : {ndarray, bool}
    Output array of bools, or a single bool if x1 and x2 are scalars.

See Also
--------
equal, not_equal, greater_equal, less_equal, less


return compare_chararrays(x1, x2, '<STR_LIT:<>', True)<EOL>

Return (x1 < x2) element-wise.

Unlike `numpy.greater`, this comparison is performed by first
stripping whitespace characters from the end of the string.  This
behavior is provided for backward-compatibility with numarray.

Parameters
----------
x1, x2 : array_like of str or unicode
    Input arrays of the same shape.

Returns
-------
out : {ndarray, bool}
    Output array of bools, or a single bool if x1 and x2 are scalars.

See Also
--------
equal, not_equal, greater_equal, less_equal, greater


return _vec_string(a, integer, '<STR_LIT>')<EOL>

Return len(a) element-wise.

Parameters
----------
a : array_like of str or unicode

Returns
-------
out : ndarray
    Output array of integers

See also
--------
__builtin__.len


arr1 = numpy.asarray(x1)<EOL>arr2 = numpy.asarray(x2)<EOL>out_size = _get_num_chars(arr1) + _get_num_chars(arr2)<EOL>dtype = _use_unicode(arr1, arr2)<EOL>return _vec_string(arr1, (dtype, out_size), '<STR_LIT>', (arr2,))<EOL>

Return element-wise string concatenation for two arrays of str or unicode.

Arrays `x1` and `x2` must have the same shape.

Parameters
----------
x1 : array_like of str or unicode
    Input array.
x2 : array_like of str or unicode
    Input array.

Returns
-------
add : ndarray
    Output array of `string_` or `unicode_`, depending on input types
    of the same shape as `x1` and `x2`.


a_arr = numpy.asarray(a)<EOL>i_arr = numpy.asarray(i)<EOL>if not issubclass(i_arr.dtype.type, integer):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>out_size = _get_num_chars(a_arr) * max(long(i_arr.max()), <NUM_LIT:0>)<EOL>return _vec_string(<EOL>a_arr, (a_arr.dtype.type, out_size), '<STR_LIT>', (i_arr,))<EOL>

Return (a * i), that is string multiple concatenation,
element-wise.

Values in `i` of less than 0 are treated as 0 (which yields an
empty string).

Parameters
----------
a : array_like of str or unicode

i : array_like of ints

Returns
-------
out : ndarray
    Output array of str or unicode, depending on input types


return _to_string_or_unicode_array(<EOL>_vec_string(a, object_, '<STR_LIT>', (values,)))<EOL>

Return (a % i), that is pre-Python 2.6 string formatting
(iterpolation), element-wise for a pair of array_likes of str
or unicode.

Parameters
----------
a : array_like of str or unicode

values : array_like of values
   These values will be element-wise interpolated into the string.

Returns
-------
out : ndarray
    Output array of str or unicode, depending on input types

See also
--------
str.__mod__


a_arr = numpy.asarray(a)<EOL>return _vec_string(a_arr, a_arr.dtype, '<STR_LIT>')<EOL>

Return a copy of `a` with only the first character of each element
capitalized.

Calls `str.capitalize` element-wise.

For 8-bit strings, this method is locale-dependent.

Parameters
----------
a : array_like of str or unicode
    Input array of strings to capitalize.

Returns
-------
out : ndarray
    Output array of str or unicode, depending on input
    types

See also
--------
str.capitalize

Examples
--------
>>> c = np.array(['a1b2','1b2a','b2a1','2a1b'],'S4'); c
array(['a1b2', '1b2a', 'b2a1', '2a1b'],
    dtype='|S4')
>>> np.char.capitalize(c)
array(['A1b2', '1b2a', 'B2a1', '2a1b'],
    dtype='|S4')


def center(a, width, fillchar='<STR_LIT:U+0020>'):

a_arr = numpy.asarray(a)<EOL>width_arr = numpy.asarray(width)<EOL>size = long(numpy.max(width_arr.flat))<EOL>if numpy.issubdtype(a_arr.dtype, numpy.string_):<EOL><INDENT>fillchar = asbytes(fillchar)<EOL><DEDENT>return _vec_string(<EOL>a_arr, (a_arr.dtype.type, size), '<STR_LIT>', (width_arr, fillchar))<EOL>

Return a copy of `a` with its elements centered in a string of
length `width`.

Calls `str.center` element-wise.

Parameters
----------
a : array_like of str or unicode

width : int
    The length of the resulting strings
fillchar : str or unicode, optional
    The padding character to use (default is space).

Returns
-------
out : ndarray
    Output array of str or unicode, depending on input
    types

See also
--------
str.center


def count(a, sub, start=<NUM_LIT:0>, end=None):

return _vec_string(a, integer, '<STR_LIT:count>', [sub, start] + _clean_args(end))<EOL>

Returns an array with the number of non-overlapping occurrences of
substring `sub` in the range [`start`, `end`].

Calls `str.count` element-wise.

Parameters
----------
a : array_like of str or unicode

sub : str or unicode
   The substring to search for.

start, end : int, optional
   Optional arguments `start` and `end` are interpreted as slice
   notation to specify the range in which to count.

Returns
-------
out : ndarray
    Output array of ints.

See also
--------
str.count

Examples
--------
>>> c = np.array(['aAaAaA', '  aA  ', 'abBABba'])
>>> c
array(['aAaAaA', '  aA  ', 'abBABba'],
    dtype='|S7')
>>> np.char.count(c, 'A')
array([3, 1, 1])
>>> np.char.count(c, 'aA')
array([3, 1, 0])
>>> np.char.count(c, 'A', start=1, end=4)
array([2, 1, 1])
>>> np.char.count(c, 'A', start=1, end=3)
array([1, 0, 0])


def decode(a, encoding=None, errors=None):

return _to_string_or_unicode_array(<EOL>_vec_string(a, object_, '<STR_LIT>', _clean_args(encoding, errors)))<EOL>

Calls `str.decode` element-wise.

The set of available codecs comes from the Python standard library,
and may be extended at runtime.  For more information, see the
:mod:`codecs` module.

Parameters
----------
a : array_like of str or unicode

encoding : str, optional
   The name of an encoding

errors : str, optional
   Specifies how to handle encoding errors

Returns
-------
out : ndarray

See also
--------
str.decode

Notes
-----
The type of the result will depend on the encoding specified.

Examples
--------
>>> c = np.array(['aAaAaA', '  aA  ', 'abBABba'])
>>> c
array(['aAaAaA', '  aA  ', 'abBABba'],
    dtype='|S7')
>>> np.char.encode(c, encoding='cp037')
array(['\\x81\\xc1\\x81\\xc1\\x81\\xc1', '@@\\x81\\xc1@@',
    '\\x81\\x82\\xc2\\xc1\\xc2\\x82\\x81'],
    dtype='|S7')


def encode(a, encoding=None, errors=None):

Calls `str.encode` element-wise.

The set of available codecs comes from the Python standard library,
and may be extended at runtime. For more information, see the codecs
module.

Parameters
----------
a : array_like of str or unicode

encoding : str, optional
   The name of an encoding

errors : str, optional
   Specifies how to handle encoding errors

Returns
-------
out : ndarray

See also
--------
str.encode

Notes
-----
The type of the result will depend on the encoding specified.


def endswith(a, suffix, start=<NUM_LIT:0>, end=None):

return _vec_string(<EOL>a, bool_, '<STR_LIT>', [suffix, start] + _clean_args(end))<EOL>

Returns a boolean array which is `True` where the string element
in `a` ends with `suffix`, otherwise `False`.

Calls `str.endswith` element-wise.

Parameters
----------
a : array_like of str or unicode

suffix : str

start, end : int, optional
    With optional `start`, test beginning at that position. With
    optional `end`, stop comparing at that position.

Returns
-------
out : ndarray
    Outputs an array of bools.

See also
--------
str.endswith

Examples
--------
>>> s = np.array(['foo', 'bar'])
>>> s[0] = 'foo'
>>> s[1] = 'bar'
>>> s
array(['foo', 'bar'],
    dtype='|S3')
>>> np.char.endswith(s, 'ar')
array([False,  True], dtype=bool)
>>> np.char.endswith(s, 'a', start=1, end=2)
array([False,  True], dtype=bool)


return _to_string_or_unicode_array(<EOL>_vec_string(a, object_, '<STR_LIT>', (tabsize,)))<EOL>

Return a copy of each string element where all tab characters are
replaced by one or more spaces.

Calls `str.expandtabs` element-wise.

Return a copy of each string element where all tab characters are
replaced by one or more spaces, depending on the current column
and the given `tabsize`. The column number is reset to zero after
each newline occurring in the string. This doesn't understand other
non-printing characters or escape sequences.

Parameters
----------
a : array_like of str or unicode
    Input array
tabsize : int, optional
    Replace tabs with `tabsize` number of spaces.  If not given defaults
    to 8 spaces.

Returns
-------
out : ndarray
    Output array of str or unicode, depending on input type

See also
--------
str.expandtabs


def find(a, sub, start=<NUM_LIT:0>, end=None):

return _vec_string(<EOL>a, integer, '<STR_LIT>', [sub, start] + _clean_args(end))<EOL>

For each element, return the lowest index in the string where
substring `sub` is found.

Calls `str.find` element-wise.

For each element, return the lowest index in the string where
substring `sub` is found, such that `sub` is contained in the
range [`start`, `end`].

Parameters
----------
a : array_like of str or unicode

sub : str or unicode

start, end : int, optional
    Optional arguments `start` and `end` are interpreted as in
    slice notation.

Returns
-------
out : ndarray or int
    Output array of ints.  Returns -1 if `sub` is not found.

See also
--------
str.find


def index(a, sub, start=<NUM_LIT:0>, end=None):

return _vec_string(<EOL>a, integer, '<STR_LIT:index>', [sub, start] + _clean_args(end))<EOL>

Like `find`, but raises `ValueError` when the substring is not found.

Calls `str.index` element-wise.

Parameters
----------
a : array_like of str or unicode

sub : str or unicode

start, end : int, optional

Returns
-------
out : ndarray
    Output array of ints.  Returns -1 if `sub` is not found.

See also
--------
find, str.find


return _vec_string(a, bool_, '<STR_LIT>')<EOL>

Returns true for each element if all characters in the string are
alphanumeric and there is at least one character, false otherwise.

Calls `str.isalnum` element-wise.

For 8-bit strings, this method is locale-dependent.

Parameters
----------
a : array_like of str or unicode

Returns
-------
out : ndarray
    Output array of str or unicode, depending on input type

See also
--------
str.isalnum


Returns true for each element if all characters in the string are
alphabetic and there is at least one character, false otherwise.

Calls `str.isalpha` element-wise.

For 8-bit strings, this method is locale-dependent.

Parameters
----------
a : array_like of str or unicode

Returns
-------
out : ndarray
    Output array of bools

See also
--------
str.isalpha


Returns true for each element if all characters in the string are
digits and there is at least one character, false otherwise.

Calls `str.isdigit` element-wise.

For 8-bit strings, this method is locale-dependent.

Parameters
----------
a : array_like of str or unicode

Returns
-------
out : ndarray
    Output array of bools

See also
--------
str.isdigit


Returns true for each element if all cased characters in the
string are lowercase and there is at least one cased character,
false otherwise.

Calls `str.islower` element-wise.

For 8-bit strings, this method is locale-dependent.

Parameters
----------
a : array_like of str or unicode

Returns
-------
out : ndarray
    Output array of bools

See also
--------
str.islower


Returns true for each element if there are only whitespace
characters in the string and there is at least one character,
false otherwise.

Calls `str.isspace` element-wise.

For 8-bit strings, this method is locale-dependent.

Parameters
----------
a : array_like of str or unicode

Returns
-------
out : ndarray
    Output array of bools

See also
--------
str.isspace


Returns true for each element if the element is a titlecased
string and there is at least one character, false otherwise.

Call `str.istitle` element-wise.

For 8-bit strings, this method is locale-dependent.

Parameters
----------
a : array_like of str or unicode

Returns
-------
out : ndarray
    Output array of bools

See also
--------
str.istitle


Returns true for each element if all cased characters in the
string are uppercase and there is at least one character, false
otherwise.

Call `str.isupper` element-wise.

For 8-bit strings, this method is locale-dependent.

Parameters
----------
a : array_like of str or unicode

Returns
-------
out : ndarray
    Output array of bools

See also
--------
str.isupper


return _to_string_or_unicode_array(<EOL>_vec_string(sep, object_, '<STR_LIT>', (seq,)))<EOL>

Return a string which is the concatenation of the strings in the
sequence `seq`.

Calls `str.join` element-wise.

Parameters
----------
sep : array_like of str or unicode
seq : array_like of str or unicode

Returns
-------
out : ndarray
    Output array of str or unicode, depending on input types

See also
--------
str.join


def ljust(a, width, fillchar='<STR_LIT:U+0020>'):

Return an array with the elements of `a` left-justified in a
string of length `width`.

Calls `str.ljust` element-wise.

Parameters
----------
a : array_like of str or unicode

width : int
    The length of the resulting strings
fillchar : str or unicode, optional
    The character to use for padding

Returns
-------
out : ndarray
    Output array of str or unicode, depending on input type

See also
--------
str.ljust


Return an array with the elements converted to lowercase.

Call `str.lower` element-wise.

For 8-bit strings, this method is locale-dependent.

Parameters
----------
a : array_like, {str, unicode}
    Input array.

Returns
-------
out : ndarray, {str, unicode}
    Output array of str or unicode, depending on input type

See also
--------
str.lower

Examples
--------
>>> c = np.array(['A1B C', '1BCA', 'BCA1']); c
array(['A1B C', '1BCA', 'BCA1'],
      dtype='|S5')
>>> np.char.lower(c)
array(['a1b c', '1bca', 'bca1'],
      dtype='|S5')


a_arr = numpy.asarray(a)<EOL>return _vec_string(a_arr, a_arr.dtype, '<STR_LIT>', (chars,))<EOL>

For each element in `a`, return a copy with the leading characters
removed.

Calls `str.lstrip` element-wise.

Parameters
----------
a : array-like, {str, unicode}
    Input array.

chars : {str, unicode}, optional
    The `chars` argument is a string specifying the set of
    characters to be removed. If omitted or None, the `chars`
    argument defaults to removing whitespace. The `chars` argument
    is not a prefix; rather, all combinations of its values are
    stripped.

Returns
-------
out : ndarray, {str, unicode}
    Output array of str or unicode, depending on input type

See also
--------
str.lstrip

Examples
--------
>>> c = np.array(['aAaAaA', '  aA  ', 'abBABba'])
>>> c
array(['aAaAaA', '  aA  ', 'abBABba'],
    dtype='|S7')

The 'a' variable is unstripped from c[1] because whitespace leading.

>>> np.char.lstrip(c, 'a')
array(['AaAaA', '  aA  ', 'bBABba'],
    dtype='|S7')

>>> np.char.lstrip(c, 'A') # leaves c unchanged
array(['aAaAaA', '  aA  ', 'abBABba'],
    dtype='|S7')
>>> (np.char.lstrip(c, ' ') == np.char.lstrip(c, '')).all()
... # XXX: is this a regression? this line now returns False
... # np.char.lstrip(c,'') does not modify c at all.
True
>>> (np.char.lstrip(c, ' ') == np.char.lstrip(c, None)).all()
True


return _to_string_or_unicode_array(<EOL>_vec_string(a, object_, '<STR_LIT>', (sep,)))<EOL>

Partition each element in `a` around `sep`.

Calls `str.partition` element-wise.

For each element in `a`, split the element as the first
occurrence of `sep`, and return 3 strings containing the part
before the separator, the separator itself, and the part after
the separator. If the separator is not found, return 3 strings
containing the string itself, followed by two empty strings.

Parameters
----------
a : array_like, {str, unicode}
    Input array
sep : {str, unicode}
    Separator to split each string element in `a`.

Returns
-------
out : ndarray, {str, unicode}
    Output array of str or unicode, depending on input type.
    The output array will have an extra dimension with 3
    elements per input element.

See also
--------
str.partition