return _to_string_or_unicode_array(<EOL>_vec_string(<EOL>a, object_, '<STR_LIT:replace>', [old, new] +_clean_args(count)))<EOL>

For each element in `a`, return a copy of the string with all
occurrences of substring `old` replaced by `new`.

Calls `str.replace` element-wise.

Parameters
----------
a : array-like of str or unicode

old, new : str or unicode

count : int, optional
    If the optional argument `count` is given, only the first
    `count` occurrences are replaced.

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

See also
--------
str.replace


def rfind(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 in `a`, return the highest index in the string
where substring `sub` is found, such that `sub` is contained
within [`start`, `end`].

Calls `str.rfind` element-wise.

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
   Output array of ints.  Return -1 on failure.

See also
--------
str.rfind


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

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

Calls `str.rindex` 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.

See also
--------
rfind, str.rindex


def rjust(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 an array with the elements of `a` right-justified in a
string of length `width`.

Calls `str.rjust` 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.rjust


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

Partition (split) each element around the right-most separator.

Calls `str.rpartition` element-wise.

For each element in `a`, split the element as the last
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 of str or unicode
    Input array
sep : str or unicode
    Right-most separator to split each element in array.

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

See also
--------
str.rpartition


<EOL>return _vec_string(<EOL>a, object_, '<STR_LIT>', [sep] + _clean_args(maxsplit))<EOL>

For each element in `a`, return a list of the words in the
string, using `sep` as the delimiter string.

Calls `str.rsplit` element-wise.

Except for splitting from the right, `rsplit`
behaves like `split`.

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

sep : str or unicode, optional
    If `sep` is not specified or `None`, any whitespace string
    is a separator.
maxsplit : int, optional
    If `maxsplit` is given, at most `maxsplit` splits are done,
    the rightmost ones.

Returns
-------
out : ndarray
   Array of list objects

See also
--------
str.rsplit, split


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 trailing
characters removed.

Calls `str.rstrip` element-wise.

Parameters
----------
a : array-like of str or unicode

chars : str or 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 suffix; rather, all combinations of its values are
   stripped.

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

See also
--------
str.rstrip

Examples
--------
>>> c = np.array(['aAaAaA', 'abBABba'], dtype='S7'); c
array(['aAaAaA', 'abBABba'],
    dtype='|S7')
>>> np.char.rstrip(c, 'a')
array(['aAaAaA', 'abBABb'],
    dtype='|S7')
>>> np.char.rstrip(c, 'A')
array(['aAaAa', 'abBABba'],
    dtype='|S7')


For each element in `a`, return a list of the words in the
string, using `sep` as the delimiter string.

Calls `str.rsplit` element-wise.

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

sep : str or unicode, optional
   If `sep` is not specified or `None`, any whitespace string is a
   separator.

maxsplit : int, optional
    If `maxsplit` is given, at most `maxsplit` splits are done.

Returns
-------
out : ndarray
    Array of list objects

See also
--------
str.split, rsplit


return _vec_string(<EOL>a, object_, '<STR_LIT>', _clean_args(keepends))<EOL>

For each element in `a`, return a list of the lines in the
element, breaking at line boundaries.

Calls `str.splitlines` element-wise.

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

keepends : bool, optional
    Line breaks are not included in the resulting list unless
    keepends is given and true.

Returns
-------
out : ndarray
    Array of list objects

See also
--------
str.splitlines


def startswith(a, prefix, start=<NUM_LIT:0>, end=None):

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

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

Calls `str.startswith` element-wise.

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

prefix : str

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

Returns
-------
out : ndarray
    Array of booleans

See also
--------
str.startswith


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

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

Calls `str.rstrip` element-wise.

Parameters
----------
a : array-like of str or unicode

chars : str or 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 or suffix; rather, all combinations of its
   values are stripped.

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

See also
--------
str.strip

Examples
--------
>>> c = np.array(['aAaAaA', '  aA  ', 'abBABba'])
>>> c
array(['aAaAaA', '  aA  ', 'abBABba'],
    dtype='|S7')
>>> np.char.strip(c)
array(['aAaAaA', 'aA', 'abBABba'],
    dtype='|S7')
>>> np.char.strip(c, 'a') # 'a' unstripped from c[1] because whitespace leads
array(['AaAaA', '  aA  ', 'bBABb'],
    dtype='|S7')
>>> np.char.strip(c, 'A') # 'A' unstripped from c[1] because (unprinted) ws trails
array(['aAaAa', '  aA  ', 'abBABba'],
    dtype='|S7')


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

Return element-wise a copy of the string with
uppercase characters converted to lowercase and vice versa.

Calls `str.swapcase` 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.swapcase

Examples
--------
>>> c=np.array(['a1B c','1b Ca','b Ca1','cA1b'],'S5'); c
array(['a1B c', '1b Ca', 'b Ca1', 'cA1b'],
    dtype='|S5')
>>> np.char.swapcase(c)
array(['A1b C', '1B cA', 'B cA1', 'Ca1B'],
    dtype='|S5')


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

Return element-wise title cased version of string or unicode.

Title case words start with uppercase characters, all remaining cased
characters are lowercase.

Calls `str.title` element-wise.

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

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

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

See also
--------
str.title

Examples
--------
>>> c=np.array(['a1b c','1b ca','b ca1','ca1b'],'S5'); c
array(['a1b c', '1b ca', 'b ca1', 'ca1b'],
    dtype='|S5')
>>> np.char.title(c)
array(['A1B C', '1B Ca', 'B Ca1', 'Ca1B'],
    dtype='|S5')


def translate(a, table, deletechars=None):

a_arr = numpy.asarray(a)<EOL>if issubclass(a_arr.dtype.type, unicode_):<EOL><INDENT>return _vec_string(<EOL>a_arr, a_arr.dtype, '<STR_LIT>', (table,))<EOL><DEDENT>else:<EOL><INDENT>return _vec_string(<EOL>a_arr, a_arr.dtype, '<STR_LIT>', [table] + _clean_args(deletechars))<EOL><DEDENT>

For each element in `a`, return a copy of the string where all
characters occurring in the optional argument `deletechars` are
removed, and the remaining characters have been mapped through the
given translation table.

Calls `str.translate` element-wise.

Parameters
----------
a : array-like of str or unicode

table : str of length 256

deletechars : str

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

See also
--------
str.translate


Return an array with the elements converted to uppercase.

Calls `str.upper` 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.upper

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


a_arr = numpy.asarray(a)<EOL>width_arr = numpy.asarray(width)<EOL>size = long(numpy.max(width_arr.flat))<EOL>return _vec_string(<EOL>a_arr, (a_arr.dtype.type, size), '<STR_LIT>', (width_arr,))<EOL>

Return the numeric string left-filled with zeros

Calls `str.zfill` element-wise.

Parameters
----------
a : array_like, {str, unicode}
    Input array.
width : int
    Width of string to left-fill elements in `a`.

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

See also
--------
str.zfill


if _use_unicode(a) != unicode_:<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>return _vec_string(a, bool_, '<STR_LIT>')<EOL>

For each element, return True if there are only numeric
characters in the element.

Calls `unicode.isnumeric` element-wise.

Numeric characters include digit characters, and all characters
that have the Unicode numeric value property, e.g. ``U+2155,
VULGAR FRACTION ONE FIFTH``.

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

Returns
-------
out : ndarray, bool
    Array of booleans of same shape as `a`.

See also
--------
unicode.isnumeric


For each element, return True if there are only decimal
characters in the element.

Calls `unicode.isdecimal` element-wise.

Decimal characters include digit characters, and all characters
that that can be used to form decimal-radix numbers,
e.g. ``U+0660, ARABIC-INDIC DIGIT ZERO``.

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

Returns
-------
out : ndarray, bool
    Array of booleans identical in shape to `a`.

See also
--------
unicode.isdecimal


def array(obj, itemsize=None, copy=True, unicode=None, order=None):

if isinstance(obj, (_bytes, _unicode)):<EOL><INDENT>if unicode is None:<EOL><INDENT>if isinstance(obj, _unicode):<EOL><INDENT>unicode = True<EOL><DEDENT>else:<EOL><INDENT>unicode = False<EOL><DEDENT><DEDENT>if itemsize is None:<EOL><INDENT>itemsize = _len(obj)<EOL><DEDENT>shape = _len(obj) // itemsize<EOL>if unicode:<EOL><INDENT>if sys.maxunicode == <NUM_LIT>:<EOL><INDENT>if sys.hexversion >= <NUM_LIT>:<EOL><INDENT>obj = obj.encode('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>if isinstance(obj, str):<EOL><INDENT>ascii = numpy.frombuffer(obj, '<STR_LIT>')<EOL>ucs4 = numpy.array(ascii, '<STR_LIT>')<EOL>obj = ucs4.data<EOL><DEDENT>else:<EOL><INDENT>ucs2 = numpy.frombuffer(obj, '<STR_LIT>')<EOL>ucs4 = numpy.array(ucs2, '<STR_LIT>')<EOL>obj = ucs4.data<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>obj = _unicode(obj)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>obj = _bytes(obj)<EOL><DEDENT>return chararray(shape, itemsize=itemsize, unicode=unicode,<EOL>buffer=obj, order=order)<EOL><DEDENT>if isinstance(obj, (list, tuple)):<EOL><INDENT>obj = numpy.asarray(obj)<EOL><DEDENT>if isinstance(obj, ndarray) and issubclass(obj.dtype.type, character):<EOL><INDENT>if not isinstance(obj, chararray):<EOL><INDENT>obj = obj.view(chararray)<EOL><DEDENT>if itemsize is None:<EOL><INDENT>itemsize = obj.itemsize<EOL>if issubclass(obj.dtype.type, unicode_):<EOL><INDENT>itemsize //= <NUM_LIT:4><EOL><DEDENT><DEDENT>if unicode is None:<EOL><INDENT>if issubclass(obj.dtype.type, unicode_):<EOL><INDENT>unicode = True<EOL><DEDENT>else:<EOL><INDENT>unicode = False<EOL><DEDENT><DEDENT>if unicode:<EOL><INDENT>dtype = unicode_<EOL><DEDENT>else:<EOL><INDENT>dtype = string_<EOL><DEDENT>if order is not None:<EOL><INDENT>obj = numpy.asarray(obj, order=order)<EOL><DEDENT>if (copy<EOL>or (itemsize != obj.itemsize)<EOL>or (not unicode and isinstance(obj, unicode_))<EOL>or (unicode and isinstance(obj, string_))):<EOL><INDENT>obj = obj.astype((dtype, long(itemsize)))<EOL><DEDENT>return obj<EOL><DEDENT>if isinstance(obj, ndarray) and issubclass(obj.dtype.type, object):<EOL><INDENT>if itemsize is None:<EOL><INDENT>obj = obj.tolist()<EOL><DEDENT><DEDENT>if unicode:<EOL><INDENT>dtype = unicode_<EOL><DEDENT>else:<EOL><INDENT>dtype = string_<EOL><DEDENT>if itemsize is None:<EOL><INDENT>val = narray(obj, dtype=dtype, order=order, subok=True)<EOL><DEDENT>else:<EOL><INDENT>val = narray(obj, dtype=(dtype, itemsize), order=order, subok=True)<EOL><DEDENT>return val.view(chararray)<EOL>

Create a `chararray`.

.. note::
   This class is provided for numarray backward-compatibility.
   New code (not concerned with numarray compatibility) should use
   arrays of type `string_` or `unicode_` and use the free functions
   in :mod:`numpy.char <numpy.core.defchararray>` for fast
   vectorized string operations instead.

Versus a regular Numpy array of type `str` or `unicode`, this
class adds the following functionality:

  1) values automatically have whitespace removed from the end
     when indexed

  2) comparison operators automatically remove whitespace from the
     end when comparing values

  3) vectorized string operations are provided as methods
     (e.g. `str.endswith`) and infix operators (e.g. ``+, *, %``)

Parameters
----------
obj : array of str or unicode-like

itemsize : int, optional
    `itemsize` is the number of characters per scalar in the
    resulting array.  If `itemsize` is None, and `obj` is an
    object array or a Python list, the `itemsize` will be
    automatically determined.  If `itemsize` is provided and `obj`
    is of type str or unicode, then the `obj` string will be
    chunked into `itemsize` pieces.

copy : bool, optional
    If true (default), then the object is copied.  Otherwise, a copy
    will only be made if __array__ returns a copy, if obj is a
    nested sequence, or if a copy is needed to satisfy any of the other
    requirements (`itemsize`, unicode, `order`, etc.).

unicode : bool, optional
    When true, the resulting `chararray` can contain Unicode
    characters, when false only 8-bit characters.  If unicode is
    `None` and `obj` is one of the following:

      - a `chararray`,
      - an ndarray of type `str` or `unicode`
      - a Python str or unicode object,

    then the unicode setting of the output array will be
    automatically determined.

