Numpy Core

O core é um dos módulos fundamentais do Numpy. As funções nele definidas servem de base para as funcionalidades mais avançadas do pacote. As funções definidas no módulo core estão definidas no espaço de nomes mais global do numpy.

• Classe_1

• Constante_1

# Funções

alen()
Retorna o comprimento de um objeto Python tratando-o como um arranjo de pelo menos uma dimensão.
all(x, axis=None, out=None)
Retorna "True" se todos os elementos de x forem "True", ou seja, não-zero.
allclose(a, b, rtol=1.0000000000000001e-05, atol=1e-08)
Retorna "True" se todos os elementos de de a e b forem iguais, dentro das tolerâncias especificadas. rtol representa o erro relativo e deve ser positivo e « 1.0. O erro absoluto, atol, normalmente é considerado para elementos de b que são muito pequenos ou zero; atol diz quão pequeno a também deve ser.
alltrue(x, axis=None, out=None)
Realiza um "and" lógico ao longo do eixo dado.
alterdot()
amax(a, axis=None, out=None)
Retorna o valor máximo ao longo da dimensão especificada por "axis".
amin(a, axis=None, out=None)
Retorna o valor mínimo ao longo da dimensão especificada por "axis".
any(x, axis=None, out=None)
Retorna "True" se pelo menos um dos elementos de x for verdadeiro, ou seja, não-zero.
arange()
Cria um arranjo a partir da especificação de um intervalo.
argmax(a, axis=None)
Retorna os índices para o valor máximo dos arranjo unidimensionais ao longo do eixo especificado.

argmin(a, axis=None)
argmin(a,axis=None) returns the indices to the minimum value of the
1-D arrays along the given axis.

argsort(a, axis=-1, kind='quicksort', order=None)
Returns array of indices that index 'a' in sorted order.

*Description*

Perform an indirect sort along the given axis using the algorithm specified
by the kind keyword. It returns an array of indices of the same shape as
a that index data along the given axis in sorted order.

*Parameters*:

a : array type
Array containing values that the returned indices should sort.

axis : integer
Axis to be indirectly sorted. None indicates that the flattened
array should be used. Default is -1.

kind : string
Sorting algorithm to use. Possible values are 'quicksort',
'mergesort', or 'heapsort'. Default is 'quicksort'.

order : list type or None
When a is an array with fields defined, this argument specifies
which fields to compare first, second, etc. Not all fields need be
specified.

*Returns*:

indices : integer array
Array of indices that sort 'a' along the specified axis.

*SeeAlso*:

lexsort
Indirect stable sort with multiple keys
sort
Inplace sort

*Notes*

The various sorts are characterized by average speed, worst case
performance, need for work space, and whether they are stable. A stable
sort keeps items with the same key in the same relative order. The
three available algorithms have the following properties:

+---+-+---+--+-+
| kind | speed | worst case | work space | stable|
+===========+=======+=============+============+=======+
| quicksort | 1 | O(n^2) | 0 | no |
+---+-+---+--+-+
| mergesort | 2 | O(n*log(n)) | ~n/2 | yes |
+---+-+---+--+-+
| heapsort | 3 | O(n*log(n)) | 0 | no |
+---+-+---+--+-+

All the sort algorithms make temporary copies of the data when the sort
is not along the last axis. Consequently, sorts along the last axis are
faster and use less space than sorts along other axis.

argwhere(a)
Return a 2-d array of shape N x a.ndim where each row
is a sequence of indices into a. This sequence must be
converted to a tuple in order to be used to index into a.

around = round_(a, decimals=0, out=None)
Returns reference to result. Copies a and rounds to 'decimals' places.

Keyword arguments:
decimals — number of decimal places to round to (default 0).
out — existing array to use for output (default copy of a).

Returns:
Reference to out, where None specifies a copy of the original array a.

Round to the specified number of decimals. When 'decimals' is negative it
specifies the number of positions to the left of the decimal point. The
real and imaginary parts of complex numbers are rounded separately.
Nothing is done if the array is not of float type and 'decimals' is greater
than or equal to 0.

The keyword 'out' may be used to specify a different array to hold the
result rather than the default 'a'. If the type of the array specified by
'out' differs from that of 'a', the result is cast to the new type,
otherwise the original type is kept. Floats round to floats by default.