order : {'C', 'F', 'A'}, optional
    Specify the order of the array.  If order is 'C' (default), then the
    array will be in C-contiguous order (last-index varies the
    fastest).  If order is 'F', then the returned array
    will be in Fortran-contiguous order (first-index varies the
    fastest).  If order is 'A', then the returned array may
    be in any order (either C-, Fortran-contiguous, or even
    discontiguous).


def asarray(obj, itemsize=None, unicode=None, order=None):

return array(obj, itemsize, copy=False,<EOL>unicode=unicode, order=order)<EOL>

Convert the input to a `chararray`, copying the data only if
necessary.

Versus a regular Numpy array of type `str` or `unicode`, this
class adds the following functionality:

  1) values automatically have whitespace removed from the end
     when indexed

  2) comparison operators automatically remove whitespace from the
     end when comparing values

  3) vectorized string operations are provided as methods
     (e.g. `str.endswith`) and infix operators (e.g. +, *, %)

Parameters
----------
obj : array of str or unicode-like

itemsize : int, optional
    `itemsize` is the number of characters per scalar in the
    resulting array.  If `itemsize` is None, and `obj` is an
    object array or a Python list, the `itemsize` will be
    automatically determined.  If `itemsize` is provided and `obj`
    is of type str or unicode, then the `obj` string will be
    chunked into `itemsize` pieces.

unicode : bool, optional
    When true, the resulting `chararray` can contain Unicode
    characters, when false only 8-bit characters.  If unicode is
    `None` and `obj` is one of the following:

      - a `chararray`,
      - an ndarray of type `str` or 'unicode`
      - a Python str or unicode object,

    then the unicode setting of the output array will be
    automatically determined.

order : {'C', 'F'}, optional
    Specify the order of the array.  If order is 'C' (default), then the
    array will be in C-contiguous order (last-index varies the
    fastest).  If order is 'F', then the returned array
    will be in Fortran-contiguous order (first-index varies the
    fastest).


return equal(self, other)<EOL>

Return (self == other) element-wise.

See also
--------
equal


return not_equal(self, other)<EOL>

Return (self != other) element-wise.

See also
--------
not_equal


return greater_equal(self, other)<EOL>

Return (self >= other) element-wise.

See also
--------
greater_equal


return less_equal(self, other)<EOL>

Return (self <= other) element-wise.

See also
--------
less_equal


return greater(self, other)<EOL>

Return (self > other) element-wise.

See also
--------
greater


return less(self, other)<EOL>

Return (self < other) element-wise.

See also
--------
less


return asarray(add(self, other))<EOL>

Return (self + other), that is string concatenation,
element-wise for a pair of array_likes of str or unicode.

See also
--------
add


return asarray(add(numpy.asarray(other), self))<EOL>

Return (other + self), that is string concatenation,
element-wise for a pair of array_likes of `string_` or `unicode_`.

See also
--------
add


return asarray(multiply(self, i))<EOL>

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

See also
--------
multiply


return asarray(multiply(self, i))<EOL>


return asarray(mod(self, i))<EOL>

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

See also
--------
mod


def argsort(self, axis=-<NUM_LIT:1>, kind='<STR_LIT>', order=None):

return self.__array__().argsort(axis, kind, order)<EOL>

Return the indices that sort the array lexicographically.

For full documentation see `numpy.argsort`, for which this method is
in fact merely a "thin wrapper."

Examples
--------
>>> c = np.array(['a1b c', '1b ca', 'b ca1', 'Ca1b'], 'S5')
>>> c = c.view(np.chararray); c
chararray(['a1b c', '1b ca', 'b ca1', 'Ca1b'],
      dtype='|S5')
>>> c[c.argsort()]
chararray(['1b ca', 'Ca1b', 'a1b c', 'b ca1'],
      dtype='|S5')


return asarray(capitalize(self))<EOL>

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

See also
--------
char.capitalize


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

return asarray(center(self, width, fillchar))<EOL>

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

See also
--------
center


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

return count(self, sub, start, end)<EOL>

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

See also
--------
char.count


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

return decode(self, encoding, errors)<EOL>

Calls `str.decode` element-wise.

See also
--------
char.decode


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

return encode(self, encoding, errors)<EOL>

Calls `str.encode` element-wise.

See also
--------
char.encode


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

return endswith(self, suffix, start, end)<EOL>

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

See also
--------
char.endswith


return asarray(expandtabs(self, tabsize))<EOL>

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

See also
--------
char.expandtabs


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

return find(self, sub, start, end)<EOL>

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

See also
--------
char.find


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

return index(self, sub, start, end)<EOL>

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

See also
--------
char.index


return isalnum(self)<EOL>

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

See also
--------
char.isalnum


return isalpha(self)<EOL>

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

See also
--------
char.isalpha


return isdigit(self)<EOL>

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

See also
--------
char.isdigit


return islower(self)<EOL>

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

See also
--------
char.islower


return isspace(self)<EOL>

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

See also
--------
char.isspace


return istitle(self)<EOL>

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

See also
--------
char.istitle


return isupper(self)<EOL>

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

See also
--------
char.isupper


return join(self, seq)<EOL>

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

See also
--------
char.join


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

return asarray(ljust(self, width, fillchar))<EOL>

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

See also
--------
char.ljust


return asarray(lower(self))<EOL>

Return an array with the elements of `self` converted to
lowercase.

See also
--------
char.lower


return asarray(lstrip(self, chars))<EOL>

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

See also
--------
char.lstrip


return asarray(partition(self, sep))<EOL>

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

See also
--------
partition


def replace(self, old, new, count=None):

return asarray(replace(self, old, new, count))<EOL>

For each element in `self`, return a copy of the string with all
occurrences of substring `old` replaced by `new`.

See also
--------
char.replace


def rfind(self, sub, start=<NUM_LIT:0>, end=None):

return rfind(self, sub, start, end)<EOL>

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

See also
--------
char.rfind


def rindex(self, sub, start=<NUM_LIT:0>, end=None):

return rindex(self, sub, start, end)<EOL>

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

See also
--------
char.rindex


def rjust(self, width, fillchar='<STR_LIT:U+0020>'):

return asarray(rjust(self, width, fillchar))<EOL>

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

See also
--------
char.rjust


return asarray(rpartition(self, sep))<EOL>

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

See also
--------
rpartition


def rsplit(self, sep=None, maxsplit=None):

return rsplit(self, sep, maxsplit)<EOL>

For each element in `self`, return a list of the words in
the string, using `sep` as the delimiter string.

See also
--------
char.rsplit


return asarray(rstrip(self, chars))<EOL>

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

See also
--------
char.rstrip


def split(self, sep=None, maxsplit=None):

return split(self, sep, maxsplit)<EOL>

For each element in `self`, return a list of the words in the
string, using `sep` as the delimiter string.

See also
--------
char.split


return splitlines(self, keepends)<EOL>

For each element in `self`, return a list of the lines in the
element, breaking at line boundaries.

See also
--------
char.splitlines


def startswith(self, prefix, start=<NUM_LIT:0>, end=None):

return startswith(self, prefix, start, end)<EOL>

Returns a boolean array which is `True` where the string element
in `self` starts with `prefix`, otherwise `False`.

See also
--------
char.startswith


return asarray(strip(self, chars))<EOL>

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

See also
--------
char.strip


return asarray(swapcase(self))<EOL>

For each element in `self`, return a copy of the string with
uppercase characters converted to lowercase and vice versa.

See also
--------
char.swapcase


return asarray(title(self))<EOL>

For each element in `self`, return a titlecased version of the
string: words start with uppercase characters, all remaining cased
characters are lowercase.

See also
--------
char.title


def translate(self, table, deletechars=None):

return asarray(translate(self, table, deletechars))<EOL>

For each element in `self`, return a copy of the string where
all characters occurring in the optional argument
`deletechars` are removed, and the remaining characters have
been mapped through the given translation table.

See also
--------
char.translate


return asarray(upper(self))<EOL>

Return an array with the elements of `self` converted to
uppercase.

See also
--------
char.upper


return asarray(zfill(self, width))<EOL>

Return the numeric string left-filled with zeros in a string of
length `width`.

See also
--------
char.zfill


return isnumeric(self)<EOL>

For each element in `self`, return True if there are only
numeric characters in the element.

See also
--------
char.isnumeric


return isdecimal(self)<EOL>

For each element in `self`, return True if there are only
decimal characters in the element.

See also
--------
char.isdecimal