Numpy rounds to even. Thus 1.5 and 2.5 round to 2.0, -0.5 and 0.5 round to
0.0, etc. Results may also be surprising due to the inexact representation
of decimal fractions in IEEE floating point and the errors introduced in
scaling the numbers when 'decimals' is something other than 0.

The function around is an alias for round_.

array()
Cria um arranjo a partir de um objeto iterável em Python

array2string(a, max_line_width=None, precision=None, suppress_small=None, separator=' ', prefix='', style=<built-in function repr>)
Return a string representation of an array.

:Parameters:
a : ndarray
Input array.
max_line_width : int
The maximum number of columns the string should span. Newline
characters splits the string appropriately after array elements.
precision : int
Floating point precision.
suppress_small : bool
Represent very small numbers as zero.
separator : string
Inserted between elements.
prefix : string
An array is typically printed as

'prefix(' + array2string(a) + ')'

The length of the prefix string is used to align the
output correctly.
style : function

Examples
-—-

»> x = N.array([1e-16,1,2,3])
»> print array2string(x,precision=2,separator=',',suppress_small=True)
[ 0., 1., 2., 3.]

array_equal(a1, a2)

array_equiv(a1, a2)

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

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

asanyarray(a, dtype=None, order=None)
Returns a as an array, but will pass subclasses through.

asarray(a, dtype=None, order=None)
Returns a as an array.

Unlike array(), no copy is performed if a is already an array. Subclasses
are converted to base class ndarray.

ascontiguousarray(a, dtype=None)
Return 'a' as an array contiguous in memory (C order).

asfortranarray(a, dtype=None)
Return 'a' as an array laid out in Fortran-order in memory.

asmatrix(data, dtype=None)
Returns 'data' as a matrix. Unlike matrix(), no copy is performed
if 'data' is already a matrix or array. Equivalent to:
matrix(data, copy=False)

Return the representation of a number in the given base.

Base can't be larger than 36.

binary_repr(num, width=None)
Return the binary representation of the input number as a string.

This is equivalent to using base_repr with base 2, but about 25x
faster.

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

bmat(obj, ldict=None, gdict=None)
Build a matrix object from string, nested sequence, or array.

Ex: F = bmat('A, B; C, D')
F = bmat([[A,B],[C,D]])
F = bmat(r_[c_[A,B],c_[C,D]])

all produce the same Matrix Object [ A B ]
[ C D ]

if A, B, C, and D are appropriately shaped 2-d arrays.

can_cast(…)
can_cast(from=d1, to=d2)

Returns True if data type d1 can be cast to data type d2 without
losing precision.

choose(a, choices, out=None, mode='raise')
Use an index array to construct a new array from a set of choices.

Given an array of integers in {0, 1, …, n-1} and a set of n choice arrays,
this function will create a new array that merges each of the choice arrays.
Where a value in a is i, then the new array will have the value that
choices[i] contains in the same place.

:Parameters:
- ‘a : int array
This array must contain integers in [0, n-1], where n is the number of
choices.
- choices : sequence of arrays
Each of the choice arrays should have the same shape as the index array.
- out : array, optional
If provided, the result will be inserted into this array. It should be
of the appropriate shape and dtype
- mode : one of ’raise', 'wrap', or 'clip', optional (default='raise')
Specifies how out-of-bounds indices will behave.
- 'raise' : raise an error
- 'wrap' : wrap around
- 'clip' : clip to the range

:Returns:
- merged_array : array

numpy.ndarray.choose() is the equivalent method.

:Example:
»> choices = [[0, 1, 2, 3], [10, 11, 12, 13],
… [20, 21, 22, 23], [30, 31, 32, 33]]
»> choose([2, 3, 1, 0], choices)
array([20, 31, 12, 3])
»> choose([2, 4, 1, 0], choices, mode='clip')
array([20, 31, 12, 3])
»> choose([2, 4, 1, 0], choices, mode='wrap')
array([20, 1, 12, 3])

clip(m, m_min, m_max)
clip(m, m_min, m_max) = every entry in m that is less than m_min is
replaced by m_min, and every entry greater than m_max is replaced by
m_max.

compare_chararrays(…)

compress(condition, m, axis=None, out=None)
compress(condition, x, axis=None) = those elements of x corresponding
to those elements of condition that are "true". condition must be the
same size as the given dimension of x.

concatenate(…)
concatenate((a1, a2, …), axis=0)

Join arrays together.

The tuple of sequences (a1, a2, …) are joined along the given axis
(default is the first one) into a single numpy array.

Example:

»> concatenate( ([0,1,2], [5,6,7]) )
array([0, 1, 2, 5, 6, 7])

convolve(a, v, mode='full')
Returns the discrete, linear convolution of 1-D sequences a and v; mode
can be 'valid', 'same', or 'full' to specify size of the resulting sequence.

correlate(a, v, mode='valid')
Return the discrete, linear correlation of 1-D sequences a and v; mode
can be 'valid', 'same', or 'full' to specify the size of the resulting
sequence

cross(a, b, axisa=-1, axisb=-1, axisc=-1, axis=None)
Return the cross product of two (arrays of) vectors.

The cross product is performed over the last axis of a and b by default,
and can handle axes with dimensions 2 and 3. For a dimension of 2,
the z-component of the equivalent three-dimensional cross product is
returned.

cumprod(a, axis=None, dtype=None, out=None)
Return the cumulative product of the elments along the given axis

cumproduct(x, axis=None, dtype=None, out=None)
Sum the array over the given axis.

cumsum(x, axis=None, dtype=None, out=None)
Sum the array over the given axis.

diagonal(a, offset=0, axis1=0, axis2=1)
Return specified diagonals. Uses first two indices by default.

*Description*

If a is 2-d, returns the diagonal of self with the given offset, i.e., the
collection of elements of the form a[i,i+offset]. If a is n-d with n > 2,
then the axes specified by axis1 and axis2 are used to determine the 2-d
subarray whose diagonal is returned. The shape of the resulting array can be
determined by removing axis1 and axis2 and appending an index to the right
equal to the size of the resulting diagonals.

*Parameters*:

offset : integer
Offset of the diagonal from the main diagonal. Can be both positive
and negative. Defaults to main diagonal.

axis1 : integer
Axis to be used as the first axis of the 2-d subarrays from which
the diagonals should be taken. Defaults to first axis.

axis2 : integer
Axis to be used as the second axis of the 2-d subarrays from which
the diagonals should be taken. Defaults to second axis.

*Returns*:

array_of_diagonals : type of original array
If a is 2-d, then a 1-d array containing the diagonal is returned.
If a is n-d, n > 2, then an array of diagonals is returned.

*SeeAlso*:

diag :
matlab workalike for 1-d and 2-d arrays
diagflat :
creates diagonal arrays
trace :
sum along diagonals

*Examples*:

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

»> a = arange(8).reshape(2,2,2)
»> a
array([[[0, 1],
[2, 3]],
[[4, 5],
[6, 7]]])
»> a.diagonal(0,-2,-1)
array([[0, 3],
[4, 7]])

dot(…)

empty()
Cria um arranjo de qualquer tamanho e com qualquer tipo de dados, mas não inicializa os seus elementos.
empty_like()
Cria um arranjo semelhante a um outro arranjo já existente, mas não inicializa os seus elementos.

fastCopyAndTranspose = _fastCopyAndTranspose(…)
_fastCopyAndTranspose(a)

flatnonzero(a)
Return indicies that are not-zero in flattened version of a

Equivalent to a.ravel().nonzero()

frombuffer(…)
frombuffer(buffer=, dtype=float, count=-1, offset=0)

Returns a 1-d array of data type dtype from buffer. The buffer
argument must be an object that exposes the buffer interface. If
count is -1 then the entire buffer is used, otherwise, count is the
size of the output. If offset is given then jump that far into the
buffer. If the buffer has data that is out not in machine byte-order,
than use a propert data type descriptor. The data will not be
byteswapped, but the array will manage it in future operations.

fromfile(…)
fromfile(file=, dtype=float, count=-1, sep='') -> array.

Required arguments:
file — open file object or string containing file name.

Keyword arguments:
dtype — type and order of the returned array (default float)
count — number of items to input (default all)
sep — separater between items if file is a text file (default "")

Return an array of the given data type from a text or binary file. The
'file' argument can be an open file or a string with the name of a file to
read from. If 'count' == -1 the entire file is read, otherwise count is the
number of items of the given type to read in. If 'sep' is "" it means to
read binary data from the file using the specified dtype, otherwise it gives
the separator between elements in a text file. The 'dtype' value is also
used to determine the size and order of the items in binary files.