res = []<EOL>for ary in arys:<EOL><INDENT>ary = asanyarray(ary)<EOL>if len(ary.shape) == <NUM_LIT:0> :<EOL><INDENT>result = ary.reshape(<NUM_LIT:1>)<EOL><DEDENT>else :<EOL><INDENT>result = ary<EOL><DEDENT>res.append(result)<EOL><DEDENT>if len(res) == <NUM_LIT:1>:<EOL><INDENT>return res[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>return res<EOL><DEDENT>

Convert inputs to arrays with at least one dimension.

Scalar inputs are converted to 1-dimensional arrays, whilst
higher-dimensional inputs are preserved.

Parameters
----------
arys1, arys2, ... : array_like
    One or more input arrays.

Returns
-------
ret : ndarray
    An array, or sequence of arrays, each with ``a.ndim >= 1``.
    Copies are made only if necessary.

See Also
--------
atleast_2d, atleast_3d

Examples
--------
>>> np.atleast_1d(1.0)
array([ 1.])

>>> x = np.arange(9.0).reshape(3,3)
>>> np.atleast_1d(x)
array([[ 0.,  1.,  2.],
       [ 3.,  4.,  5.],
       [ 6.,  7.,  8.]])
>>> np.atleast_1d(x) is x
True

>>> np.atleast_1d(1, [3, 4])
[array([1]), array([3, 4])]


res = []<EOL>for ary in arys:<EOL><INDENT>ary = asanyarray(ary)<EOL>if len(ary.shape) == <NUM_LIT:0> :<EOL><INDENT>result = ary.reshape(<NUM_LIT:1>, <NUM_LIT:1>)<EOL><DEDENT>elif len(ary.shape) == <NUM_LIT:1> :<EOL><INDENT>result = ary[newaxis,:]<EOL><DEDENT>else :<EOL><INDENT>result = ary<EOL><DEDENT>res.append(result)<EOL><DEDENT>if len(res) == <NUM_LIT:1>:<EOL><INDENT>return res[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>return res<EOL><DEDENT>

View inputs as arrays with at least two dimensions.

Parameters
----------
arys1, arys2, ... : array_like
    One or more array-like sequences.  Non-array inputs are converted
    to arrays.  Arrays that already have two or more dimensions are
    preserved.

Returns
-------
res, res2, ... : ndarray
    An array, or tuple of arrays, each with ``a.ndim >= 2``.
    Copies are avoided where possible, and views with two or more
    dimensions are returned.

See Also
--------
atleast_1d, atleast_3d

Examples
--------
>>> np.atleast_2d(3.0)
array([[ 3.]])

>>> x = np.arange(3.0)
>>> np.atleast_2d(x)
array([[ 0.,  1.,  2.]])
>>> np.atleast_2d(x).base is x
True

>>> np.atleast_2d(1, [1, 2], [[1, 2]])
[array([[1]]), array([[1, 2]]), array([[1, 2]])]


res = []<EOL>for ary in arys:<EOL><INDENT>ary = asanyarray(ary)<EOL>if len(ary.shape) == <NUM_LIT:0>:<EOL><INDENT>result = ary.reshape(<NUM_LIT:1>, <NUM_LIT:1>, <NUM_LIT:1>)<EOL><DEDENT>elif len(ary.shape) == <NUM_LIT:1>:<EOL><INDENT>result = ary[newaxis,:, newaxis]<EOL><DEDENT>elif len(ary.shape) == <NUM_LIT:2>:<EOL><INDENT>result = ary[:,:, newaxis]<EOL><DEDENT>else:<EOL><INDENT>result = ary<EOL><DEDENT>res.append(result)<EOL><DEDENT>if len(res) == <NUM_LIT:1>:<EOL><INDENT>return res[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>return res<EOL><DEDENT>

View inputs as arrays with at least three dimensions.

Parameters
----------
arys1, arys2, ... : array_like
    One or more array-like sequences.  Non-array inputs are converted to
    arrays.  Arrays that already have three or more dimensions are
    preserved.

Returns
-------
res1, res2, ... : ndarray
    An array, or tuple of arrays, each with ``a.ndim >= 3``.  Copies are
    avoided where possible, and views with three or more dimensions are
    returned.  For example, a 1-D array of shape ``(N,)`` becomes a view
    of shape ``(1, N, 1)``, and a 2-D array of shape ``(M, N)`` becomes a
    view of shape ``(M, N, 1)``.

See Also
--------
atleast_1d, atleast_2d

Examples
--------
>>> np.atleast_3d(3.0)
array([[[ 3.]]])

>>> x = np.arange(3.0)
>>> np.atleast_3d(x).shape
(1, 3, 1)

>>> x = np.arange(12.0).reshape(4,3)
>>> np.atleast_3d(x).shape
(4, 3, 1)
>>> np.atleast_3d(x).base is x
True

>>> for arr in np.atleast_3d([1, 2], [[1, 2]], [[[1, 2]]]):
...     print arr, arr.shape
...
[[[1]
  [2]]] (1, 2, 1)
[[[1]
  [2]]] (1, 2, 1)
[[[1 2]]] (1, 1, 2)


return _nx.concatenate([atleast_2d(_m) for _m in tup], <NUM_LIT:0>)<EOL>

Stack arrays in sequence vertically (row wise).

Take a sequence of arrays and stack them vertically to make a single
array. Rebuild arrays divided by `vsplit`.

Parameters
----------
tup : sequence of ndarrays
    Tuple containing arrays to be stacked. The arrays must have the same
    shape along all but the first axis.

Returns
-------
stacked : ndarray
    The array formed by stacking the given arrays.

See Also
--------
hstack : Stack arrays in sequence horizontally (column wise).
dstack : Stack arrays in sequence depth wise (along third dimension).
concatenate : Join a sequence of arrays together.
vsplit : Split array into a list of multiple sub-arrays vertically.

Notes
-----
Equivalent to ``np.concatenate(tup, axis=0)`` if `tup` contains arrays that
are at least 2-dimensional.

Examples
--------
>>> a = np.array([1, 2, 3])
>>> b = np.array([2, 3, 4])
>>> np.vstack((a,b))
array([[1, 2, 3],
       [2, 3, 4]])

>>> a = np.array([[1], [2], [3]])
>>> b = np.array([[2], [3], [4]])
>>> np.vstack((a,b))
array([[1],
       [2],
       [3],
       [2],
       [3],
       [4]])


arrs = [atleast_1d(_m) for _m in tup]<EOL>if arrs[<NUM_LIT:0>].ndim == <NUM_LIT:1>:<EOL><INDENT>return _nx.concatenate(arrs, <NUM_LIT:0>)<EOL><DEDENT>else:<EOL><INDENT>return _nx.concatenate(arrs, <NUM_LIT:1>)<EOL><DEDENT>

Stack arrays in sequence horizontally (column wise).

Take a sequence of arrays and stack them horizontally to make
a single array. Rebuild arrays divided by `hsplit`.

Parameters
----------
tup : sequence of ndarrays
    All arrays must have the same shape along all but the second axis.

Returns
-------
stacked : ndarray
    The array formed by stacking the given arrays.

See Also
--------
vstack : Stack arrays in sequence vertically (row wise).
dstack : Stack arrays in sequence depth wise (along third axis).
concatenate : Join a sequence of arrays together.
hsplit : Split array along second axis.

Notes
-----
Equivalent to ``np.concatenate(tup, axis=1)``

Examples
--------
>>> a = np.array((1,2,3))
>>> b = np.array((2,3,4))
>>> np.hstack((a,b))
array([1, 2, 3, 2, 3, 4])
>>> a = np.array([[1],[2],[3]])
>>> b = np.array([[2],[3],[4]])
>>> np.hstack((a,b))
array([[1, 2],
       [2, 3],
       [3, 4]])


if sys.platform == '<STR_LIT:win32>':<EOL><INDENT>return os.path.join(sys.prefix, "<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>return get_config_var('<STR_LIT>')<EOL><DEDENT>


return sys.platform == '<STR_LIT:win32>'<EOL>

Return True if the NPY_NO_SIGNAL symbol must be defined in configuration
    header.


<EOL>if sys.version[:<NUM_LIT:5>] < '<STR_LIT>':<EOL><INDENT>nosmp = <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>nosmp = os.environ['<STR_LIT>']<EOL>nosmp = <NUM_LIT:1><EOL><DEDENT>except KeyError:<EOL><INDENT>nosmp = <NUM_LIT:0><EOL><DEDENT><DEDENT>return nosmp == <NUM_LIT:1><EOL>

Return True if the NPY_NO_SMP symbol must be defined in public
    header (when SMP support cannot be reliably enabled).


if config.check_compiler_gcc4():<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT>

Return the define value to use for NPY_VISIBILITY_HIDDEN (may be empty
    string).


from distutils.version import LooseVersion<EOL>v = config.get_version('<STR_LIT>')<EOL>if v is None:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>pv = LooseVersion(vstring=v).version<EOL>if len(pv) > <NUM_LIT:3>:<EOL><INDENT>return False<EOL><DEDENT>return True<EOL>

Return True if a released version of numpy is detected.


api_files = [join(codegen_dir, '<STR_LIT>'),<EOL>join(codegen_dir, '<STR_LIT>')]<EOL>sys.path.insert(<NUM_LIT:0>, codegen_dir)<EOL>try:<EOL><INDENT>m = __import__('<STR_LIT>')<EOL>numpy_api = __import__('<STR_LIT>')<EOL>curapi_hash = m.fullapi_hash(numpy_api.full_api)<EOL>apis_hash = m.get_versions_hash()<EOL><DEDENT>finally:<EOL><INDENT>del sys.path[<NUM_LIT:0>]<EOL><DEDENT>return curapi_hash, apis_hash[apiversion]<EOL>

Return current C API checksum and the recorded checksum for the given
    version of the C API version.


curapi_hash, api_hash = get_api_versions(apiversion, codegen_dir)<EOL>if not curapi_hash == api_hash:<EOL><INDENT>msg = "<STR_LIT>""<STR_LIT>""<STR_LIT>""<STR_LIT>""<STR_LIT>"<EOL>warnings.warn(msg % (apiversion, curapi_hash, apiversion, api_hash,<EOL>__file__),<EOL>MismatchCAPIWarning)<EOL><DEDENT>

Emits a MismacthCAPIWarning if the C API version needs updating.


def _pyod2():<EOL><INDENT>out = []<EOL>fid = open(filename, '<STR_LIT:rb>')<EOL>try:<EOL><INDENT>yo = [int(oct(int(binascii.b2a_hex(o), <NUM_LIT:16>))) for o in fid.read()]<EOL>for i in range(<NUM_LIT:0>, len(yo), <NUM_LIT:16>):<EOL><INDENT>line = ['<STR_LIT>' % int(oct(i))]<EOL>line.extend(['<STR_LIT>' % c for c in yo[i:i+<NUM_LIT:16>]])<EOL>out.append("<STR_LIT:U+0020>".join(line))<EOL><DEDENT>return out<EOL><DEDENT>finally:<EOL><INDENT>fid.close()<EOL><DEDENT><DEDENT>def _pyod3():<EOL><INDENT>out = []<EOL>fid = open(filename, '<STR_LIT:rb>')<EOL>try:<EOL><INDENT>yo2 = [oct(o)[<NUM_LIT:2>:] for o in fid.read()]<EOL>for i in range(<NUM_LIT:0>, len(yo2), <NUM_LIT:16>):<EOL><INDENT>line = ['<STR_LIT>' % int(oct(i)[<NUM_LIT:2>:])]<EOL>line.extend(['<STR_LIT>' % int(c) for c in yo2[i:i+<NUM_LIT:16>]])<EOL>out.append("<STR_LIT:U+0020>".join(line))<EOL><DEDENT>return out<EOL><DEDENT>finally:<EOL><INDENT>fid.close()<EOL><DEDENT><DEDENT>if sys.version_info[<NUM_LIT:0>] < <NUM_LIT:3>:<EOL><INDENT>return _pyod2()<EOL><DEDENT>else:<EOL><INDENT>return _pyod3()<EOL><DEDENT>

Python implementation of the od UNIX utility (od -b, more exactly).

    Parameters
    ----------
    filename : str
        name of the file to get the dump from.

    Returns
    -------
    out : seq
        list of lines of od output

    Note
    ----
    We only implement enough to get the necessary information for long double
    representation, this is not intended as a compatible replacement for od.


<EOL>read = ['<STR_LIT>'] * <NUM_LIT:32><EOL>saw = None<EOL>for line in lines:<EOL><INDENT>for w in line.split()[<NUM_LIT:1>:]:<EOL><INDENT>read.pop(<NUM_LIT:0>)<EOL>read.append(w)<EOL>if read[-<NUM_LIT:8>:] == _AFTER_SEQ:<EOL><INDENT>saw = copy.copy(read)<EOL>if read[:<NUM_LIT:12>] == _BEFORE_SEQ[<NUM_LIT:4>:]:<EOL><INDENT>if read[<NUM_LIT:12>:-<NUM_LIT:8>] == _INTEL_EXTENDED_12B:<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT>if read[<NUM_LIT:12>:-<NUM_LIT:8>] == _MOTOROLA_EXTENDED_12B:<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT><DEDENT>elif read[:<NUM_LIT:8>] == _BEFORE_SEQ[<NUM_LIT:8>:]:<EOL><INDENT>if read[<NUM_LIT:8>:-<NUM_LIT:8>] == _INTEL_EXTENDED_16B:<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT>elif read[<NUM_LIT:8>:-<NUM_LIT:8>] == _IEEE_QUAD_PREC_BE:<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT>elif read[<NUM_LIT:8>:-<NUM_LIT:8>] == _IEEE_QUAD_PREC_LE:<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT>elif read[<NUM_LIT:8>:-<NUM_LIT:8>] == _DOUBLE_DOUBLE_BE:<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT>elif read[<NUM_LIT:8>:-<NUM_LIT:8>] == _DOUBLE_DOUBLE_LE:<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT><DEDENT>elif read[:<NUM_LIT:16>] == _BEFORE_SEQ:<EOL><INDENT>if read[<NUM_LIT:16>:-<NUM_LIT:8>] == _IEEE_DOUBLE_LE:<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT>elif read[<NUM_LIT:16>:-<NUM_LIT:8>] == _IEEE_DOUBLE_BE:<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>if saw is not None:<EOL><INDENT>raise ValueError("<STR_LIT>" % saw)<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>" % saw)<EOL><DEDENT>

Given a binary dump as given by GNU od -b, look for long double
    representation.


from numpy.core.multiarray import dtype<EOL>if value.fields is None:<EOL><INDENT>vfields = {'<STR_LIT>': (value, <NUM_LIT:0>)}<EOL><DEDENT>else:<EOL><INDENT>vfields = dict(value.fields)<EOL><DEDENT>if value.names and value.names[-<NUM_LIT:1>] == '<STR_LIT>' andvalue['<STR_LIT>'].char == '<STR_LIT>':<EOL><INDENT>vfields['<STR_LIT>'] = ('<STR_LIT>' % (vfields['<STR_LIT>'][<NUM_LIT:0>].itemsize + padding),<EOL>vfields['<STR_LIT>'][<NUM_LIT:1>])<EOL>value = dtype(vfields)<EOL><DEDENT>else:<EOL><INDENT>j = <NUM_LIT:0><EOL>while True:<EOL><INDENT>name = '<STR_LIT>' % j<EOL>if name not in vfields:<EOL><INDENT>vfields[name] = ('<STR_LIT>' % padding, value.itemsize)<EOL>break<EOL><DEDENT>j += <NUM_LIT:1><EOL><DEDENT>value = dtype(vfields)<EOL>if '<STR_LIT>' not in vfields:<EOL><INDENT>names = list(value.names)<EOL>names[-<NUM_LIT:1>] = '<STR_LIT>'<EOL>value.names = tuple(names)<EOL><DEDENT><DEDENT>return value<EOL>

Inject the specified number of padding bytes at the end of a dtype


while b:<EOL><INDENT>a, b = b, a%b<EOL><DEDENT>return a<EOL>

Calculate the greatest common divisor of a and b


def zeros_like(a, dtype=None, order='<STR_LIT>', subok=True):

res = empty_like(a, dtype=dtype, order=order, subok=subok)<EOL>z = zeros(<NUM_LIT:1>, dtype=res.dtype)<EOL>multiarray.copyto(res, z, casting='<STR_LIT>')<EOL>return res<EOL>

Return an array of zeros with the same shape and type as a given array.

Parameters
----------
a : array_like
    The shape and data-type of `a` define these same attributes of
    the returned array.
dtype : data-type, optional
    .. versionadded:: 1.6.0
    Overrides the data type of the result.
order : {'C', 'F', 'A', or 'K'}, optional
    .. versionadded:: 1.6.0
    Overrides the memory layout of the result. 'C' means C-order,
    'F' means F-order, 'A' means 'F' if `a` is Fortran contiguous,
    'C' otherwise. 'K' means match the layout of `a` as closely
    as possible.
subok : bool, optional.
    If True, then the newly created array will use the sub-class
    type of 'a', otherwise it will be a base-class array. Defaults
    to True.

Returns
-------
out : ndarray
    Array of zeros with the same shape and type as `a`.

See Also
--------
ones_like : Return an array of ones with shape and type of input.
empty_like : Return an empty array with shape and type of input.
zeros : Return a new array setting values to zero.
ones : Return a new array setting values to one.
empty : Return a new uninitialized array.

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

>>> y = np.arange(3, dtype=np.float)
>>> y
array([ 0.,  1.,  2.])
>>> np.zeros_like(y)
array([ 0.,  0.,  0.])


def ones(shape, dtype=None, order='<STR_LIT:C>'):

a = empty(shape, dtype, order)<EOL>multiarray.copyto(a, <NUM_LIT:1>, casting='<STR_LIT>')<EOL>return a<EOL>

Return a new array of given shape and type, filled with ones.

Parameters
----------
shape : int or sequence of ints
    Shape of the new array, e.g., ``(2, 3)`` or ``2``.
dtype : data-type, optional
    The desired data-type for the array, e.g., `numpy.int8`.  Default is
    `numpy.float64`.
order : {'C', 'F'}, optional
    Whether to store multidimensional data in C- or Fortran-contiguous
    (row- or column-wise) order in memory.

Returns
-------
out : ndarray
    Array of ones with the given shape, dtype, and order.

See Also
--------
zeros, ones_like

Examples
--------
>>> np.ones(5)
array([ 1.,  1.,  1.,  1.,  1.])

>>> np.ones((5,), dtype=np.int)
array([1, 1, 1, 1, 1])

>>> np.ones((2, 1))
array([[ 1.],
       [ 1.]])

>>> s = (2,2)
>>> np.ones(s)
array([[ 1.,  1.],
       [ 1.,  1.]])


def ones_like(a, dtype=None, order='<STR_LIT>', subok=True):

res = empty_like(a, dtype=dtype, order=order, subok=subok)<EOL>multiarray.copyto(res, <NUM_LIT:1>, casting='<STR_LIT>')<EOL>return res<EOL>

Return an array of ones with the same shape and type as a given array.

Parameters
----------
a : array_like
    The shape and data-type of `a` define these same attributes of
    the returned array.
dtype : data-type, optional
    .. versionadded:: 1.6.0
    Overrides the data type of the result.
order : {'C', 'F', 'A', or 'K'}, optional
    .. versionadded:: 1.6.0
    Overrides the memory layout of the result. 'C' means C-order,
    'F' means F-order, 'A' means 'F' if `a` is Fortran contiguous,
    'C' otherwise. 'K' means match the layout of `a` as closely
    as possible.
subok : bool, optional.
    If True, then the newly created array will use the sub-class
    type of 'a', otherwise it will be a base-class array. Defaults
    to True.

Returns
-------
out : ndarray
    Array of ones with the same shape and type as `a`.

See Also
--------
zeros_like : Return an array of zeros with shape and type of input.
empty_like : Return an empty array with shape and type of input.
zeros : Return a new array setting values to zero.
ones : Return a new array setting values to one.
empty : Return a new uninitialized array.

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

>>> y = np.arange(3, dtype=np.float)
>>> y
array([ 0.,  1.,  2.])
>>> np.ones_like(y)
array([ 1.,  1.,  1.])


def full(shape, fill_value, dtype=None, order='<STR_LIT:C>'):

a = empty(shape, dtype, order)<EOL>multiarray.copyto(a, fill_value, casting='<STR_LIT>')<EOL>return a<EOL>

Return a new array of given shape and type, filled with `fill_value`.

Parameters
----------
shape : int or sequence of ints
    Shape of the new array, e.g., ``(2, 3)`` or ``2``.
fill_value : scalar
    Fill value.
dtype : data-type, optional
    The desired data-type for the array, e.g., `numpy.int8`.  Default is
    is chosen as `np.array(fill_value).dtype`.
order : {'C', 'F'}, optional
    Whether to store multidimensional data in C- or Fortran-contiguous
    (row- or column-wise) order in memory.

Returns
-------
out : ndarray
    Array of `fill_value` with the given shape, dtype, and order.

See Also
--------
zeros_like : Return an array of zeros with shape and type of input.
ones_like : Return an array of ones with shape and type of input.
empty_like : Return an empty array with shape and type of input.
full_like : Fill an array with shape and type of input.
zeros : Return a new array setting values to zero.
ones : Return a new array setting values to one.
empty : Return a new uninitialized array.

Examples
--------
>>> np.full((2, 2), np.inf)
array([[ inf,  inf],
       [ inf,  inf]])
>>> np.full((2, 2), 10, dtype=np.int)
array([[10, 10],
       [10, 10]])


def full_like(a, fill_value, dtype=None, order='<STR_LIT>', subok=True):

res = empty_like(a, dtype=dtype, order=order, subok=subok)<EOL>multiarray.copyto(res, fill_value, casting='<STR_LIT>')<EOL>return res<EOL>

Return a full array with the same shape and type as a given array.

Parameters
----------
a : array_like
    The shape and data-type of `a` define these same attributes of
    the returned array.
fill_value : scalar
    Fill value.
dtype : data-type, optional
    Overrides the data type of the result.
order : {'C', 'F', 'A', or 'K'}, optional
    Overrides the memory layout of the result. 'C' means C-order,
    'F' means F-order, 'A' means 'F' if `a` is Fortran contiguous,
    'C' otherwise. 'K' means match the layout of `a` as closely
    as possible.
subok : bool, optional.
    If True, then the newly created array will use the sub-class
    type of 'a', otherwise it will be a base-class array. Defaults
    to True.

Returns
-------
out : ndarray
    Array of `fill_value` with the same shape and type as `a`.

See Also
--------
zeros_like : Return an array of zeros with shape and type of input.
ones_like : Return an array of ones with shape and type of input.
empty_like : Return an empty array with shape and type of input.
zeros : Return a new array setting values to zero.
ones : Return a new array setting values to one.
empty : Return a new uninitialized array.
full : Fill a new array.

Examples
--------
>>> x = np.arange(6, dtype=np.int)
>>> np.full_like(x, 1)
array([1, 1, 1, 1, 1, 1])
>>> np.full_like(x, 0.1)
array([0, 0, 0, 0, 0, 0])
>>> np.full_like(x, 0.1, dtype=np.double)
array([ 0.1,  0.1,  0.1,  0.1,  0.1,  0.1])
>>> np.full_like(x, np.nan, dtype=np.double)
array([ nan,  nan,  nan,  nan,  nan,  nan])

>>> y = np.arange(6, dtype=np.double)
>>> np.full_like(y, 0.1)
array([ 0.1,  0.1,  0.1,  0.1,  0.1,  0.1])


return array(a, dtype, copy=False, order=order)<EOL>

Convert the input to an array.

Parameters
----------
a : array_like
    Input data, in any form that can be converted to an array.  This
    includes lists, lists of tuples, tuples, tuples of tuples, tuples
    of lists and ndarrays.
dtype : data-type, optional
    By default, the data-type is inferred from the input data.
order : {'C', 'F'}, optional
    Whether to use row-major ('C') or column-major ('F' for FORTRAN)
    memory representation.  Defaults to 'C'.

Returns
-------
out : ndarray
    Array interpretation of `a`.  No copy is performed if the input
    is already an ndarray.  If `a` is a subclass of ndarray, a base
    class ndarray is returned.

See Also
--------
asanyarray : Similar function which passes through subclasses.
ascontiguousarray : Convert input to a contiguous array.
asfarray : Convert input to a floating point ndarray.
asfortranarray : Convert input to an ndarray with column-major
                 memory order.
asarray_chkfinite : Similar function which checks input for NaNs and Infs.
fromiter : Create an array from an iterator.
fromfunction : Construct an array by executing a function on grid
               positions.

Examples
--------
Convert a list into an array:

>>> a = [1, 2]
>>> np.asarray(a)
array([1, 2])

Existing arrays are not copied:

>>> a = np.array([1, 2])
>>> np.asarray(a) is a
True

If `dtype` is set, array is copied only if dtype does not match:

>>> a = np.array([1, 2], dtype=np.float32)
>>> np.asarray(a, dtype=np.float32) is a
True
>>> np.asarray(a, dtype=np.float64) is a
False

Contrary to `asanyarray`, ndarray subclasses are not passed through:

>>> issubclass(np.matrix, np.ndarray)
True
>>> a = np.matrix([[1, 2]])
>>> np.asarray(a) is a
False
>>> np.asanyarray(a) is a
True


def asanyarray(a, dtype=None, order=None):

return array(a, dtype, copy=False, order=order, subok=True)<EOL>

Convert the input to an ndarray, but pass ndarray subclasses through.

Parameters
----------
a : array_like
    Input data, in any form that can be converted to an array.  This
    includes scalars, lists, lists of tuples, tuples, tuples of tuples,
    tuples of lists, and ndarrays.
dtype : data-type, optional
    By default, the data-type is inferred from the input data.
order : {'C', 'F'}, optional
    Whether to use row-major ('C') or column-major ('F') memory
    representation.  Defaults to 'C'.

Returns
-------
out : ndarray or an ndarray subclass
    Array interpretation of `a`.  If `a` is an ndarray or a subclass
    of ndarray, it is returned as-is and no copy is performed.

See Also
--------
asarray : Similar function which always returns ndarrays.
ascontiguousarray : Convert input to a contiguous array.
asfarray : Convert input to a floating point ndarray.
asfortranarray : Convert input to an ndarray with column-major
                 memory order.
asarray_chkfinite : Similar function which checks input for NaNs and
                    Infs.
fromiter : Create an array from an iterator.
fromfunction : Construct an array by executing a function on grid
               positions.

Examples
--------
Convert a list into an array:

>>> a = [1, 2]
>>> np.asanyarray(a)
array([1, 2])

Instances of `ndarray` subclasses are passed through as-is:

>>> a = np.matrix([1, 2])
>>> np.asanyarray(a) is a
True


return array(a, dtype, copy=False, order='<STR_LIT:C>', ndmin=<NUM_LIT:1>)<EOL>

Return a contiguous array in memory (C order).

Parameters
----------
a : array_like
    Input array.
dtype : str or dtype object, optional
    Data-type of returned array.

Returns
-------
out : ndarray
    Contiguous array of same shape and content as `a`, with type `dtype`
    if specified.

See Also
--------
asfortranarray : Convert input to an ndarray with column-major
                 memory order.
require : Return an ndarray that satisfies requirements.
ndarray.flags : Information about the memory layout of the array.

Examples
--------
>>> x = np.arange(6).reshape(2,3)
>>> np.ascontiguousarray(x, dtype=np.float32)
array([[ 0.,  1.,  2.],
       [ 3.,  4.,  5.]], dtype=float32)
>>> x.flags['C_CONTIGUOUS']
True


return array(a, dtype, copy=False, order='<STR_LIT:F>', ndmin=<NUM_LIT:1>)<EOL>

Return an array laid out in Fortran order in memory.

Parameters
----------
a : array_like
    Input array.
dtype : str or dtype object, optional
    By default, the data-type is inferred from the input data.

Returns
-------
out : ndarray
    The input `a` in Fortran, or column-major, order.

See Also
--------
ascontiguousarray : Convert input to a contiguous (C order) array.
asanyarray : Convert input to an ndarray with either row or
    column-major memory order.
require : Return an ndarray that satisfies requirements.
ndarray.flags : Information about the memory layout of the array.

Examples
--------
>>> x = np.arange(6).reshape(2,3)
>>> y = np.asfortranarray(x)
>>> x.flags['F_CONTIGUOUS']
False
>>> y.flags['F_CONTIGUOUS']
True


def require(a, dtype=None, requirements=None):

if requirements is None:<EOL><INDENT>requirements = []<EOL><DEDENT>else:<EOL><INDENT>requirements = [x.upper() for x in requirements]<EOL><DEDENT>if not requirements:<EOL><INDENT>return asanyarray(a, dtype=dtype)<EOL><DEDENT>if '<STR_LIT>' in requirements or '<STR_LIT:E>' in requirements:<EOL><INDENT>subok = False<EOL><DEDENT>else:<EOL><INDENT>subok = True<EOL><DEDENT>arr = array(a, dtype=dtype, copy=False, subok=subok)<EOL>copychar = '<STR_LIT:A>'<EOL>if '<STR_LIT>' in requirements or'<STR_LIT>' in requirements or'<STR_LIT:F>' in requirements:<EOL><INDENT>copychar = '<STR_LIT:F>'<EOL><DEDENT>elif '<STR_LIT>' in requirements or'<STR_LIT>' in requirements or'<STR_LIT:C>' in requirements:<EOL><INDENT>copychar = '<STR_LIT:C>'<EOL><DEDENT>for prop in requirements:<EOL><INDENT>if not arr.flags[prop]:<EOL><INDENT>arr = arr.copy(copychar)<EOL>break<EOL><DEDENT><DEDENT>return arr<EOL>

Return an ndarray of the provided type that satisfies requirements.

This function is useful to be sure that an array with the correct flags
is returned for passing to compiled code (perhaps through ctypes).

Parameters
----------
a : array_like
   The object to be converted to a type-and-requirement-satisfying array.
dtype : data-type
   The required data-type, the default data-type is float64).
requirements : str or list of str
   The requirements list can be any of the following

   * 'F_CONTIGUOUS' ('F') - ensure a Fortran-contiguous array
   * 'C_CONTIGUOUS' ('C') - ensure a C-contiguous array
   * 'ALIGNED' ('A')      - ensure a data-type aligned array
   * 'WRITEABLE' ('W')    - ensure a writable array
   * 'OWNDATA' ('O')      - ensure an array that owns its own data

See Also
--------
asarray : Convert input to an ndarray.
asanyarray : Convert to an ndarray, but pass through ndarray subclasses.
ascontiguousarray : Convert input to a contiguous array.
asfortranarray : Convert input to an ndarray with column-major
                 memory order.
ndarray.flags : Information about the memory layout of the array.

Notes
-----
The returned array will be guaranteed to have the listed requirements
by making a copy if needed.

Examples
--------
>>> x = np.arange(6).reshape(2,3)
>>> x.flags
  C_CONTIGUOUS : True
  F_CONTIGUOUS : False
  OWNDATA : False
  WRITEABLE : True
  ALIGNED : True
  UPDATEIFCOPY : False

>>> y = np.require(x, dtype=np.float32, requirements=['A', 'O', 'W', 'F'])
>>> y.flags
  C_CONTIGUOUS : False
  F_CONTIGUOUS : True
  OWNDATA : True
  WRITEABLE : True
  ALIGNED : True
  UPDATEIFCOPY : False


return a.flags.fnc<EOL>

Returns True if array is arranged in Fortran-order in memory
and not C-order.

Parameters
----------
a : ndarray
    Input array.

Examples
--------

np.array allows to specify whether the array is written in C-contiguous
order (last index varies the fastest), or FORTRAN-contiguous order in
memory (first index varies the fastest).

>>> a = np.array([[1, 2, 3], [4, 5, 6]], order='C')
>>> a
array([[1, 2, 3],
       [4, 5, 6]])
>>> np.isfortran(a)
False

>>> b = np.array([[1, 2, 3], [4, 5, 6]], order='FORTRAN')
>>> b
array([[1, 2, 3],
       [4, 5, 6]])
>>> np.isfortran(b)
True

The transpose of a C-ordered array is a FORTRAN-ordered array.

>>> a = np.array([[1, 2, 3], [4, 5, 6]], order='C')
>>> a
array([[1, 2, 3],
       [4, 5, 6]])
>>> np.isfortran(a)
False
>>> b = a.T
>>> b
array([[1, 4],
       [2, 5],
       [3, 6]])
>>> np.isfortran(b)
True

C-ordered arrays evaluate as False even if they are also FORTRAN-ordered.

>>> np.isfortran(np.array([1, 2], order='FORTRAN'))
False


return transpose(nonzero(a))<EOL>

Find the indices of array elements that are non-zero, grouped by element.

Parameters
----------
a : array_like
    Input data.

Returns
-------
index_array : ndarray
    Indices of elements that are non-zero. Indices are grouped by element.

See Also
--------
where, nonzero

Notes
-----
``np.argwhere(a)`` is the same as ``np.transpose(np.nonzero(a))``.

The output of ``argwhere`` is not suitable for indexing arrays.
For this purpose use ``where(a)`` instead.

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


return a.ravel().nonzero()[<NUM_LIT:0>]<EOL>

Return indices that are non-zero in the flattened version of a.

This is equivalent to a.ravel().nonzero()[0].

Parameters
----------
a : ndarray
    Input array.

Returns
-------
res : ndarray
    Output array, containing the indices of the elements of `a.ravel()`
    that are non-zero.

See Also
--------
nonzero : Return the indices of the non-zero elements of the input array.
ravel : Return a 1-D array containing the elements of the input array.

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

Use the indices of the non-zero elements as an index array to extract
these elements:

>>> x.ravel()[np.flatnonzero(x)]
array([-2, -1,  1,  2])


def correlate(a, v, mode='<STR_LIT>', old_behavior=False):

mode = _mode_from_name(mode)<EOL>e old behavior should be made available under a different name, see thread<EOL>tp://thread.gmane.org/gmane.comp.python.numeric.general/<NUM_LIT>/focus=<NUM_LIT><EOL>if old_behavior:<EOL><INDENT>warnings.warn("""<STR_LIT>""",<EOL>DeprecationWarning)<EOL>return multiarray.correlate(a, v, mode)<EOL><DEDENT>else:<EOL><INDENT>return multiarray.correlate2(a, v, mode)<EOL><DEDENT>

Cross-correlation of two 1-dimensional sequences.

This function computes the correlation as generally defined in signal
processing texts::

    c_{av}[k] = sum_n a[n+k] * conj(v[n])

with a and v sequences being zero-padded where necessary and conj being
the conjugate.

Parameters
----------
a, v : array_like
    Input sequences.
mode : {'valid', 'same', 'full'}, optional
    Refer to the `convolve` docstring.  Note that the default
    is `valid`, unlike `convolve`, which uses `full`.
old_behavior : bool
    If True, uses the old behavior from Numeric,
    (correlate(a,v) == correlate(v,a), and the conjugate is not taken
    for complex arrays). If False, uses the conventional signal
    processing definition.

Returns
-------
out : ndarray
    Discrete cross-correlation of `a` and `v`.

See Also
--------
convolve : Discrete, linear convolution of two one-dimensional sequences.

Notes
-----
The definition of correlation above is not unique and sometimes correlation
may be defined differently. Another common definition is::

    c'_{av}[k] = sum_n a[n] conj(v[n+k])

which is related to ``c_{av}[k]`` by ``c'_{av}[k] = c_{av}[-k]``.

Examples
--------
>>> np.correlate([1, 2, 3], [0, 1, 0.5])
array([ 3.5])
>>> np.correlate([1, 2, 3], [0, 1, 0.5], "same")
array([ 2. ,  3.5,  3. ])
>>> np.correlate([1, 2, 3], [0, 1, 0.5], "full")
array([ 0.5,  2. ,  3.5,  3. ,  0. ])

Using complex sequences:

>>> np.correlate([1+1j, 2, 3-1j], [0, 1, 0.5j], 'full')
array([ 0.5-0.5j,  1.0+0.j ,  1.5-1.5j,  3.0-1.j ,  0.0+0.j ])

Note that you get the time reversed, complex conjugated result
when the two input sequences change places, i.e.,
``c_{va}[k] = c^{*}_{av}[-k]``:

>>> np.correlate([0, 1, 0.5j], [1+1j, 2, 3-1j], 'full')
array([ 0.0+0.j ,  3.0+1.j ,  1.5+1.5j,  1.0+0.j ,  0.5+0.5j])


a, v = array(a, ndmin=<NUM_LIT:1>), array(v, ndmin=<NUM_LIT:1>)<EOL>if (len(v) > len(a)):<EOL><INDENT>a, v = v, a<EOL><DEDENT>if len(a) == <NUM_LIT:0> :<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>if len(v) == <NUM_LIT:0> :<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>mode = _mode_from_name(mode)<EOL>return multiarray.correlate(a, v[::-<NUM_LIT:1>], mode)<EOL>

Returns the discrete, linear convolution of two one-dimensional sequences.

The convolution operator is often seen in signal processing, where it
models the effect of a linear time-invariant system on a signal [1]_.  In
probability theory, the sum of two independent random variables is
distributed according to the convolution of their individual
distributions.

If `v` is longer than `a`, the arrays are swapped before computation.

Parameters
----------
a : (N,) array_like
    First one-dimensional input array.
v : (M,) array_like
    Second one-dimensional input array.
mode : {'full', 'valid', 'same'}, optional
    'full':
      By default, mode is 'full'.  This returns the convolution
      at each point of overlap, with an output shape of (N+M-1,). At
      the end-points of the convolution, the signals do not overlap
      completely, and boundary effects may be seen.

    'same':
      Mode `same` returns output of length ``max(M, N)``.  Boundary
      effects are still visible.

    'valid':
      Mode `valid` returns output of length
      ``max(M, N) - min(M, N) + 1``.  The convolution product is only given
      for points where the signals overlap completely.  Values outside
      the signal boundary have no effect.

Returns
-------
out : ndarray
    Discrete, linear convolution of `a` and `v`.

See Also
--------
scipy.signal.fftconvolve : Convolve two arrays using the Fast Fourier
                           Transform.
scipy.linalg.toeplitz : Used to construct the convolution operator.
polymul : Polynomial multiplication. Same output as convolve, but also
          accepts poly1d objects as input.

Notes
-----
The discrete convolution operation is defined as

.. math:: (a * v)[n] = \\sum_{m = -\\infty}^{\\infty} a[m] v[n - m]

It can be shown that a convolution :math:`x(t) * y(t)` in time/space
is equivalent to the multiplication :math:`X(f) Y(f)` in the Fourier
domain, after appropriate padding (padding is necessary to prevent
circular convolution).  Since multiplication is more efficient (faster)
than convolution, the function `scipy.signal.fftconvolve` exploits the
FFT to calculate the convolution of large data-sets.

References
----------
.. [1] Wikipedia, "Convolution", http://en.wikipedia.org/wiki/Convolution.

Examples
--------
Note how the convolution operator flips the second array
before "sliding" the two across one another:

>>> np.convolve([1, 2, 3], [0, 1, 0.5])
array([ 0. ,  1. ,  2.5,  4. ,  1.5])

Only return the middle values of the convolution.
Contains boundary effects, where zeros are taken
into account:

>>> np.convolve([1,2,3],[0,1,0.5], 'same')
array([ 1. ,  2.5,  4. ])

The two arrays are of the same length, so there
is only one position where they completely overlap:

>>> np.convolve([1,2,3],[0,1,0.5], 'valid')
array([ 2.5])


a = asarray(a)<EOL>b = asarray(b)<EOL>return multiply(a.ravel()[:, newaxis], b.ravel()[newaxis,:], out)<EOL>


try:<EOL><INDENT>iter(axes)<EOL><DEDENT>except:<EOL><INDENT>axes_a = list(range(-axes, <NUM_LIT:0>))<EOL>axes_b = list(range(<NUM_LIT:0>, axes))<EOL><DEDENT>else:<EOL><INDENT>axes_a, axes_b = axes<EOL><DEDENT>try:<EOL><INDENT>na = len(axes_a)<EOL>axes_a = list(axes_a)<EOL><DEDENT>except TypeError:<EOL><INDENT>axes_a = [axes_a]<EOL>na = <NUM_LIT:1><EOL><DEDENT>try:<EOL><INDENT>nb = len(axes_b)<EOL>axes_b = list(axes_b)<EOL><DEDENT>except TypeError:<EOL><INDENT>axes_b = [axes_b]<EOL>nb = <NUM_LIT:1><EOL><DEDENT>a, b = asarray(a), asarray(b)<EOL>as_ = a.shape<EOL>nda = len(a.shape)<EOL>bs = b.shape<EOL>ndb = len(b.shape)<EOL>equal = True<EOL>if (na != nb): equal = False<EOL>else:<EOL><INDENT>for k in range(na):<EOL><INDENT>if as_[axes_a[k]] != bs[axes_b[k]]:<EOL><INDENT>equal = False<EOL>break<EOL><DEDENT>if axes_a[k] < <NUM_LIT:0>:<EOL><INDENT>axes_a[k] += nda<EOL><DEDENT>if axes_b[k] < <NUM_LIT:0>:<EOL><INDENT>axes_b[k] += ndb<EOL><DEDENT><DEDENT><DEDENT>if not equal:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>notin = [k for k in range(nda) if k not in axes_a]<EOL>newaxes_a = notin + axes_a<EOL>N2 = <NUM_LIT:1><EOL>for axis in axes_a:<EOL><INDENT>N2 *= as_[axis]<EOL><DEDENT>newshape_a = (-<NUM_LIT:1>, N2)<EOL>olda = [as_[axis] for axis in notin]<EOL>notin = [k for k in range(ndb) if k not in axes_b]<EOL>newaxes_b = axes_b + notin<EOL>N2 = <NUM_LIT:1><EOL>for axis in axes_b:<EOL><INDENT>N2 *= bs[axis]<EOL><DEDENT>newshape_b = (N2, -<NUM_LIT:1>)<EOL>oldb = [bs[axis] for axis in notin]<EOL>at = a.transpose(newaxes_a).reshape(newshape_a)<EOL>bt = b.transpose(newaxes_b).reshape(newshape_b)<EOL>res = dot(at, bt)<EOL>return res.reshape(olda + oldb)<EOL>

Compute tensor dot product along specified axes for arrays >= 1-D.

Given two tensors (arrays of dimension greater than or equal to one),
`a` and `b`, and an array_like object containing two array_like
objects, ``(a_axes, b_axes)``, sum the products of `a`'s and `b`'s
elements (components) over the axes specified by ``a_axes`` and
``b_axes``. The third argument can be a single non-negative
integer_like scalar, ``N``; if it is such, then the last ``N``
dimensions of `a` and the first ``N`` dimensions of `b` are summed
over.

Parameters
----------
a, b : array_like, len(shape) >= 1
    Tensors to "dot".
axes : variable type
    * integer_like scalar
      Number of axes to sum over (applies to both arrays); or
    * (2,) array_like, both elements array_like of the same length
      List of axes to be summed over, first sequence applying to `a`,
      second to `b`.

See Also
--------
dot, einsum

Notes
-----
When there is more than one axis to sum over - and they are not the last
(first) axes of `a` (`b`) - the argument `axes` should consist of
two sequences of the same length, with the first axis to sum over given
first in both sequences, the second axis second, and so forth.

Examples
--------
A "traditional" example:

>>> a = np.arange(60.).reshape(3,4,5)
>>> b = np.arange(24.).reshape(4,3,2)
>>> c = np.tensordot(a,b, axes=([1,0],[0,1]))
>>> c.shape
(5, 2)
>>> c
array([[ 4400.,  4730.],
       [ 4532.,  4874.],
       [ 4664.,  5018.],
       [ 4796.,  5162.],
       [ 4928.,  5306.]])
>>> # A slower but equivalent way of computing the same...
>>> d = np.zeros((5,2))
>>> for i in range(5):
...   for j in range(2):
...     for k in range(3):
...       for n in range(4):
...         d[i,j] += a[k,n,i] * b[n,k,j]
>>> c == d
array([[ True,  True],
       [ True,  True],
       [ True,  True],
       [ True,  True],
       [ True,  True]], dtype=bool)

An extended example taking advantage of the overloading of + and \\*:

>>> a = np.array(range(1, 9))
>>> a.shape = (2, 2, 2)
>>> A = np.array(('a', 'b', 'c', 'd'), dtype=object)
>>> A.shape = (2, 2)
>>> a; A
array([[[1, 2],
        [3, 4]],
       [[5, 6],
        [7, 8]]])
array([[a, b],
       [c, d]], dtype=object)

>>> np.tensordot(a, A) # third argument default is 2
array([abbcccdddd, aaaaabbbbbbcccccccdddddddd], dtype=object)

>>> np.tensordot(a, A, 1)
array([[[acc, bdd],
        [aaacccc, bbbdddd]],
       [[aaaaacccccc, bbbbbdddddd],
        [aaaaaaacccccccc, bbbbbbbdddddddd]]], dtype=object)

>>> np.tensordot(a, A, 0) # "Left for reader" (result too long to incl.)
array([[[[[a, b],
          [c, d]],
          ...

>>> np.tensordot(a, A, (0, 1))
array([[[abbbbb, cddddd],
        [aabbbbbb, ccdddddd]],
       [[aaabbbbbbb, cccddddddd],
        [aaaabbbbbbbb, ccccdddddddd]]], dtype=object)

>>> np.tensordot(a, A, (2, 1))
array([[[abb, cdd],
        [aaabbbb, cccdddd]],
       [[aaaaabbbbbb, cccccdddddd],
        [aaaaaaabbbbbbbb, cccccccdddddddd]]], dtype=object)

>>> np.tensordot(a, A, ((0, 1), (0, 1)))
array([abbbcccccddddddd, aabbbbccccccdddddddd], dtype=object)

>>> np.tensordot(a, A, ((2, 1), (1, 0)))
array([acccbbdddd, aaaaacccccccbbbbbbdddddddd], dtype=object)


a = asanyarray(a)<EOL>if axis is None:<EOL><INDENT>n = a.size<EOL>reshape = True<EOL><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>n = a.shape[axis]<EOL><DEDENT>except IndexError:<EOL><INDENT>raise ValueError('<STR_LIT>' % a.ndim)<EOL><DEDENT>reshape = False<EOL><DEDENT>if n == <NUM_LIT:0>:<EOL><INDENT>return a<EOL><DEDENT>shift %= n<EOL>indexes = concatenate((arange(n - shift, n), arange(n - shift)))<EOL>res = a.take(indexes, axis)<EOL>if reshape:<EOL><INDENT>res = res.reshape(a.shape)<EOL><DEDENT>return res<EOL>

Roll array elements along a given axis.

Elements that roll beyond the last position are re-introduced at
the first.

Parameters
----------
a : array_like
    Input array.
shift : int
    The number of places by which elements are shifted.
axis : int, optional
    The axis along which elements are shifted.  By default, the array
    is flattened before shifting, after which the original
    shape is restored.

Returns
-------
res : ndarray
    Output array, with the same shape as `a`.

See Also
--------
rollaxis : Roll the specified axis backwards, until it lies in a
           given position.

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

>>> x2 = np.reshape(x, (2,5))
>>> x2
array([[0, 1, 2, 3, 4],
       [5, 6, 7, 8, 9]])
>>> np.roll(x2, 1)
array([[9, 0, 1, 2, 3],
       [4, 5, 6, 7, 8]])
>>> np.roll(x2, 1, axis=0)
array([[5, 6, 7, 8, 9],
       [0, 1, 2, 3, 4]])
>>> np.roll(x2, 1, axis=1)
array([[4, 0, 1, 2, 3],
       [9, 5, 6, 7, 8]])


def rollaxis(a, axis, start=<NUM_LIT:0>):

n = a.ndim<EOL>if axis < <NUM_LIT:0>:<EOL><INDENT>axis += n<EOL><DEDENT>if start < <NUM_LIT:0>:<EOL><INDENT>start += n<EOL><DEDENT>msg = '<STR_LIT>'<EOL>if not (<NUM_LIT:0> <= axis < n):<EOL><INDENT>raise ValueError(msg % ('<STR_LIT>', axis, n))<EOL><DEDENT>if not (<NUM_LIT:0> <= start < n+<NUM_LIT:1>):<EOL><INDENT>raise ValueError(msg % ('<STR_LIT:start>', start, n+<NUM_LIT:1>))<EOL><DEDENT>if (axis < start): <EOL><INDENT>start -= <NUM_LIT:1><EOL><DEDENT>if axis==start:<EOL><INDENT>return a<EOL><DEDENT>axes = list(range(<NUM_LIT:0>, n))<EOL>axes.remove(axis)<EOL>axes.insert(start, axis)<EOL>return a.transpose(axes)<EOL>

Roll the specified axis backwards, until it lies in a given position.

Parameters
----------
a : ndarray
    Input array.
axis : int
    The axis to roll backwards.  The positions of the other axes do not
    change relative to one another.
start : int, optional
    The axis is rolled until it lies before this position.  The default,
    0, results in a "complete" roll.

Returns
-------
res : ndarray
    Output array.

See Also
--------
roll : Roll the elements of an array by a number of positions along a
    given axis.

Examples
--------
>>> a = np.ones((3,4,5,6))
>>> np.rollaxis(a, 3, 1).shape
(3, 6, 4, 5)
>>> np.rollaxis(a, 2).shape
(5, 3, 4, 6)
>>> np.rollaxis(a, 1, 4).shape
(3, 5, 6, 4)


def cross(a, b, axisa=-<NUM_LIT:1>, axisb=-<NUM_LIT:1>, axisc=-<NUM_LIT:1>, axis=None):

if axis is not None:<EOL><INDENT>axisa, axisb, axisc = (axis,) * <NUM_LIT:3><EOL><DEDENT>a = asarray(a)<EOL>b = asarray(b)<EOL>a = rollaxis(a, axisa, a.ndim)<EOL>b = rollaxis(b, axisb, b.ndim)<EOL>msg = ("<STR_LIT>"<EOL>"<STR_LIT>")<EOL>if a.shape[-<NUM_LIT:1>] not in (<NUM_LIT:2>, <NUM_LIT:3>) or b.shape[-<NUM_LIT:1>] not in (<NUM_LIT:2>, <NUM_LIT:3>):<EOL><INDENT>raise ValueError(msg)<EOL><DEDENT>shape = broadcast(a[..., <NUM_LIT:0>], b[..., <NUM_LIT:0>]).shape<EOL>if a.shape[-<NUM_LIT:1>] == <NUM_LIT:3> or b.shape[-<NUM_LIT:1>] == <NUM_LIT:3>:<EOL><INDENT>shape += (<NUM_LIT:3>,)<EOL><DEDENT>dtype = promote_types(a.dtype, b.dtype)<EOL>cp = empty(shape, dtype)<EOL>a0 = a[..., <NUM_LIT:0>]<EOL>a1 = a[..., <NUM_LIT:1>]<EOL>if a.shape[-<NUM_LIT:1>] == <NUM_LIT:3>:<EOL><INDENT>a2 = a[..., <NUM_LIT:2>]<EOL><DEDENT>b0 = b[..., <NUM_LIT:0>]<EOL>b1 = b[..., <NUM_LIT:1>]<EOL>if b.shape[-<NUM_LIT:1>] == <NUM_LIT:3>:<EOL><INDENT>b2 = b[..., <NUM_LIT:2>]<EOL><DEDENT>if cp.ndim != <NUM_LIT:0> and cp.shape[-<NUM_LIT:1>] == <NUM_LIT:3>:<EOL><INDENT>cp0 = cp[..., <NUM_LIT:0>]<EOL>cp1 = cp[..., <NUM_LIT:1>]<EOL>cp2 = cp[..., <NUM_LIT:2>]<EOL><DEDENT>if a.shape[-<NUM_LIT:1>] == <NUM_LIT:2>:<EOL><INDENT>if b.shape[-<NUM_LIT:1>] == <NUM_LIT:2>:<EOL><INDENT>multiply(a0, b1, out=cp)<EOL>cp -= a1 * b0<EOL>if cp.ndim == <NUM_LIT:0>:<EOL><INDENT>return cp<EOL><DEDENT>else:<EOL><INDENT>return rollaxis(cp, -<NUM_LIT:1>, axisc)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>multiply(a1, b2, out=cp0)<EOL>multiply(a0, b2, out=cp1)<EOL>negative(cp1, out=cp1)<EOL>multiply(a0, b1, out=cp2)<EOL>cp2 -= a1 * b0<EOL><DEDENT><DEDENT>elif a.shape[-<NUM_LIT:1>] == <NUM_LIT:3>:<EOL><INDENT>if b.shape[-<NUM_LIT:1>] == <NUM_LIT:3>:<EOL><INDENT>multiply(a1, b2, out=cp0)<EOL>tmp = array(a2 * b1)<EOL>cp0 -= tmp<EOL>multiply(a2, b0, out=cp1)<EOL>multiply(a0, b2, out=tmp)<EOL>cp1 -= tmp<EOL>multiply(a0, b1, out=cp2)<EOL>multiply(a1, b0, out=tmp)<EOL>cp2 -= tmp<EOL><DEDENT>else:<EOL><INDENT>multiply(a2, b1, out=cp0)<EOL>negative(cp0, out=cp0)<EOL>multiply(a2, b0, out=cp1)<EOL>multiply(a0, b1, out=cp2)<EOL>cp2 -= a1 * b0<EOL><DEDENT><DEDENT>if cp.ndim == <NUM_LIT:1>:<EOL><INDENT>return cp<EOL><DEDENT>else:<EOL><INDENT>return rollaxis(cp, -<NUM_LIT:1>, axisc)<EOL><DEDENT>

Return the cross product of two (arrays of) vectors.

The cross product of `a` and `b` in :math:`R^3` is a vector perpendicular
to both `a` and `b`.  If `a` and `b` are arrays of vectors, the vectors
are defined by the last axis of `a` and `b` by default, and these axes
can have dimensions 2 or 3.  Where the dimension of either `a` or `b` is
2, the third component of the input vector is assumed to be zero and the
cross product calculated accordingly.  In cases where both input vectors
have dimension 2, the z-component of the cross product is returned.

Parameters
----------
a : array_like
    Components of the first vector(s).
b : array_like
    Components of the second vector(s).
axisa : int, optional
    Axis of `a` that defines the vector(s).  By default, the last axis.
axisb : int, optional
    Axis of `b` that defines the vector(s).  By default, the last axis.
axisc : int, optional
    Axis of `c` containing the cross product vector(s).  By default, the
    last axis.
axis : int, optional
    If defined, the axis of `a`, `b` and `c` that defines the vector(s)
    and cross product(s).  Overrides `axisa`, `axisb` and `axisc`.

Returns
-------
c : ndarray
    Vector cross product(s).

Raises
------
ValueError
    When the dimension of the vector(s) in `a` and/or `b` does not
    equal 2 or 3.

See Also
--------
inner : Inner product
outer : Outer product.
ix_ : Construct index arrays.

Notes
-----
.. versionadded:: 1.9.0
Supports full broadcasting of the inputs.

Examples
--------
Vector cross-product.

>>> x = [1, 2, 3]
>>> y = [4, 5, 6]
>>> np.cross(x, y)
array([-3,  6, -3])

One vector with dimension 2.

>>> x = [1, 2]
>>> y = [4, 5, 6]
>>> np.cross(x, y)
array([12, -6, -3])

Equivalently:

>>> x = [1, 2, 0]
>>> y = [4, 5, 6]
>>> np.cross(x, y)
array([12, -6, -3])

Both vectors with dimension 2.

>>> x = [1,2]
>>> y = [4,5]
>>> np.cross(x, y)
-3

Multiple vector cross-products. Note that the direction of the cross
product vector is defined by the `right-hand rule`.

>>> x = np.array([[1,2,3], [4,5,6]])
>>> y = np.array([[4,5,6], [1,2,3]])
>>> np.cross(x, y)
array([[-3,  6, -3],
       [ 3, -6,  3]])

The orientation of `c` can be changed using the `axisc` keyword.

>>> np.cross(x, y, axisc=0)
array([[-3,  3],
       [ 6, -6],
       [-3,  3]])

Change the vector definition of `x` and `y` using `axisa` and `axisb`.

>>> x = np.array([[1,2,3], [4,5,6], [7, 8, 9]])
>>> y = np.array([[7, 8, 9], [4,5,6], [1,2,3]])
>>> np.cross(x, y)
array([[ -6,  12,  -6],
       [  0,   0,   0],
       [  6, -12,   6]])
>>> np.cross(x, y, axisa=0, axisb=0)
array([[-24,  48, -24],
       [-30,  60, -30],
       [-36,  72, -36]])


def array_repr(arr, max_line_width=None, precision=None, suppress_small=None):

if arr.size > <NUM_LIT:0> or arr.shape==(<NUM_LIT:0>,):<EOL><INDENT>lst = array2string(arr, max_line_width, precision, suppress_small,<EOL>'<STR_LIT:U+002CU+0020>', "<STR_LIT>")<EOL><DEDENT>else: <EOL><INDENT>lst = "<STR_LIT>" % (repr(arr.shape),)<EOL><DEDENT>if arr.__class__ is not ndarray:<EOL><INDENT>cName= arr.__class__.__name__<EOL><DEDENT>else:<EOL><INDENT>cName = "<STR_LIT>"<EOL><DEDENT>skipdtype = (arr.dtype.type in _typelessdata) and arr.size > <NUM_LIT:0><EOL>if skipdtype:<EOL><INDENT>return "<STR_LIT>" % (cName, lst)<EOL><DEDENT>else:<EOL><INDENT>typename = arr.dtype.name<EOL>if typename and not (typename[<NUM_LIT:0>].isalpha() and typename.isalnum()):<EOL><INDENT>typename = "<STR_LIT>" % typename<EOL><DEDENT>lf = '<STR_LIT>'<EOL>if issubclass(arr.dtype.type, flexible):<EOL><INDENT>if arr.dtype.names:<EOL><INDENT>typename = "<STR_LIT:%s>" % str(arr.dtype)<EOL><DEDENT>else:<EOL><INDENT>typename = "<STR_LIT>" % str(arr.dtype)<EOL><DEDENT>lf = '<STR_LIT:\n>'+'<STR_LIT:U+0020>'*len("<STR_LIT>")<EOL><DEDENT>return cName + "<STR_LIT>" % (lst, lf, typename)<EOL><DEDENT>

Return the string representation of an array.

Parameters
----------
arr : ndarray
    Input array.
max_line_width : int, optional
    The maximum number of columns the string should span. Newline
    characters split the string appropriately after array elements.
precision : int, optional
    Floating point precision. Default is the current printing precision
    (usually 8), which can be altered using `set_printoptions`.
suppress_small : bool, optional
    Represent very small numbers as zero, default is False. Very small
    is defined by `precision`, if the precision is 8 then
    numbers smaller than 5e-9 are represented as zero.

Returns
-------
string : str
  The string representation of an array.

See Also
--------
array_str, array2string, set_printoptions

Examples
--------
>>> np.array_repr(np.array([1,2]))
'array([1, 2])'
>>> np.array_repr(np.ma.array([0.]))
'MaskedArray([ 0.])'
>>> np.array_repr(np.array([], np.int32))
'array([], dtype=int32)'

>>> x = np.array([1e-6, 4e-7, 2, 3])
>>> np.array_repr(x, precision=6, suppress_small=True)
'array([ 0.000001,  0.      ,  2.      ,  3.      ])'


def array_str(a, max_line_width=None, precision=None, suppress_small=None):

return array2string(a, max_line_width, precision, suppress_small, '<STR_LIT:U+0020>', "<STR_LIT>", str)<EOL>

Return a string representation of the data in an array.

The data in the array is returned as a single string.  This function is
similar to `array_repr`, the difference being that `array_repr` also
returns information on the kind of array and its data type.

Parameters
----------
a : ndarray
    Input array.
max_line_width : int, optional
    Inserts newlines if text is longer than `max_line_width`.  The
    default is, indirectly, 75.
precision : int, optional
    Floating point precision.  Default is the current printing precision
    (usually 8), which can be altered using `set_printoptions`.
suppress_small : bool, optional
    Represent numbers "very close" to zero as zero; default is False.
    Very close is defined by precision: if the precision is 8, e.g.,
    numbers smaller (in absolute value) than 5e-9 are represented as
    zero.

See Also
--------
array2string, array_repr, set_printoptions

Examples
--------
>>> np.array_str(np.arange(3))
'[0 1 2]'


if f is None:<EOL><INDENT>if repr:<EOL><INDENT>return multiarray.set_string_function(array_repr, <NUM_LIT:1>)<EOL><DEDENT>else:<EOL><INDENT>return multiarray.set_string_function(array_str, <NUM_LIT:0>)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>return multiarray.set_string_function(f, repr)<EOL><DEDENT>

Set a Python function to be used when pretty printing arrays.

Parameters
----------
f : function or None
    Function to be used to pretty print arrays. The function should expect
    a single array argument and return a string of the representation of
    the array. If None, the function is reset to the default NumPy function
    to print arrays.
repr : bool, optional
    If True (default), the function for pretty printing (``__repr__``)
    is set, if False the function that returns the default string
    representation (``__str__``) is set.

See Also
--------
set_printoptions, get_printoptions

Examples
--------
>>> def pprint(arr):
...     return 'HA! - What are you going to do now?'
...
>>> np.set_string_function(pprint)
>>> a = np.arange(10)
>>> a
HA! - What are you going to do now?
>>> print a
[0 1 2 3 4 5 6 7 8 9]

We can reset the function to the default:

>>> np.set_string_function(None)
>>> a
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])

`repr` affects either pretty printing or normal string representation.
Note that ``__repr__`` is still affected by setting ``__str__``
because the width of each array element in the returned string becomes
equal to the length of the result of ``__str__()``.

>>> x = np.arange(4)
>>> np.set_string_function(lambda x:'random', repr=False)
>>> x.__str__()
'random'
>>> x.__repr__()
'array([     0,      1,      2,      3])'


dimensions = tuple(dimensions)<EOL>N = len(dimensions)<EOL>if N == <NUM_LIT:0>:<EOL><INDENT>return array([], dtype=dtype)<EOL><DEDENT>res = empty((N,)+dimensions, dtype=dtype)<EOL>for i, dim in enumerate(dimensions):<EOL><INDENT>tmp = arange(dim, dtype=dtype)<EOL>tmp.shape = (<NUM_LIT:1>,)*i + (dim,)+(<NUM_LIT:1>,)*(N-i-<NUM_LIT:1>)<EOL>newdim = dimensions[:i] + (<NUM_LIT:1>,)+ dimensions[i+<NUM_LIT:1>:]<EOL>val = zeros(newdim, dtype)<EOL>add(tmp, val, res[i])<EOL><DEDENT>return res<EOL>

Return an array representing the indices of a grid.

Compute an array where the subarrays contain index values 0,1,...
varying only along the corresponding axis.

Parameters
----------
dimensions : sequence of ints
    The shape of the grid.
dtype : dtype, optional
    Data type of the result.

Returns
-------
grid : ndarray
    The array of grid indices,
    ``grid.shape = (len(dimensions),) + tuple(dimensions)``.

See Also
--------
mgrid, meshgrid

Notes
-----
The output shape is obtained by prepending the number of dimensions
in front of the tuple of dimensions, i.e. if `dimensions` is a tuple
``(r0, ..., rN-1)`` of length ``N``, the output shape is
``(N,r0,...,rN-1)``.

The subarrays ``grid[k]`` contains the N-D array of indices along the
``k-th`` axis. Explicitly::

    grid[k,i0,i1,...,iN-1] = ik

Examples
--------
>>> grid = np.indices((2, 3))
>>> grid.shape
(2, 2, 3)
>>> grid[0]        # row indices
array([[0, 0, 0],
       [1, 1, 1]])
>>> grid[1]        # column indices
array([[0, 1, 2],
       [0, 1, 2]])

The indices can be used as an index into an array.

>>> x = np.arange(20).reshape(5, 4)
>>> row, col = np.indices((2, 3))
>>> x[row, col]
array([[0, 1, 2],
       [4, 5, 6]])

Note that it would be more straightforward in the above example to
extract the required elements directly with ``x[:2, :3]``.


def fromfunction(function, shape, **kwargs):

dtype = kwargs.pop('<STR_LIT>', float)<EOL>args = indices(shape, dtype=dtype)<EOL>return function(*args,**kwargs)<EOL>

Construct an array by executing a function over each coordinate.

The resulting array therefore has a value ``fn(x, y, z)`` at
coordinate ``(x, y, z)``.

Parameters
----------
function : callable
    The function is called with N parameters, where N is the rank of
    `shape`.  Each parameter represents the coordinates of the array
    varying along a specific axis.  For example, if `shape`
    were ``(2, 2)``, then the parameters in turn be (0, 0), (0, 1),
    (1, 0), (1, 1).
shape : (N,) tuple of ints
    Shape of the output array, which also determines the shape of
    the coordinate arrays passed to `function`.
dtype : data-type, optional
    Data-type of the coordinate arrays passed to `function`.
    By default, `dtype` is float.

Returns
-------
fromfunction : any
    The result of the call to `function` is passed back directly.
    Therefore the shape of `fromfunction` is completely determined by
    `function`.  If `function` returns a scalar value, the shape of
    `fromfunction` would match the `shape` parameter.

See Also
--------
indices, meshgrid

Notes
-----
Keywords other than `dtype` are passed to `function`.

Examples
--------
>>> np.fromfunction(lambda i, j: i == j, (3, 3), dtype=int)
array([[ True, False, False],
       [False,  True, False],
       [False, False,  True]], dtype=bool)

>>> np.fromfunction(lambda i, j: i + j, (3, 3), dtype=int)
array([[0, 1, 2],
       [1, 2, 3],
       [2, 3, 4]])


if isinstance(num, generic):<EOL><INDENT>return True<EOL><DEDENT>else:<EOL><INDENT>return type(num) in ScalarType<EOL><DEDENT>

Returns True if the type of `num` is a scalar type.

Parameters
----------
num : any
    Input argument, can be of any type and shape.

Returns
-------
val : bool
    True if `num` is a scalar type, False if it is not.

Examples
--------
>>> np.isscalar(3.1)
True
>>> np.isscalar([3.1])
False
>>> np.isscalar(False)
True


<EOL>sign = '<STR_LIT>'<EOL>if num < <NUM_LIT:0>:<EOL><INDENT>if width is None:<EOL><INDENT>sign = '<STR_LIT:->'<EOL>num = -num<EOL><DEDENT>else:<EOL><INDENT>num = <NUM_LIT:2>**width + num<EOL><DEDENT><DEDENT>elif num == <NUM_LIT:0>:<EOL><INDENT>return '<STR_LIT:0>'*(width or <NUM_LIT:1>)<EOL><DEDENT>ostr = hex(num)<EOL>bin = '<STR_LIT>'.join([_lkup[ch] for ch in ostr[<NUM_LIT:2>:]])<EOL>bin = bin.lstrip('<STR_LIT:0>')<EOL>if width is not None:<EOL><INDENT>bin = bin.zfill(width)<EOL><DEDENT>return sign + bin<EOL>

Return the binary representation of the input number as a string.

For negative numbers, if width is not given, a minus sign is added to the
front. If width is given, the two's complement of the number is
returned, with respect to that width.

In a two's-complement system negative numbers are represented by the two's
complement of the absolute value. This is the most common method of
representing signed integers on computers [1]_. A N-bit two's-complement
system can represent every integer in the range
:math:`-2^{N-1}` to :math:`+2^{N-1}-1`.

Parameters
----------
num : int
    Only an integer decimal number can be used.
width : int, optional
    The length of the returned string if `num` is positive, the length of
    the two's complement if `num` is negative.

Returns
-------
bin : str
    Binary representation of `num` or two's complement of `num`.

See Also
--------
base_repr: Return a string representation of a number in the given base
           system.

Notes
-----
`binary_repr` is equivalent to using `base_repr` with base 2, but about 25x
faster.

References
----------
.. [1] Wikipedia, "Two's complement",
    http://en.wikipedia.org/wiki/Two's_complement

Examples
--------
>>> np.binary_repr(3)
'11'
>>> np.binary_repr(-3)
'-11'
>>> np.binary_repr(3, width=4)
'0011'

The two's complement is returned when the input number is negative and
width is specified:

>>> np.binary_repr(-3, width=4)
'1101'


def base_repr(number, base=<NUM_LIT:2>, padding=<NUM_LIT:0>):

digits = '<STR_LIT>'<EOL>if base > len(digits):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>num = abs(number)<EOL>res = []<EOL>while num:<EOL><INDENT>res.append(digits[num % base])<EOL>num //= base<EOL><DEDENT>if padding:<EOL><INDENT>res.append('<STR_LIT:0>' * padding)<EOL><DEDENT>if number < <NUM_LIT:0>:<EOL><INDENT>res.append('<STR_LIT:->')<EOL><DEDENT>return '<STR_LIT>'.join(reversed(res or '<STR_LIT:0>'))<EOL>

Return a string representation of a number in the given base system.

Parameters
----------
number : int
    The value to convert. Only positive values are handled.
base : int, optional
    Convert `number` to the `base` number system. The valid range is 2-36,
    the default value is 2.
padding : int, optional
    Number of zeros padded on the left. Default is 0 (no padding).

Returns
-------
out : str
    String representation of `number` in `base` system.

See Also
--------
binary_repr : Faster version of `base_repr` for base 2.

Examples
--------
>>> np.base_repr(5)
'101'
>>> np.base_repr(6, 5)
'11'
>>> np.base_repr(7, base=5, padding=3)
'00012'

>>> np.base_repr(10, base=16)
'A'
>>> np.base_repr(32, base=16)
'20'


if isinstance(file, type("<STR_LIT>")):<EOL><INDENT>file = open(file, "<STR_LIT:rb>")<EOL><DEDENT>return pickle.load(file)<EOL>

Wrapper around cPickle.load which accepts either a file-like object or
a filename.

Note that the NumPy binary format is not based on pickle/cPickle anymore.
For details on the preferred way of loading and saving files, see `load`
and `save`.

See Also
--------
load, save


from numpy import eye<EOL>return eye(n, dtype=dtype)<EOL>

Return the identity array.

The identity array is a square array with ones on
the main diagonal.

Parameters
----------
n : int
    Number of rows (and columns) in `n` x `n` output.
dtype : data-type, optional
    Data-type of the output.  Defaults to ``float``.

Returns
-------
out : ndarray
    `n` x `n` array with its main diagonal set to one,
    and all other elements 0.

Examples
--------
>>> np.identity(3)
array([[ 1.,  0.,  0.],
       [ 0.,  1.,  0.],
       [ 0.,  0.,  1.]])


def allclose(a, b, rtol=<NUM_LIT>, atol=<NUM_LIT>):

x = array(a, copy=False, ndmin=<NUM_LIT:1>)<EOL>y = array(b, copy=False, ndmin=<NUM_LIT:1>)<EOL>dtype = multiarray.result_type(y, <NUM_LIT:1.>)<EOL>y = array(y, dtype=dtype, copy=False)<EOL>xinf = isinf(x)<EOL>yinf = isinf(y)<EOL>if any(xinf) or any(yinf):<EOL><INDENT>if not all(xinf == yinf):<EOL><INDENT>return False<EOL><DEDENT>if not all(x[xinf] == y[xinf]):<EOL><INDENT>return False<EOL><DEDENT>x = x[~xinf]<EOL>y = y[~xinf]<EOL><DEDENT>with errstate(invalid='<STR_LIT:ignore>'):<EOL><INDENT>r = all(less_equal(abs(x - y), atol + rtol * abs(y)))<EOL><DEDENT>return r<EOL>

Returns True if two arrays are element-wise equal within a tolerance.

The tolerance values are positive, typically very small numbers.  The
relative difference (`rtol` * abs(`b`)) and the absolute difference
`atol` are added together to compare against the absolute difference
between `a` and `b`.

If either array contains one or more NaNs, False is returned.
Infs are treated as equal if they are in the same place and of the same
sign in both arrays.

Parameters
----------
a, b : array_like
    Input arrays to compare.
rtol : float
    The relative tolerance parameter (see Notes).
atol : float
    The absolute tolerance parameter (see Notes).

Returns
-------
allclose : bool
    Returns True if the two arrays are equal within the given
    tolerance; False otherwise.

See Also
--------
isclose, all, any

Notes
-----
If the following equation is element-wise True, then allclose returns
True.

 absolute(`a` - `b`) <= (`atol` + `rtol` * absolute(`b`))

The above equation is not symmetric in `a` and `b`, so that
`allclose(a, b)` might be different from `allclose(b, a)` in
some rare cases.

Examples
--------
>>> np.allclose([1e10,1e-7], [1.00001e10,1e-8])
False
>>> np.allclose([1e10,1e-8], [1.00001e10,1e-9])
True
>>> np.allclose([1e10,1e-8], [1.0001e10,1e-9])
False
>>> np.allclose([1.0, np.nan], [1.0, np.nan])
False


def isclose(a, b, rtol=<NUM_LIT>, atol=<NUM_LIT>, equal_nan=False):

def within_tol(x, y, atol, rtol):<EOL><INDENT>with errstate(invalid='<STR_LIT:ignore>'):<EOL><INDENT>result = less_equal(abs(x-y), atol + rtol * abs(y))<EOL><DEDENT>if isscalar(a) and isscalar(b):<EOL><INDENT>result = bool(result)<EOL><DEDENT>return result<EOL><DEDENT>x = array(a, copy=False, subok=True, ndmin=<NUM_LIT:1>)<EOL>y = array(b, copy=False, subok=True, ndmin=<NUM_LIT:1>)<EOL>xfin = isfinite(x)<EOL>yfin = isfinite(y)<EOL>if all(xfin) and all(yfin):<EOL><INDENT>return within_tol(x, y, atol, rtol)<EOL><DEDENT>else:<EOL><INDENT>finite = xfin & yfin<EOL>cond = zeros_like(finite, subok=True)<EOL>x = x * ones_like(cond)<EOL>y = y * ones_like(cond)<EOL>cond[finite] = within_tol(x[finite], y[finite], atol, rtol)<EOL>cond[~finite] = (x[~finite] == y[~finite])<EOL>if equal_nan:<EOL><INDENT>both_nan = isnan(x) & isnan(y)<EOL>cond[both_nan] = both_nan[both_nan]<EOL><DEDENT>return cond<EOL><DEDENT>

Returns a boolean array where two arrays are element-wise equal within a
tolerance.

The tolerance values are positive, typically very small numbers.  The
relative difference (`rtol` * abs(`b`)) and the absolute difference
`atol` are added together to compare against the absolute difference
between `a` and `b`.

Parameters
----------
a, b : array_like
    Input arrays to compare.
rtol : float
    The relative tolerance parameter (see Notes).
atol : float
    The absolute tolerance parameter (see Notes).
equal_nan : bool
    Whether to compare NaN's as equal.  If True, NaN's in `a` will be
    considered equal to NaN's in `b` in the output array.

Returns
-------
y : array_like
    Returns a boolean array of where `a` and `b` are equal within the
    given tolerance. If both `a` and `b` are scalars, returns a single
    boolean value.

See Also
--------
allclose

Notes
-----
.. versionadded:: 1.7.0

For finite values, isclose uses the following equation to test whether
two floating point values are equivalent.

 absolute(`a` - `b`) <= (`atol` + `rtol` * absolute(`b`))

The above equation is not symmetric in `a` and `b`, so that
`isclose(a, b)` might be different from `isclose(b, a)` in
some rare cases.

Examples
--------
>>> np.isclose([1e10,1e-7], [1.00001e10,1e-8])
array([True, False])
>>> np.isclose([1e10,1e-8], [1.00001e10,1e-9])
array([True, True])
>>> np.isclose([1e10,1e-8], [1.0001e10,1e-9])
array([False, True])
>>> np.isclose([1.0, np.nan], [1.0, np.nan])
array([True, False])
>>> np.isclose([1.0, np.nan], [1.0, np.nan], equal_nan=True)
array([True, True])


try:<EOL><INDENT>a1, a2 = asarray(a1), asarray(a2)<EOL><DEDENT>except:<EOL><INDENT>return False<EOL><DEDENT>if a1.shape != a2.shape:<EOL><INDENT>return False<EOL><DEDENT>return bool(asarray(a1 == a2).all())<EOL>

True if two arrays have the same shape and elements, False otherwise.

Parameters
----------
a1, a2 : array_like
    Input arrays.

Returns
-------
b : bool
    Returns True if the arrays are equal.

See Also
--------
allclose: Returns True if two arrays are element-wise equal within a
          tolerance.
array_equiv: Returns True if input arrays are shape consistent and all
             elements equal.

Examples
--------
>>> np.array_equal([1, 2], [1, 2])
True
>>> np.array_equal(np.array([1, 2]), np.array([1, 2]))
True
>>> np.array_equal([1, 2], [1, 2, 3])
False
>>> np.array_equal([1, 2], [1, 4])
False


try:<EOL><INDENT>a1, a2 = asarray(a1), asarray(a2)<EOL><DEDENT>except:<EOL><INDENT>return False<EOL><DEDENT>try:<EOL><INDENT>multiarray.broadcast(a1, a2)<EOL><DEDENT>except:<EOL><INDENT>return False<EOL><DEDENT>return bool(asarray(a1 == a2).all())<EOL>

Returns True if input arrays are shape consistent and all elements equal.

Shape consistent means they are either the same shape, or one input array
can be broadcasted to create the same shape as the other one.

Parameters
----------
a1, a2 : array_like
    Input arrays.

Returns
-------
out : bool
    True if equivalent, False otherwise.

Examples
--------
>>> np.array_equiv([1, 2], [1, 2])
True
>>> np.array_equiv([1, 2], [1, 3])
False

Showing the shape equivalence:

>>> np.array_equiv([1, 2], [[1, 2], [1, 2]])
True
>>> np.array_equiv([1, 2], [[1, 2, 1, 2], [1, 2, 1, 2]])
False

>>> np.array_equiv([1, 2], [[1, 2], [1, 3]])
False


def seterr(all=None, divide=None, over=None, under=None, invalid=None):

pyvals = umath.geterrobj()<EOL>old = geterr()<EOL>if divide is None: divide = all or old['<STR_LIT>']<EOL>if over is None: over = all or old['<STR_LIT>']<EOL>if under is None: under = all or old['<STR_LIT>']<EOL>if invalid is None: invalid = all or old['<STR_LIT>']<EOL>maskvalue = ((_errdict[divide] << SHIFT_DIVIDEBYZERO) +<EOL>(_errdict[over] << SHIFT_OVERFLOW ) +<EOL>(_errdict[under] << SHIFT_UNDERFLOW) +<EOL>(_errdict[invalid] << SHIFT_INVALID))<EOL>pyvals[<NUM_LIT:1>] = maskvalue<EOL>umath.seterrobj(pyvals)<EOL>return old<EOL>

Set how floating-point errors are handled.

Note that operations on integer scalar types (such as `int16`) are
handled like floating point, and are affected by these settings.

Parameters
----------
all : {'ignore', 'warn', 'raise', 'call', 'print', 'log'}, optional
    Set treatment for all types of floating-point errors at once:

    - ignore: Take no action when the exception occurs.
    - warn: Print a `RuntimeWarning` (via the Python `warnings` module).
    - raise: Raise a `FloatingPointError`.
    - call: Call a function specified using the `seterrcall` function.
    - print: Print a warning directly to ``stdout``.
    - log: Record error in a Log object specified by `seterrcall`.

    The default is not to change the current behavior.
divide : {'ignore', 'warn', 'raise', 'call', 'print', 'log'}, optional
    Treatment for division by zero.
over : {'ignore', 'warn', 'raise', 'call', 'print', 'log'}, optional
    Treatment for floating-point overflow.
under : {'ignore', 'warn', 'raise', 'call', 'print', 'log'}, optional
    Treatment for floating-point underflow.
invalid : {'ignore', 'warn', 'raise', 'call', 'print', 'log'}, optional
    Treatment for invalid floating-point operation.

Returns
-------
old_settings : dict
    Dictionary containing the old settings.

See also
--------
seterrcall : Set a callback function for the 'call' mode.
geterr, geterrcall, errstate

Notes
-----
The floating-point exceptions are defined in the IEEE 754 standard [1]:

- Division by zero: infinite result obtained from finite numbers.
- Overflow: result too large to be expressed.
- Underflow: result so close to zero that some precision
  was lost.
- Invalid operation: result is not an expressible number, typically
  indicates that a NaN was produced.

.. [1] http://en.wikipedia.org/wiki/IEEE_754

Examples
--------
>>> old_settings = np.seterr(all='ignore')  #seterr to known value
>>> np.seterr(over='raise')
{'over': 'ignore', 'divide': 'ignore', 'invalid': 'ignore',
 'under': 'ignore'}
>>> np.seterr(**old_settings)  # reset to default
{'over': 'raise', 'divide': 'ignore', 'invalid': 'ignore', 'under': 'ignore'}

>>> np.int16(32000) * np.int16(3)
30464
>>> old_settings = np.seterr(all='warn', over='raise')
>>> np.int16(32000) * np.int16(3)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
FloatingPointError: overflow encountered in short_scalars

>>> old_settings = np.seterr(all='print')
>>> np.geterr()
{'over': 'print', 'divide': 'print', 'invalid': 'print', 'under': 'print'}
>>> np.int16(32000) * np.int16(3)
Warning: overflow encountered in short_scalars
30464