Data written using the tofile() method can be conveniently recovered using
this function.

WARNING: This function should be used sparingly as the binary files are not
platform independent. In particular, they contain no endianess or datatype
information. Nevertheless it can be useful for reading in simply formatted
or binary data quickly.

fromfunction(function, shape, **kwargs)
Returns an array constructed by calling a function on a tuple of number
grids.

The function should accept as many arguments as the length of shape and
work on array inputs. The shape argument is a sequence of numbers
indicating the length of the desired output for each axis.

The function can also accept keyword arguments (except dtype), which will
be passed through fromfunction to the function itself. The dtype argument
(default float) determines the data-type of the index grid passed to the
function.

fromiter(…)
fromiter(iterable, dtype, count=-1)

Return a new 1d array initialized from iterable. If count is
nonegative, the new array will have count elements, otherwise it's
size is determined by the generator.

frompyfunc(…)
frompyfunc(func, nin, nout) take an arbitrary python function that takes nin objects as input and returns nout objects and return a universal function (ufunc). This ufunc always returns PyObject arrays

fromstring(…)
fromstring(string, dtype=float, count=-1, sep='')

Return a new 1d array initialized from the raw binary data in string.

If count is positive, the new array will have count elements, otherwise its
size is determined by the size of string. If sep is not empty then the
string is interpreted in ASCII mode and converted to the desired number type
using sep as the separator between elements (extra whitespace is ignored).

get_printoptions()
Return the current print options.

:Returns:
precision : int
threshold : int
edgeitems : int
linewidth : int
suppress : bool

:SeeAlso:
- set_printoptions : parameter descriptions

getbuffer(…)
getbuffer(obj [,offset[, size]])

Create a buffer object from the given object referencing a slice of
length size starting at offset. Default is the entire buffer. A

getbufsize()
Return the size of the buffer used in ufuncs.

geterr()
Get the current way of handling floating-point errors.

Returns a dictionary with entries "divide", "over", "under", and
"invalid", whose values are from the strings
"ignore", "print", "log", "warn", "raise", and "call".

geterrcall()
Return the current callback function used on floating-point errors.

geterrobj(…)

identity()
indices()
Gera um grid contendo índices organizados em linha e em coluna.

inner(…)
inner(a,b)

Returns the dot product of two arrays, which has shape a.shape[:-1] +
b.shape[:-1] with elements computed by the product of the elements
from the last dimensions of a and b.

int_asbuffer(…)

isfortran(a)
Returns True if 'a' is arranged in Fortran-order in memory with a.ndim > 1

isscalar(num)
Returns True if the type of num is a scalar type.

issctype(rep)
Determines whether the given object represents
a numeric array type.

lexsort(…)
lexsort(keys=, axis=-1) -> array of indices. Argsort with list of keys.

Perform an indirect sort using a list of keys. The first key is sorted,
then the second, and so on through the list of keys. At each step the
previous order is preserved when equal keys are encountered. The result is
a sort on multiple keys. If the keys represented columns of a spreadsheet,
for example, this would sort using multiple columns (the last key being
used for the primary sort order, the second-to-last key for the secondary
sort order, and so on). The keys argument must be a sequence of things
that can be converted to arrays of the same shape.

:Parameters:

a : array type
Array containing values that the returned indices should sort.

axis : integer
Axis to be indirectly sorted. None indicates that the flattened
array should be used. Default is -1.

:Returns:

indices : integer array
Array of indices that sort the keys along the specified axis. The
array has the same shape as the keys.

:SeeAlso:

- argsort : indirect sort
- sort : inplace sort

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

Load ASCII data from fname into an array and return the array.

The data must be regular, same number of values in every row

fname can be a filename or a file handle. Support for gzipped files is
automatic, if the filename ends in .gz

Example usage:

X = loadtxt('test.dat') # data in two columns
t = X[:,0]
y = X[:,1]

Alternatively, you can do the same with "unpack"; see below

X = loadtxt('test.dat') # a matrix of data
x = loadtxt('test.dat') # a single column of data

dtype - the data-type of the resulting array. If this is a
record data-type, the the resulting array will be 1-d and each row will
be interpreted as an element of the array. The number of columns
used must match the number of fields in the data-type in this case.

comments - the character used to indicate the start of a comment
in the file

delimiter is a string-like character used to seperate values in the
file. If delimiter is unspecified or none, any whitespace string is
a separator.

converters, if not None, is a dictionary mapping column number to
a function that will convert that column to a float. Eg, if
column 0 is a date string: converters={0:datestr2num}

skiprows is the number of rows from the top to skip

usecols, if not None, is a sequence of integer column indexes to
extract where 0 is the first column, eg usecols=(1,4,5) to extract
just the 2nd, 5th and 6th columns

unpack, if True, will transpose the matrix allowing you to unpack
into named arguments on the left hand side

t,y = load('test.dat', unpack=True) # for two column data

mat = asmatrix(data, dtype=None)
Returns 'data' as a matrix. Unlike matrix(), no copy is performed
if 'data' is already a matrix or array. Equivalent to:
matrix(data, copy=False)

maximum_sctype(t)
returns the sctype of highest precision of the same general kind as 't'

mean(a, axis=None, dtype=None, out=None)
Compute the mean along the specified axis.

*Description*

Returns the average of the array elements. The average is taken over
the flattened array by default, otherwise over the specified axis.

*Parameters*:

axis : integer
Axis along which the means are computed. The default is
to compute the standard deviation of the flattened array.

dtype : type
Type to use in computing the means. For arrays of
integer type the default is float32, for arrays of float types it
is the same as the array type.

out : ndarray
Alternative output array in which to place the result. It must have
the same shape as the expected output but the type will be cast if
necessary.

*Returns*:

mean : The return type varies, see above.
A new array holding the result is returned unless out is specified,
in which case a reference to out is returned.

*SeeAlso*:

var
Variance
std
Standard deviation

*Notes*

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

ndim(a)

newbuffer(…)
newbuffer(size)

Return a new uninitialized buffer object of size bytes

nonzero(a)
nonzero(a) returns the indices of the elements of a which are not zero

obj2sctype(rep, default=None)

ones()
Cria um arranjo composto apenas de unidades.

outer(a, b)
Returns the outer product of two vectors.

result[i,j] = a[i]*b[j] when a and b are vectors.
Will accept any arguments that can be made into vectors.

prod(a, axis=None, dtype=None, out=None)
Return the product of the elements along the given axis

product(x, axis=None, dtype=None, out=None)
Product of the array elements over the given axis.

ptp(a, axis=None, out=None)
Return maximum - minimum along the the given dimension

put(a, ind, v, mode='raise')
put(a, ind, v) results in a[n] = v[n] for all n in ind
If v is shorter than mask it will be repeated as necessary.
In particular v can be a scalar or length 1 array.
The routine put is the equivalent of the following (although the loop
is in C for speed):

ind = array(indices, copy=False)
v = array(values, copy=False).astype(a.dtype)
for i in ind: a.flat[i] = v[i]
a must be a contiguous numpy array.

mask.flat[n] is true. If values is not the same size of a and mask then
it will repeat. This gives different behavior than a[mask] = values.

rank(a)
Get the rank of sequence a (the number of dimensions, not a matrix rank)
The rank of a scalar is zero.

ravel(m, order='C')
ravel(m) returns a 1d array corresponding to all the elements of it's
argument. The new array is a view of m if possible, otherwise it is
a copy.

repeat(a, repeats, axis=None)
Repeat elements of an array.

:Parameters:
- a : array
- repeats : int or int array
The number of repetitions for each element. If a plain integer, then it
is applied to all elements. If an array, it needs to be of the same
length as the chosen axis.
- axis : None or int, optional (default=None)
The axis along which to repeat values. If None, then this function will
operated on the flattened array a and return a similarly flat result.

:Returns:
- repeated_array : array

numpy.ndarray.repeat() is the equivalent method.

:Example:
»> repeat([0, 1, 2], 2)
array([0, 0, 1, 1, 2, 2])
»> repeat([0, 1, 2], [2, 3, 4])
array([0, 0, 1, 1, 1, 2, 2, 2, 2])

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

reshape(a, newshape, order='C')
Return an array that uses the data of the given array, but with a new
shape.

:Parameters:
- ‘a : array
- newshape : shape tuple or int
The new shape should be compatible with the original shape. If an
integer, then the result will be a 1D array of that length.
- order : ’C' or 'FORTRAN', optional (default='C')
Whether the array data should be viewed as in C (row-major) order or
FORTRAN (column-major) order.

:Returns:
- reshaped_array : array
This will be a new view object if possible; otherwise, it will return
a copy.

numpy.ndarray.reshape() is the equivalent method.

resize(a, new_shape)
resize(a,new_shape) returns a new array with the specified shape.
The original array's total size can be any size. It
fills the new array with repeated copies of a.

Note that a.resize(new_shape) will fill array with 0's
beyond current definition of a.

restoredot()

roll(a, shift, axis=None)
Roll the elements in the array by 'shift' positions along
the given axis.

rollaxis(a, axis, start=0)
Return transposed array so that axis is rolled before start.

if a.shape is (3,4,5,6)
rollaxis(a, 3, 1).shape is (3,6,4,5)
rollaxis(a, 2, 0).shape is (5,3,4,6)
rollaxis(a, 1, 3).shape is (3,5,4,6)
rollaxis(a, 1, 4).shape is (3,5,6,4)

round_(a, decimals=0, out=None)
Returns reference to result. Copies a and rounds to 'decimals' places.

Keyword arguments:
decimals — number of decimal places to round to (default 0).
out — existing array to use for output (default copy of a).

Returns:
Reference to out, where None specifies a copy of the original array a.

Round to the specified number of decimals. When 'decimals' is negative it
specifies the number of positions to the left of the decimal point. The
real and imaginary parts of complex numbers are rounded separately.
Nothing is done if the array is not of float type and 'decimals' is greater
than or equal to 0.

The keyword 'out' may be used to specify a different array to hold the
result rather than the default 'a'. If the type of the array specified by
'out' differs from that of 'a', the result is cast to the new type,
otherwise the original type is kept. Floats round to floats by default.

Numpy rounds to even. Thus 1.5 and 2.5 round to 2.0, -0.5 and 0.5 round to
0.0, etc. Results may also be surprising due to the inexact representation
of decimal fractions in IEEE floating point and the errors introduced in
scaling the numbers when 'decimals' is something other than 0.

The function around is an alias for round_.

savetxt(fname, X, fmt='%.18e', delimiter=' ')
Save the data in X to file fname using fmt string to convert the
data to strings

fname can be a filename or a file handle. If the filename ends in .gz,
the file is automatically saved in compressed gzip format. The load()
command understands gzipped files transparently.

Example usage:

save('test.out', X) # X is an array
save('test1.out', (x,y,z)) # x,y,z equal sized 1D arrays
save('test2.out', x) # x is 1D
save('test3.out', x, fmt='%1.4e') # use exponential notation

delimiter is used to separate the fields, eg delimiter ',' for
comma-separated values

sctype2char(sctype)

searchsorted(a, v, side='left')
Returns indices where keys in v should be inserted to maintain order.

*Description*

Find the indices into a sorted array such that if the corresponding
keys in v were inserted before the indices the order of a would be
preserved. If side='left', then the first such index is returned. If
side='right', then the last such index is returned. If there is no such
index because the key is out of bounds, then the length of a is
returned, i.e., the key would need to be appended. The returned index
array has the same shape as v.

*Parameters*:

a : array
1-d array sorted in ascending order.

v : array or list type
Array of keys to be searched for in a.

side : string
Possible values are : 'left', 'right'. Default is 'left'. Return
the first or last index where the key could be inserted.

*Returns*:

indices : integer array
Array of insertion points with the same shape as v.

*SeeAlso*:

sort
Inplace sort
histogram
Produce histogram from 1-d data

*Notes*

The array a must be 1-d and is assumed to be sorted in ascending order.
Searchsorted uses binary search to find the required insertion points.

set_numeric_ops(…)
set_numeric_ops(op=func, …)

Set some or all of the number methods for all array objects. Do not
forget **dict can be used as the argument list. Return the functions
that were replaced, which can be stored and set later.

set_printoptions(precision=None, threshold=None, edgeitems=None, linewidth=None, suppress=None)
Set options associated with printing.

:Parameters:
precision : int
Number of digits of precision for floating point output (default 8).
threshold : int
Total number of array elements which trigger summarization
rather than full repr (default 1000).
edgeitems : int
Number of array items in summary at beginning and end of
each dimension (default 3).
linewidth : int
The number of characters per line for the purpose of inserting
line breaks (default 75).
suppress : bool
Whether or not suppress printing of small floating point values
using scientific notation (default False).

set_string_function(…)
set_string_function(f, repr=1)

Set the python function f to be the function used to obtain a pretty
printable string version of an array whenever an array is printed.
f(M) should expect an array argument M, and should return a string
consisting of the desired representation of M for printing.

setbufsize(size)
Set the size of the buffer used in ufuncs.

seterr(all=None, divide=None, over=None, under=None, invalid=None)
Set how floating-point errors are handled.

Valid values for each type of error are the strings
"ignore", "warn", "raise", and "call". Returns the old settings.
If 'all' is specified, values that are not otherwise specified
will be set to 'all', otherwise they will retain their old
values.

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

Example:

»> seterr(over='raise') # doctest: +SKIP
{'over': 'ignore', 'divide': 'ignore', 'invalid': 'ignore', 'under': 'ignore'}

»> seterr(all='warn', over='raise') # doctest: +SKIP
{'over': 'raise', 'divide': 'ignore', 'invalid': 'ignore', 'under': 'ignore'}

»> int16(32000) * int16(3) # doctest: +SKIP
Traceback (most recent call last):
File "<stdin>", line 1, in ?
FloatingPointError: overflow encountered in short_scalars
»> seterr(all='ignore') # doctest: +SKIP
{'over': 'ignore', 'divide': 'ignore', 'invalid': 'ignore', 'under': 'ignore'}

seterrcall(func)
Set the callback function used when a floating-point error handler
is set to 'call' or the object with a write method for use when
the floating-point error handler is set to 'log'

'func' should be a function that takes two arguments. The first is
type of error ("divide", "over", "under", or "invalid"), and the second
is the status flag (= divide + 2*over + 4*under + 8*invalid).

Returns the old handler.

seterrobj(…)

shape(a)
shape(a) returns the shape of a (as a function call which
also works on nested sequences).

size(a, axis=None)
Get the number of elements in sequence a, or along a certain axis.

sometrue(x, axis=None, out=None)
Perform a logical_or over the given axis.

sort(a, axis=-1, kind='quicksort', order=None)
Return copy of 'a' sorted along the given axis.

*Description*

Perform an inplace sort along the given axis using the algorithm specified
by the kind keyword.

*Parameters*:

a : array type
Array to be sorted.

axis : integer
Axis to be sorted along. None indicates that the flattened array
should be used. Default is -1.

kind : string
Sorting algorithm to use. Possible values are 'quicksort',
'mergesort', or 'heapsort'. Default is 'quicksort'.

order : list type or None
When a is an array with fields defined, this argument specifies
which fields to compare first, second, etc. Not all fields need be
specified.

*Returns*:

sorted_array : type is unchanged.

*SeeAlso*:

argsort
Indirect sort
lexsort
Indirect stable sort on multiple keys
searchsorted
Find keys in sorted array

*Notes*

The various sorts are characterized by average speed, worst case
performance, need for work space, and whether they are stable. A stable
sort keeps items with the same key in the same relative order. The
three available algorithms have the following properties:

+---+-+---+--+-+
| kind | speed | worst case | work space | stable|
+===========+=======+=============+============+=======+
| quicksort | 1 | O(n^2) | 0 | no |
+---+-+---+--+-+
| mergesort | 2 | O(n*log(n)) | ~n/2 | yes |
+---+-+---+--+-+
| heapsort | 3 | O(n*log(n)) | 0 | no |
+---+-+---+--+-+

All the sort algorithms make temporary copies of the data when the sort
is not along the last axis. Consequently, sorts along the last axis are
faster and use less space than sorts along other axis.

squeeze(a)
Returns a with any ones from the shape of a removed

std(a, axis=None, dtype=None, out=None)
Compute the standard deviation along the specified axis.

*Description*

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

*Parameters*:

axis : integer
Axis along which the standard deviation is computed. The default is
to compute the standard deviation of the flattened array.

dtype : type
Type to use in computing the standard deviation. For arrays of
integer type the default is float32, for arrays of float types it
is the same as the array type.

out : ndarray
Alternative output array in which to place the result. It must have
the same shape as the expected output but the type will be cast if
necessary.

*Returns*:

standard_deviation : The return type varies, see above.
A new array holding the result is returned unless out is specified,
in which case a reference to out is returned.

*SeeAlso*:

var
Variance
mean
Average

*Notes*

The standard deviation is the square root of the average of the squared
deviations from the mean, i.e. var = sqrt(mean((x - x.mean())**2)).
The computed standard deviation is biased, i.e., the mean is computed
by dividing by the number of elements, N, rather than by N-1.

sum(x, axis=None, dtype=None, out=None)
Sum the array over the given axis. The optional dtype argument
is the data type for intermediate calculations.

The default is to upcast (promote) smaller integer types to the
platform-dependent Int. For example, on 32-bit platforms:

x.dtype default sum() dtype
-----------
bool, int8, int16, int32 int32

Examples:
»> N.sum([0.5, 1.5])
2.0
»> N.sum([0.5, 1.5], dtype=N.int32)
1
»> N.sum([[0, 1], [0, 5]])
6
»> N.sum([[0, 1], [0, 5]], axis=1)
array([1, 5])

swapaxes(a, axis1, axis2)
swapaxes(a, axis1, axis2) returns array a with axis1 and axis2
interchanged.

take(a, indices, axis=None, out=None, mode='raise')
Return an array with values pulled from the given array at the given
indices.

This function does the same thing as "fancy" indexing; however, it can be
easier to use if you need to specify a given axis.

:Parameters:
- ‘a : array
The source array
- indices : int array
The indices of the values to extract.
- axis : None or int, optional (default=None)
The axis over which to select values. None signifies that the operation
should be performed over the flattened array.
- out : array, optional
If provided, the result will be inserted into this array. It should be
of the appropriate shape and dtype.
- mode : one of ’raise', 'wrap', or 'clip', optional (default='raise')
Specifies how out-of-bounds indices will behave.
- 'raise' : raise an error
- 'wrap' : wrap around
- 'clip' : clip to the range

:Returns:
- subarray : array

numpy.ndarray.take() is the equivalent method.

tensordot(a, b, axes=2)
tensordot returns the product for any (ndim >= 1) arrays.

r_{xxx, yyy} = \sum_k a_{xxx,k} b_{k,yyy} where

the axes to be summed over are given by the axes argument.
the first element of the sequence determines the axis or axes
in arr1 to sum over, and the second element in axes argument sequence
determines the axis or axes in arr2 to sum over.

When there is more than one axis to sum over, the corresponding
arguments to axes should be sequences of the same length with the first
axis to sum over given first in both sequences, the second axis second,
and so forth.

If the axes argument is an integer, N, then the last N dimensions of a
and first N dimensions of b are summed over.

trace(a, offset=0, axis1=0, axis2=1, dtype=None, out=None)
trace(a,offset=0, axis1=0, axis2=1) returns the sum along diagonals
(defined by the last two dimenions) of the array.

transpose(a, axes=None)
transpose(a, axes=None) returns a view of the array with
dimensions permuted according to axes. If axes is None
(default) returns array with dimensions reversed.

var(a, axis=None, dtype=None, out=None)
Compute the variance along the specified axis.

*Description*

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

*Parameters*:

axis : integer
Axis along which the variance is computed. The default is to
compute the variance of the flattened array.

dtype : type
Type to use in computing the variance. For arrays of integer type
the default is float32, for arrays of float types it is the same as
the array type.

out : ndarray
Alternative output array in which to place the result. It must have
the same shape as the expected output but the type will be cast if
necessary.

*Returns*:

variance : depends, see above
A new array holding the result is returned unless out is specified,
in which case a reference to out is returned.

*SeeAlso*:

std
Standard deviation
mean
Average

*Notes*

The variance is the average of the squared deviations from the mean,
i.e. var = mean((x - x.mean())**2). The computed variance is biased,
i.e., the mean is computed by dividing by the number of elements, N,
rather than by N-1.

vdot(a, b)
Returns the dot product of 2 vectors (or anything that can be made into
a vector).

Note: this is not the same as dot`, as it takes the conjugate of its first
argument if complex and always returns a scalar.

where(…)
where(condition, | x, y)

The result is shaped like condition and has elements of x and y where
condition is respectively true or false. If x or y are not given,
then it is equivalent to condition.nonzero().

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

transpose(where(condition, | x, y))

instead. This always results in a 2d array, with a row of indices for
each element that satisfies the condition.

zeros()
Cria um arranjo composto apenas por zeros.
zeros_like()
Cria um arranjo semelhante a um arranjo já existente, mas composto apenas de zeros.