| Trees | Indices | Help |
|---|
|
|
NumPy
==========
You can support the development of NumPy and SciPy by purchasing
the book "Guide to NumPy" at
http://www.trelgol.com
It is being distributed for a fee for only a few years to
cover some of the costs of development. After the restriction period
it will also be freely available.
Additional documentation is available in the docstrings and at
http://www.scipy.org.
Available subpackages
---------------------
core --- Defines a multi-dimensional array and useful procedures
for Numerical computation.
lib --- Basic functions used by several sub-packages and useful
to have in the main name-space.
random --- Core Random Tools
linalg --- Core Linear Algebra Tools
fft --- Core FFT routines
testing --- Numpy testing tools
These packages require explicit import
f2py --- Fortran to Python Interface Generator.
distutils --- Enhancements to distutils with support for
Fortran compilers support and more.
Global symbols from subpackages
-------------------------------
core --> *
lib --> *
testing --> NumpyTest
Utility tools
-------------
test --- Run numpy unittests
pkgload --- Load numpy packages
show_config --- Show numpy build configuration
dual --- Overwrite certain functions with high-performance Scipy tools
matlib --- Make everything matrices.
__version__ --- Numpy version string
Version: 1.0.4
|
|||
| |||
|
|||
|
MachAr Diagnosing machine parameters. |
|||
|
NumpyTest Numpy tests site manager. |
|||
| PackageLoader | |||
|
RankWarning Issued by polyfit when Vandermonde matrix is rank deficient. |
|||
| ScipyTest | |||
| bool8 | |||
| bool_ | |||
| broadcast | |||
| byte | |||
|
cdouble Composed of two 64 bit floats |
|||
|
cfloat Composed of two 64 bit floats |
|||
| character | |||
| chararray | |||
|
clongdouble Composed of two 96 bit floats |
|||
|
clongfloat Composed of two 96 bit floats |
|||
|
complex128 Composed of two 64 bit floats |
|||
|
complex192 Composed of two 96 bit floats |
|||
|
complex64 Composed of two 32 bit floats |
|||
|
complex_ Composed of two 64 bit floats |
|||
| complexfloating | |||
|
csingle Composed of two 32 bit floats |
|||
| double | |||
| dtype | |||
|
errstate with errstate(**state): --> operations in following block use given state. |
|||
|
finfo Machine limits for floating point types. |
|||
| flatiter | |||
| flexible | |||
| float32 | |||
| float64 | |||
| float96 | |||
| float_ | |||
| floating | |||
| format_parser | |||
| generic | |||
|
iinfo Limits for integer types. |
|||
| inexact | |||
| int0 | |||
| int16 | |||
| int32 | |||
| int64 | |||
| int8 | |||
| int_ | |||
| intc | |||
| integer | |||
| intp | |||
|
longcomplex Composed of two 96 bit floats |
|||
| longdouble | |||
| longfloat | |||
| longlong | |||
| matrix | |||
| memmap | |||
|
ndarray An array object represents a multidimensional, homogeneous array of fixed-size items. |
|||
|
ndenumerate A simple nd index iterator over an array. |
|||
|
ndindex Pass in a sequence of integers corresponding to the number of dimensions in the counter. |
|||
| number | |||
| object0 | |||
| object_ | |||
|
poly1d A one-dimensional polynomial class. |
|||
| recarray | |||
| record | |||
| short | |||
| signedinteger | |||
| single | |||
|
singlecomplex Composed of two 32 bit floats |
|||
| str_ | |||
| string0 | |||
| string_ | |||
| ubyte | |||
|
ufunc Optimized functions make it possible to implement arithmetic with arrays efficiently |
|||
| uint | |||
| uint0 | |||
| uint16 | |||
| uint32 | |||
| uint64 | |||
| uint8 | |||
| uintc | |||
| uintp | |||
| ulonglong | |||
| unicode0 | |||
| unicode_ | |||
| unsignedinteger | |||
| ushort | |||
|
vectorize vectorize(somefunction, otypes=None, doc=None) Generalized Function class. |
|||
| void | |||
| void0 | |||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
ALLOW_THREADS = 1
|
|||
BUFSIZE = 10000
|
|||
CLIP = 0
|
|||
ERR_CALL = 3
|
|||
ERR_DEFAULT = 0
|
|||
ERR_DEFAULT2 = 2084
|
|||
ERR_IGNORE = 0
|
|||
ERR_LOG = 5
|
|||
ERR_PRINT = 4
|
|||
ERR_RAISE = 2
|
|||
ERR_WARN = 1
|
|||
FLOATING_POINT_SUPPORT = 1
|
|||
FPE_DIVIDEBYZERO = 1
|
|||
FPE_INVALID = 8
|
|||
FPE_OVERFLOW = 2
|
|||
FPE_UNDERFLOW = 4
|
|||
False_ = False
|
|||
Inf = inf
|
|||
Infinity = inf
|
|||
MAXDIMS = 32
|
|||
NAN = nan
|
|||
NINF = -inf
|
|||
NZERO = -0.0
|
|||
NaN = nan
|
|||
PINF = inf
|
|||
PZERO = 0.0
|
|||
RAISE = 2
|
|||
SHIFT_DIVIDEBYZERO = 0
|
|||
SHIFT_INVALID = 9
|
|||
SHIFT_OVERFLOW = 3
|
|||
SHIFT_UNDERFLOW = 6
|
|||
ScalarType =
|
|||
True_ = True
|
|||
UFUNC_BUFSIZE_DEFAULT = 10000
|
|||
UFUNC_PYVALS_NAME =
|
|||
WRAP = 1
|
|||
abs = <ufunc 'absolute'>
|
|||
absolute = <ufunc 'absolute'>
|
|||
add = <ufunc 'add'>
|
|||
arccos = <ufunc 'arccos'>
|
|||
arccosh = <ufunc 'arccosh'>
|
|||
arcsin = <ufunc 'arcsin'>
|
|||
arcsinh = <ufunc 'arcsinh'>
|
|||
arctan = <ufunc 'arctan'>
|
|||
arctan2 = <ufunc 'arctan2'>
|
|||
arctanh = <ufunc 'arctanh'>
|
|||
bitwise_and = <ufunc 'bitwise_and'>
|
|||
bitwise_not = <ufunc 'invert'>
|
|||
bitwise_or = <ufunc 'bitwise_or'>
|
|||
bitwise_xor = <ufunc 'bitwise_xor'>
|
|||
c_ = <numpy.lib.index_tricks.c_class object at 0x85f790c>
|
|||
cast = {<type 'numpy.int64'>: <function <lambda> at 0x8544614>
|
|||
ceil = <ufunc 'ceil'>
|
|||
conj = <ufunc 'conjugate'>
|
|||
conjugate = <ufunc 'conjugate'>
|
|||
cos = <ufunc 'cos'>
|
|||
cosh = <ufunc 'cosh'>
|
|||
divide = <ufunc 'divide'>
|
|||
e = 2.71828182846
|
|||
equal = <ufunc 'equal'>
|
|||
exp = <ufunc 'exp'>
|
|||
expm1 = <ufunc 'expm1'>
|
|||
fabs = <ufunc 'fabs'>
|
|||
floor = <ufunc 'floor'>
|
|||
floor_divide = <ufunc 'floor_divide'>
|
|||
fmod = <ufunc 'fmod'>
|
|||
frexp = <ufunc 'frexp'>
|
|||
greater = <ufunc 'greater'>
|
|||
greater_equal = <ufunc 'greater_equal'>
|
|||
hypot = <ufunc 'hypot'>
|
|||
index_exp = <numpy.lib.index_tricks._index_expression_class ob
|
|||
inf = inf
|
|||
infty = inf
|
|||
invert = <ufunc 'invert'>
|
|||
isfinite = <ufunc 'isfinite'>
|
|||
isinf = <ufunc 'isinf'>
|
|||
isnan = <ufunc 'isnan'>
|
|||
ldexp = <ufunc 'ldexp'>
|
|||
left_shift = <ufunc 'left_shift'>
|
|||
less = <ufunc 'less'>
|
|||
less_equal = <ufunc 'less_equal'>
|
|||
little_endian = False
|
|||
log = <ufunc 'log'>
|
|||
log10 = <ufunc 'log10'>
|
|||
log1p = <ufunc 'log1p'>
|
|||
logical_and = <ufunc 'logical_and'>
|
|||
logical_not = <ufunc 'logical_not'>
|
|||
logical_or = <ufunc 'logical_or'>
|
|||
logical_xor = <ufunc 'logical_xor'>
|
|||
maximum = <ufunc 'maximum'>
|
|||
mgrid = <numpy.lib.index_tricks.nd_grid object at 0x85f780c>
|
|||
minimum = <ufunc 'minimum'>
|
|||
mod = <ufunc 'remainder'>
|
|||
modf = <ufunc 'modf'>
|
|||
multiply = <ufunc 'multiply'>
|
|||
nan = nan
|
|||
nbytes = {<type 'numpy.int64'>: 8, <type 'numpy.int16'>: 2, <t
|
|||
negative = <ufunc 'negative'>
|
|||
newaxis = None
|
|||
not_equal = <ufunc 'not_equal'>
|
|||
ogrid = <numpy.lib.index_tricks.nd_grid object at 0x85f782c>
|
|||
ones_like = <ufunc 'ones_like'>
|
|||
pi = 3.14159265359
|
|||
power = <ufunc 'power'>
|
|||
r_ = <numpy.lib.index_tricks.r_class object at 0x85f788c>
|
|||
reciprocal = <ufunc 'reciprocal'>
|
|||
remainder = <ufunc 'remainder'>
|
|||
right_shift = <ufunc 'right_shift'>
|
|||
rint = <ufunc 'rint'>
|
|||
s_ = <numpy.lib.index_tricks._index_expression_class object at
|
|||
sctypeDict =
|
|||
sctypeNA =
|
|||
sctypes =
|
|||
sign = <ufunc 'sign'>
|
|||
signbit = <ufunc 'signbit'>
|
|||
sin = <ufunc 'sin'>
|
|||
sinh = <ufunc 'sinh'>
|
|||
sqrt = <ufunc 'sqrt'>
|
|||
square = <ufunc 'square'>
|
|||
subtract = <ufunc 'subtract'>
|
|||
tan = <ufunc 'tan'>
|
|||
tanh = <ufunc 'tanh'>
|
|||
true_divide = <ufunc 'true_divide'>
|
|||
typeDict =
|
|||
typeNA =
|
|||
typecodes =
|
|||
|
|||
|
Adds documentation to obj which is in module place. If doc is a string add it to obj as a docstring
This routine never raises an error. |
Return the length of a Python object interpreted as an array of at least 1 dimension. Blah, Blah. |
Return true if all elements of x are true: See Also:
|
Returns True if all components of a and b are equal subject to given tolerances. The relative error rtol must be positive and << 1.0 The absolute error atol usually comes into play for those elements of b that are very small or zero; it says how small a must be also. |
Perform a logical_and over the given axis. See Also:
|
Return the maximum of 'a' along dimension axis. Blah, Blah. |
Return the minimum of a along dimension axis. Blah, Blah. |
Return true if any elements of x are true. See Also:
|
|
Apply a function repeatedly over multiple axes, keeping the same shape for the resulting array. func is called as res = func(a, axis). The result is assumed to be either the same shape as a or have one less dimension. This call is repeated for each axis in the axes sequence. |
arange([start,] stop[, step,], dtype=None) For integer arguments, just like range() except it returns an array whose type can be specified by the keyword argument dtype. If dtype is not specified, the type of the result is deduced from the type of the arguments. For floating point arguments, the length of the result is ceil((stop - start)/step). This rule may result in the last element of the result being greater than stop. |
Returns array of indices of the maximum values of along the given axis. Parameters:
Returns: index_array : {integer_array} Examples >>> a = arange(6).reshape(2,3) >>> argmax(a) 5 >>> argmax(a,0) array([1, 1, 1]) >>> argmax(a,1) array([2, 2]) |
Return array of indices to the minimum values along the given axis. Parameters:
Returns: index_array : {integer_array} Examples >>> a = arange(6).reshape(2,3) >>> argmin(a) 0 >>> argmin(a,0) array([0, 0, 0]) >>> argmin(a,1) array([0, 0]) |
Returns array of indices that index 'a' in sorted order. 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:
Returns:
See Also:
Notes
|
|
Round a to the given number of decimals. The real and imaginary parts of complex numbers are rounded separately. The result of rounding a float is a float so the type must be cast if integers are desired. Nothing is done if the input is an integer array and the decimals parameter has a value >= 0. Parameters:
See Also:
Notes 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 when scaling by powers of ten. Examples >>> around([.5, 1.5, 2.5, 3.5, 4.5]) array([ 0., 2., 2., 4., 4.]) >>> around([1,2,3,11], decimals=1) array([ 1, 2, 3, 11]) >>> around([1,2,3,11], decimals=-1) array([ 0, 0, 0, 10]) |
Return an array from object with the specified date-type.
Inputs:
object - an array, any object exposing the array interface, any
object whose __array__ method returns an array, or any
(nested) sequence.
dtype - The desired data-type for the array. If not given, then
the type will be determined as the minimum type required
to hold the objects in the sequence. This argument can only
be used to 'upcast' the array. For downcasting, use the
.astype(t) method.
copy - If true, then force a copy. Otherwise a copy will only occur
if __array__ returns a copy, obj is a nested sequence, or
a copy is needed to satisfy any of the other requirements
order - Specify the order of the array. If order is 'C', then the
array will be in C-contiguous order (last-index varies the
fastest). If order is 'FORTRAN', then the returned array
will be in Fortran-contiguous order (first-index varies the
fastest). If order is None, then the returned array may
be in either C-, or Fortran-contiguous order or even
discontiguous.
subok - If True, then sub-classes will be passed-through, otherwise
the returned array will be forced to be a base-class array
ndmin - Specifies the minimum number of dimensions that the resulting
array should have. 1's will be pre-pended to the shape as
needed to meet this requirement.
|
Return a string representation of an array. Examples>>> x = N.array([1e-16,1,2,3]) >>> print array2string(x,precision=2,separator=',',suppress_small=True) [ 0., 1., 2., 3.] Parameters:
style : function |
Divide an array into a list of sub-arrays.
Description:
Divide ary into a list of sub-arrays along the
specified axis. If indices_or_sections is an integer,
ary is divided into that many equally sized arrays.
If it is impossible to make an equal split, each of the
leading arrays in the list have one additional member. If
indices_or_sections is a list of sorted integers, its
entries define the indexes where ary is split.
Arguments:
ary -- N-D array.
Array to be divided into sub-arrays.
indices_or_sections -- integer or 1D array.
If integer, defines the number of (close to) equal sized
sub-arrays. If it is a 1D array of sorted indices, it
defines the indexes at which ary is divided. Any empty
list results in a single sub-array equal to the original
array.
axis -- integer. default=0.
Specifies the axis along which to split ary.
Caveats:
Currently, the default for axis is 0. This
means a 2D array is divided into multiple groups
of rows. This seems like the appropriate default,
|
Returns a as an array. Unlike array(), no copy is performed if a is already an array. Subclasses are converted to base class ndarray. |
|
Force a sequence of arrays to each be at least 1D. Description: Force an array to be at least 1D. If an array is 0D, the array is converted to a single row of values. Otherwise, the array is unaltered. Arguments: *arys -- arrays to be converted to 1 or more dimensional array. Returns: input array converted to at least 1D array. |
Force a sequence of arrays to each be at least 2D. Description: Force an array to each be at least 2D. If the array is 0D or 1D, the array is converted to a single row of values. Otherwise, the array is unaltered. Arguments: arys -- arrays to be converted to 2 or more dimensional array. Returns: input array converted to at least 2D array. |
Force a sequence of arrays to each be at least 3D. Description: Force an array each be at least 3D. If the array is 0D or 1D, the array is converted to a single 1xNx1 array of values where N is the orginal length of the array. If the array is 2D, the array is converted to a single MxNx1 array of values where MxN is the orginal shape of the array. Otherwise, the array is unaltered. Arguments: arys -- arrays to be converted to 3 or more dimensional array. Returns: input array converted to at least 3D array. |
Average the array over the given axis. If the axis is None, average over all dimensions of the array. Equivalent to a.mean(axis) and to a.sum(axis) / size(a, axis)
where the weights must have a's shape or be 1D with length the size of a in the given axis. Integer weights are converted to Float. Not specifying weights is equivalent to specifying weights that are all 1. If 'returned' is True, return a tuple: the result and the sum of the weights or count of values. The shape of these two results will be the same. Raises ZeroDivisionError if appropriate. (The version in MA does not -- it returns masked values). |
Return the representation of a number in the given base. Base can't be larger than 36. |
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. |
Return the number of occurrences of each value in x. x must be a list of non-negative integers. The output, b[i], represents the number of times that i is found in x. If weights is specified, every occurrence of i at a position p contributes weights[p] instead of 1. See also: histogram, digitize, unique. |
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.
|
(low, high) are pointers to the end-points of an array low is the first byte high is just *past* the last byte If the array is not single-segment, then it may not actually use every byte between these bounds. The array provided must conform to the Python-side of the array interface |
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 Parameters:
Returns: merged_array : array See Also:
Examples >>> 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]) |
Limit the values of a to [a_min, a_max]. Equivalent to a[a < a_min] = a_min a[a > a_max] = a_max |
Stack 1D arrays as columns into a 2D array
Description:
Take a sequence of 1D arrays and stack them as columns
to make a single 2D array. All arrays in the sequence
must have the same first dimension. 2D arrays are
stacked as-is, just like with hstack. 1D arrays are turned
into 2D columns first.
Arguments:
tup -- sequence of 1D or 2D arrays. All arrays must have the same
first dimension.
Examples:
>>> import numpy
>>> a = array((1,2,3))
>>> b = array((2,3,4))
>>> numpy.column_stack((a,b))
array([[1, 2],
[2, 3],
[3, 4]])
|
Given a sequence of arrays as arguments, return the best inexact scalar type which is "most" common amongst them. The return type will always be a inexact scalar type, even if all the arrays are integer arrays. |
Return a where condition is true. Equivalent to a[condition]. |
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]) |
Estimate the covariance matrix. If m is a vector, return the variance. For matrices return the covariance matrix. If y is given it is treated as an additional (set of) variable(s). Normalization is by (N-1) where N is the number of observations (unbiased estimate). If bias is 1 then normalization is by N. If rowvar is non-zero (default), then each row is a variable with observations in the columns, otherwise each column is a variable and the observations are in the rows. |
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. |
Return the cumulative product of the elements along the given axis. Blah, Blah. |
Return the cumulative product over the given axis. Blah, Blah. |
Sum the array over the given axis. Blah, Blah. |
Return a new array with sub-arrays along an axis deleted. Return a new array with the sub-arrays (i.e. rows or columns) deleted along the given axis as specified by obj obj may be a slice_object (s_[3:5:2]) or an integer or an array of integers indicated which sub-arrays to remove. If axis is None, then ravel the array first. Example: >>> arr = [[3,4,5], ... [1,2,3], ... [6,7,8]] >>> delete(arr, 1, 1) array([[3, 5], [1, 3], [6, 8]]) >>> delete(arr, 1, 0) array([[3, 4, 5], [6, 7, 8]]) |
Return specified diagonals. 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 has more than two dimensions, 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:
Returns:
See Also:
Examples >>> a = arange(4).reshape(2,2) >>> a array([[0, 1], [2, 3]]) >>> a.diagonal() array([0, 3]) >>> a.diagonal(1) array([1])>>> 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]]) |
Return the index of the bin to which each value of x belongs. Each index i returned is such that bins[i-1] <= x < bins[i] if bins is monotonically increasing, or bins [i-1] > x >= bins[i] if bins is monotonically decreasing. Beyond the bounds of the bins 0 or len(bins) is returned as appropriate. |
Split ary into multiple sub-arrays along the 3rd axis (depth)
Description:
Split a single array into multiple sub arrays. The array is
divided into groups along the 3rd axis. If indices_or_sections is
an integer, ary is divided into that many equally sized sub arrays.
If it is impossible to make the sub-arrays equally sized, the
operation throws a ValueError exception. See array_split and
split for other options on indices_or_sections.
Arguments:
ary -- N-D array.
Array to be divided into sub-arrays.
indices_or_sections -- integer or 1D array.
If integer, defines the number of (close to) equal sized
sub-arrays. If it is a 1D array of sorted indices, it
defines the indexes at which ary is divided. Any empty
list results in a single sub-array equal to the original
array.
Returns:
sequence of sub-arrays. The returned arrays have the same
number of dimensions as the input array.
Caveats:
See vsplit caveats.
Related:
dstack, split, array_split, hsplit, vsplit.
Examples:
>>> a = array([[[1,2,3,4],[1,2,3,4]]])
>>> dsplit(a,2)
[array([[[1, 2],
[1, 2]]]), array([[[3, 4],
[3, 4]]])]
|
Stack arrays in sequence depth wise (along third dimension)
Description:
Take a sequence of arrays and stack them along the third axis.
All arrays in the sequence must have the same shape along all
but the third axis. This is a simple way to stack 2D arrays
(images) into a single 3D array for processing.
dstack will rebuild arrays divided by dsplit.
Arguments:
tup -- sequence of arrays. All arrays must have the same
shape.
Examples:
>>> import numpy
>>> a = array((1,2,3))
>>> b = array((2,3,4))
>>> numpy.dstack((a,b))
array([[[1, 2],
[2, 3],
[3, 4]]])
>>> a = array([[1],[2],[3]])
>>> b = array([[2],[3],[4]])
>>> numpy.dstack((a,b))
array([[[1, 2]],
<BLANKLINE>
[[2, 3]],
<BLANKLINE>
[[3, 4]]])
|
The differences between consecutive elements of an array, possibly with prefixed and/or appended values. :Parameters:
|
empty((d1,...,dn),dtype=float,order='C') Return a new array of shape (d1,...,dn) and given type with all its entries uninitialized. This can be faster than zeros. |
Return an empty (uninitialized) array of the shape and typecode of a. Note that this does NOT initialize the returned array. If you require your array to be initialized, you should use zeros_like(). |
Return the elements of ravel(arr) where ravel(condition) is True (in 1D). Equivalent to compress(ravel(condition), ravel(arr)). |
Return indicies that are not-zero in flattened version of a Equivalent to a.ravel().nonzero()[0] |
|
|
|
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.
|
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. |
|
|
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). |
Find the wrapper for the array with the highest priority. In case of ties, leftmost wins. If no wrapper is found, return None |
Return the directory in the package that contains the numpy/*.h header
files.
Extension modules that need to compile against numpy should use this
function to locate the appropriate include directory. Using distutils:
import numpy
Extension('extension_name', ...
include_dirs=[numpy.get_include()])
|
Return the directory in the package that contains the numpy/*.h header
files.
Extension modules that need to compile against numpy should use this
function to locate the appropriate include directory. Using distutils:
import numpy
Extension('extension_name', ...
include_dirs=[numpy.get_numarray_include()])
|
get_numpy_include is DEPRECATED in numpy: use get_include instead
Return the directory in the package that contains the numpy/*.h header
files.
Extension modules that need to compile against numpy should use this
function to locate the appropriate include directory. Using distutils:
import numpy
Extension('extension_name', ...
include_dirs=[numpy.get_include()])
|
See Also:
|
|
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". |
Calculate the gradient of an N-dimensional scalar function. Uses central differences on the interior and first differences on boundaries to give the same shape. Inputs:
Outputs: N arrays of the same shape as f giving the derivative of f with respect to each dimension. |
Compute the histogram from a set of data. Parameters:
Returns:
SeeAlso: histogramdd |
Compute the 2D histogram from samples x,y. :Parameters:
>>> x = random.randn(100,2) >>> hist2d, xedges, yedges = histogram2d(x, bins = (6, 7)):SeeAlso: histogramdd
|
Return the N-dimensional histogram of the sample. Parameters:
Returns:
SeeAlso: histogram Example >>> x = random.randn(100,3) >>> hist3d, edges = histogramdd(x, bins = (5, 6, 7)) |
Split ary into multiple columns of sub-arrays
Description:
Split a single array into multiple sub arrays. The array is
divided into groups of columns. If indices_or_sections is
an integer, ary is divided into that many equally sized sub arrays.
If it is impossible to make the sub-arrays equally sized, the
operation throws a ValueError exception. See array_split and
split for other options on indices_or_sections.
Arguments:
ary -- N-D array.
Array to be divided into sub-arrays.
indices_or_sections -- integer or 1D array.
If integer, defines the number of (close to) equal sized
sub-arrays. If it is a 1D array of sorted indices, it
defines the indexes at which ary is divided. Any empty
list results in a single sub-array equal to the original
array.
Returns:
sequence of sub-arrays. The returned arrays have the same
number of dimensions as the input array.
Related:
hstack, split, array_split, vsplit, dsplit.
Examples:
>>> import numpy
>>> a= array((1,2,3,4))
>>> numpy.hsplit(a,2)
[array([1, 2]), array([3, 4])]
>>> a = array([[1,2,3,4],[1,2,3,4]])
>>> hsplit(a,2)
[array([[1, 2],
[1, 2]]), array([[3, 4],
[3, 4]])]
|
Stack arrays in sequence horizontally (column wise)
Description:
Take a sequence of arrays and stack them horizontally
to make a single array. All arrays in the sequence
must have the same shape along all but the second axis.
hstack will rebuild arrays divided by hsplit.
Arguments:
tup -- sequence of arrays. All arrays must have the same
shape.
Examples:
>>> import numpy
>>> a = array((1,2,3))
>>> b = array((2,3,4))
>>> numpy.hstack((a,b))
array([1, 2, 3, 2, 3, 4])
>>> a = array([[1],[2],[3]])
>>> b = array([[2],[3],[4]])
>>> numpy.hstack((a,b))
array([[1, 2],
[2, 3],
[3, 4]])
|
Returns the identity 2-d array of shape n x n.
identity(n)[i,j] == 1 for all i == j
== 0 for all i != j
|
Return the imaginary part of val. Useful if val maybe a scalar or an array. |
Get help information for a function, class, or module.
Example:
>>> from numpy import *
>>> info(polyval) # doctest: +SKIP
polyval(p, x)
Evaluate the polymnomial p at x.
Description:
If p is of length N, this function returns the value:
p[0]*(x**N-1) + p[1]*(x**N-2) + ... + p[N-2]*x + p[N-1]
|
Return a new array with values inserted along the given axis before the given indices If axis is None, then ravel the array first. The obj argument can be an integer, a slice, or a sequence of integers. Example: >>> a = array([[1,2,3], ... [4,5,6], ... [7,8,9]]) >>> insert(a, [1,2], [[4],[5]], axis=0) array([[1, 2, 3], [4, 4, 4], [4, 5, 6], [5, 5, 5], [7, 8, 9]]) |
Return the value of a piecewise-linear function at each value in x. The piecewise-linear function, f, is defined by the known data-points fp=f(xp). The xp points must be sorted in increasing order but this is not checked. For values of x < xp[0] return the value given by left. If left is None, then return fp[0]. For values of x > xp[-1] return the value given by right. If right is None, then return fp[-1]. |
Intersection of 1D arrays with unique elements. Use unique1d() to generate arrays with only unique elements to use as inputs to this function. Alternatively, use intersect1d_nu() which will find the unique values for you. :Parameters: - `ar1` : array - `ar2` : array :Returns: - `intersection` : array :See also: numpy.lib.arraysetops has a number of other functions for performing set operations on arrays. |
Intersection of 1D arrays with any elements. The input arrays do not have unique elements like intersect1d() requires. :Parameters: - `ar1` : array - `ar2` : array :Returns: - `intersection` : array :See also: numpy.lib.arraysetops has a number of other functions for performing set operations on arrays. |
Return a boolean array where elements are True if that element is complex (has non-zero imaginary part). For scalars, return a boolean. |
Return True if x is a complex type or an array of complex numbers. Unlike iscomplex(x), complex(3.0) is considered a complex object. |
Return a boolean array y with y[i] True for x[i] = -Inf. If y is an array, the result replaces the contents of y. |
Return a boolean array y with y[i] True for x[i] = +Inf. If y is an array, the result replaces the contents of y. |
Return a boolean array where elements are True if that element is real (has zero imaginary part) For scalars, return a boolean. |
Return True if x is not a complex type. Unlike isreal(x), complex(3.0) is considered a complex object. |
Construct an open mesh from multiple sequences. This function takes n 1-d sequences and returns n outputs with n dimensions each such that the shape is 1 in all but one dimension and the dimension with the non-unit shape value cycles through all n dimensions. Using ix_() one can quickly construct index arrays that will index the cross product. a[ix_([1,3,7],[2,5,8])] returns the array a[1,2] a[1,5] a[1,8] a[3,2] a[3,5] a[3,8] a[7,2] a[7,5] a[7,8] |
kronecker product of a and b Kronecker product of two arrays is block array [[ a[ 0 ,0]*b, a[ 0 ,1]*b, ... , a[ 0 ,n-1]*b ], [ ... ... ], [ a[m-1,0]*b, a[m-1,1]*b, ... , a[m-1,n-1]*b ]] |
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
|
Return evenly spaced numbers. Return num evenly spaced samples from start to stop. If endpoint is True, the last sample is stop. If retstep is True then return (seq, step_value), where step_value used.
|
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
See scipy.loadmat to read and write matfiles.
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
x,y,z = load('somefile.dat', usecols=(3,5,7), unpack=True)
|
Returns the base 2 logarithm of x If y is an array, the result replaces the contents of y. |
Evenly spaced numbers on a logarithmic scale. Computes int(num) evenly spaced exponents from base**start to base**stop. If endpoint=True, then last number is base**stop |
|
Determine if two arrays can share memory The memory-bounds of a and b are computed. If they overlap then this function returns True. Otherwise, it returns False. A return of True does not necessarily mean that the two arrays share any element. It just means that they *might*. |
Compute the mean along the specified axis. Returns the average of the array elements. The average is taken over the flattened array by default, otherwise over the specified axis. The dtype returned for integer type arrays is float Parameters:
Returns:
See Also:
Notes The mean is the sum of the elements along the axis divided by the number of elements. Examples >>> a = array([[1,2],[3,4]]) >>> mean(a) 2.5 >>> mean(a,0) array([ 2., 3.]) >>> mean(a,1) array([ 1.5, 3.5]) |
For vectors x, y with lengths Nx=len(x) and Ny=len(y), return X, Y where X and Y are (Ny, Nx) shaped arrays with the elements of x and y repeated to fill the matrix EG,
|
Return a minimum data type character from typeset that handles all typechars given The returned type character must be the smallest size such that an array of the returned type can handle the data from an array of type t for each t in typechars (or if typechars is an array, then its dtype.char). If the typechars does not intersect with the typeset, then default is returned. If t in typechars is not a string then t=asarray(t).dtype.char is applied. |
Returns a copy of replacing NaN's with 0 and Infs with large numbers
The following mappings are applied:
NaN -> 0
Inf -> limits.double_max
-Inf -> limits.double_min
|
Return the number of dimensions of a. If a is not already an array, a conversion is attempted. Scalars are zero dimensional. Parameters:
Returns:
See Also:
Examples >>> ndim([[1,2,3],[4,5,6]]) 2 >>> ndim(array([[1,2,3],[4,5,6]])) 2 >>> ndim(1) 0 |
Return the indices of the elements of a which are not zero. Parameters: a : {array_like} Returns: tuple_of_arrays : {tuple} Examples >>> eye(3)[nonzero(eye(3))] array([ 1., 1., 1.]) >>> nonzero(eye(3)) (array([0, 1, 2]), array([0, 1, 2])) >>> eye(3)[nonzero(eye(3))] array([ 1., 1., 1.]) |
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. |
Return a piecewise-defined function. x is the domain
|
|
Return a sequence representing a polynomial given a sequence of roots. If the input is a matrix, return the characteristic polynomial. Example:>>> b = roots([1,3,1,5,6]) >>> poly(b) array([ 1., 3., 1., 5., 6.]) |
Least squares polynomial fit.
Required arguments
x -- vector of sample points
y -- vector or 2D array of values to fit
deg -- degree of the fitting polynomial
Keyword arguments
rcond -- relative condition number of the fit (default len(x)*eps)
full -- return full diagnostic output (default False)
Returns
full == False -- coefficients
full == True -- coefficients, residuals, rank, singular values, rcond.
Warns
RankWarning -- if rank is reduced and not full output
Do a best fit polynomial of degree 'deg' of 'x' to 'y'. Return value is a
vector of polynomial coefficients [pk ... p1 p0]. Eg, for n=2
p2*x0^2 + p1*x0 + p0 = y1
p2*x1^2 + p1*x1 + p0 = y1
p2*x2^2 + p1*x2 + p0 = y2
.....
p2*xk^2 + p1*xk + p0 = yk
Method: if X is a the Vandermonde Matrix computed from x (see
http://mathworld.wolfram.com/VandermondeMatrix.html), then the
polynomial least squares solution is given by the 'p' in
X*p = y
where X is a len(x) x N+1 matrix, p is a N+1 length vector, and y
is a len(x) x 1 vector
This equation can be solved as
p = (XT*X)^-1 * XT * y
where XT is the transpose of X and -1 denotes the inverse. However, this
method is susceptible to rounding errors and generally the singular value
decomposition is preferred and that is the method used here. The singular
value method takes a paramenter, 'rcond', which sets a limit on the
relative size of the smallest singular value to be used in solving the
equation. This may result in lowering the rank of the Vandermonde matrix,
in which case a RankWarning is issued. If polyfit issues a RankWarning, try
a fit of lower degree or replace x by x - x.mean(), both of which will
generally improve the condition number. The routine already normalizes the
vector x by its maximum absolute value to help in this regard. The rcond
parameter may also be set to a value smaller than its default, but this may
result in bad fits. The current default value of rcond is len(x)*eps, where
eps is the relative precision of the floating type being used, generally
around 1e-7 and 2e-16 for IEEE single and double precision respectively.
This value of rcond is fairly conservative but works pretty well when x -
x.mean() is used in place of x.
The warnings can be turned off by:
>>> import numpy
>>> import warnings
>>> warnings.simplefilter('ignore',numpy.RankWarning)
DISCLAIMER: Power series fits are full of pitfalls for the unwary once the
degree of the fit becomes large or the interval of sample points is badly
centered. The basic problem is that the powers x**n are generally a poor
basis for the functions on the sample interval with the result that the
Vandermonde matrix is ill conditioned and computation of the polynomial
values is sensitive to coefficient error. The quality of the resulting fit
should be checked against the data whenever the condition number is large,
as the quality of polynomial fits *can not* be taken for granted. If all
you want to do is draw a smooth curve through the y values and polyfit is
not doing the job, try centering the sample range or look into
scipy.interpolate, which includes some nice spline fitting functions that
may be of use.
For more info, see
http://mathworld.wolfram.com/LeastSquaresFittingPolynomial.html,
but note that the k's and n's in the superscripts and subscripts
on that page. The linear algebra is correct, however.
See also polyval
|
Return the mth analytical integral of the polynomial p. If k is None, then zero-valued constants of integration are used. otherwise, k should be a list of length m (or a scalar if m=1) to represent the constants of integration to use for each integration (starting with k[0]) |
Evaluate the polynomial p at x. If x is a polynomial then composition. Description: If p is of length N, this function returns the value: p[0]*(x**N-1) + p[1]*(x**N-2) + ... + p[N-2]*x + p[N-1] x can be a sequence and p(x) will be returned for all elements of x. or x can be another polynomial and the composite polynomial p(x) will be returned. Notice: This can produce inaccurate results for polynomials with significant variability. Use carefully. |
Return the product of the elements along the given axis. Blah, Blah. |
Product of the array elements over the given axis. Parameters:
Returns:
See Also:
Examples >>> product([1.,2.]) 2.0 >>> product([1.,2.], dtype=int32) 2 >>> product([[1.,2.],[3.,4.]]) 24.0 >>> product([[1.,2.],[3.,4.]], axis=1) array([ 2., 12.]) |
Return maximum - minimum along the the given dimension. Blah, Blah. |
Set 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. |
|
Return the number of dimensions of a. In old Numeric, rank was the term used for the number of dimensions. If a is not already an array, a conversion is attempted. Scalars are zero dimensional. Parameters:
Returns:
See Also:
Examples >>> rank([[1,2,3],[4,5,6]]) 2 >>> rank(array([[1,2,3],[4,5,6]])) 2 >>> rank(1) 0 |
Return a 1d array containing the elements of a. Returns the elements of a as a 1d array. The elements in the new array are taken in the order specified by the order keyword. The new array is a view of a if possible, otherwise it is a copy. Parameters:
Returns: 1d_array : {array} See Also:
Examples >>> x = array([[1,2,3],[4,5,6]]) >>> x array([[1, 2, 3], [4, 5, 6]]) >>> ravel(x) array([1, 2, 3, 4, 5, 6]) |
Return the real part of val. Useful if val maybe a scalar or an array. |
If a is a complex array, return it as a real array if the imaginary part is close enough to zero. "Close enough" is defined as tol*(machine epsilon of a's element type). |
Repeat elements of an array. Parameters:
Returns: repeated_array : array See Also:
Examples >>> 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]) |
Returns an array containing the data of a, but with a new shape. Parameters:
Returns:
See Also:
|
Return a new array with the specified shape. The original array's total size can be any size. The new array is filled with repeated copies of a. Note that a.resize(new_shape) will fill the array with 0's beyond current definition of a. Parameters:
Returns:
|
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) |
Return the roots of the polynomial coefficients in p. The values in the rank-1 array p are coefficients of a polynomial. If the length of p is n+1 then the polynomial is p[0] * x**n + p[1] * x**(n-1) + ... + p[n-1]*x + p[n] |
|
Round a to the given number of decimals. The real and imaginary parts of complex numbers are rounded separately. The result of rounding a float is a float so the type must be cast if integers are desired. Nothing is done if the input is an integer array and the decimals parameter has a value >= 0. Parameters:
Returns:
See Also:
Notes 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 when scaling by powers of ten. Examples >>> round_([.5, 1.5, 2.5, 3.5, 4.5]) array([ 0., 2., 2., 4., 4.]) >>> round_([1,2,3,11], decimals=1) array([ 1, 2, 3, 11]) >>> round_([1,2,3,11], decimals=-1) array([ 0, 0, 0, 10]) |
Stack arrays in sequence vertically (row wise)
Description:
Take a sequence of arrays and stack them vertically
to make a single array. All arrays in the sequence
must have the same shape along all but the first axis.
vstack will rebuild arrays divided by vsplit.
Arguments:
tup -- sequence of arrays. All arrays must have the same
shape.
Examples:
>>> import numpy
>>> a = array((1,2,3))
>>> b = array((2,3,4))
>>> numpy.vstack((a,b))
array([[1, 2, 3],
[2, 3, 4]])
>>> a = array([[1],[2],[3]])
>>> b = array([[2],[3],[4]])
>>> numpy.vstack((a,b))
array([[1],
[2],
[3],
[2],
[3],
[4]])
|
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 |
Return indices where keys in v should be inserted to maintain order. 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:
Returns:
See Also:
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. Examples >>> searchsorted([1,2,3,4,5],[6,4,0]) array([5, 3, 0]) |
Return an array composed of different elements in choicelist,
depending on the list of conditions.
:Parameters:
condlist : list of N boolean arrays of length M
The conditions C_0 through C_(N-1) which determine
from which vector the output elements are taken.
choicelist : list of N arrays of length M
Th vectors V_0 through V_(N-1), from which the output
elements are chosen.
:Returns:
output : 1-dimensional array of length M
The output at position m is the m-th element of the first
vector V_n for which C_n[m] is non-zero. Note that the
output depends on the order of conditions, since the
first satisfied condition is used.
Equivalent to:
output = []
for m in range(M):
output += [V[m] for V,C in zip(values,cond) if C[m]]
or [default]
|
|
|
|
Set difference of 1D arrays with unique elements.
Use unique1d() to generate arrays with only unique elements to use as inputs
to this function.
:Parameters:
- `ar1` : array
- `ar2` : array
:Returns:
- `difference` : array
The values in ar1 that are not in ar2.
:See also:
numpy.lib.arraysetops has a number of other functions for performing set
operations on arrays.
|
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'} |
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. |
Return a boolean array of shape of ar1 containing True where the elements
of ar1 are in ar2 and False otherwise.
Use unique1d() to generate arrays with only unique elements to use as inputs
to this function.
:Parameters:
- `ar1` : array
- `ar2` : array
:Returns:
- `mask` : bool array
The values ar1[mask] are in ar2.
:See also:
numpy.lib.arraysetops has a number of other functions for performing set
operations on arrays.
|
Set exclusive-or of 1D arrays with unique elements.
Use unique1d() to generate arrays with only unique elements to use as inputs
to this function.
:Parameters:
- `ar1` : array
- `ar2` : array
:Returns:
- `xor` : array
The values that are only in one, but not both, of the input arrays.
:See also:
numpy.lib.arraysetops has a number of other functions for performing set
operations on arrays.
|
Return the shape of a. Parameters:
Returns:
Examples >>> shape(eye(3)) (3, 3) >>> shape([[1,2]]) (1, 2) |
Return the number of elements along given axis. Parameters:
Returns:
See Also:
Examples >>> a = array([[1,2,3],[4,5,6]]) >>> size(a) 6 >>> size(a,1) 3 >>> size(a,0) 2 |
Perform a logical_or over the given axis. See Also:
|
Return copy of 'a' sorted along the given axis. Perform an inplace sort along the given axis using the algorithm specified by the kind keyword. Parameters:
Returns: sorted_array : array of same type as a See Also:
Notes
|
|
Divide an array into a list of sub-arrays.
Description:
Divide ary into a list of sub-arrays along the
specified axis. If indices_or_sections is an integer,
ary is divided into that many equally sized arrays.
If it is impossible to make an equal split, an error is
raised. This is the only way this function differs from
the array_split() function. If indices_or_sections is a
list of sorted integers, its entries define the indexes
where ary is split.
Arguments:
ary -- N-D array.
Array to be divided into sub-arrays.
indices_or_sections -- integer or 1D array.
If integer, defines the number of (close to) equal sized
sub-arrays. If it is a 1D array of sorted indices, it
defines the indexes at which ary is divided. Any empty
list results in a single sub-array equal to the original
array.
axis -- integer. default=0.
Specifies the axis along which to split ary.
Caveats:
Currently, the default for axis is 0. This
means a 2D array is divided into multiple groups
of rows. This seems like the appropriate default
|
Remove single-dimensional entries from the shape of a. Examples >>> x = array([[[1,1,1],[2,2,2],[3,3,3]]]) >>> x array([[[1, 1, 1], [2, 2, 2], [3, 3, 3]]]) >>> x.shape (1, 3, 3) >>> squeeze(x).shape (3, 3) |
Compute the standard deviation along the specified axis. 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:
Returns:
See Also:
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. Examples >>> a = array([[1,2],[3,4]]) >>> std(a) 1.1180339887498949 >>> std(a,0) array([ 1., 1.]) >>> std(a,1) array([ 0.5, 0.5]) |
Sum the array over the given axis. Parameters:
Returns:
See Also:
Examples >>> sum([0.5, 1.5]) 2.0 >>> sum([0.5, 1.5], dtype=N.int32) 1 >>> sum([[0, 1], [0, 5]]) 6 >>> sum([[0, 1], [0, 5]], axis=1) array([1, 5]) |
Return array a with axis1 and axis2 interchanged. Blah, Blah. |
Return an array formed from the elements of a 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:
Returns:
See Also:
|
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. |
Run Numpy module test suite with level and verbosity.
level:
None --- do nothing, return None
< 0 --- scan for tests of level=abs(level),
don't run them, return TestSuite-list
> 0 --- scan for tests of level, run them,
return TestRunner
> 10 --- run all tests (same as specifying all=True).
(backward compatibility).
verbosity:
>= 0 --- show information messages
> 1 --- show warnings on missing tests
all:
True --- run all test files (like self.testall())
False (default) --- only run test files associated with a module
sys_argv --- replacement of sys.argv[1:] during running
tests.
testcase_pattern --- run only tests that match given pattern.
It is assumed (when all=False) that package tests suite follows
the following convention: for each package module, there exists
file <packagepath>/tests/test_<modulename>.py that defines
TestCase classes (with names having prefix 'test_') with methods
(with names having prefixes 'check_' or 'bench_'); each of these
methods are called when running unit tests.
|
Repeat an array the number of times given in the integer tuple, reps.
If reps has length d, the result will have dimension of max(d, A.ndim).
If reps is scalar it is treated as a 1-tuple.
If A.ndim < d, A is promoted to be d-dimensional by prepending new axes.
So a shape (3,) array is promoted to (1,3) for 2-D replication,
or shape (1,1,3) for 3-D replication.
If this is not the desired behavior, promote A to d-dimensions manually
before calling this function.
If d < A.ndim, tup is promoted to A.ndim by pre-pending 1's to it. Thus
for an A.shape of (2,3,4,5), a tup of (2,2) is treated as (1,1,2,2)
Examples:
>>> a = array([0,1,2])
>>> tile(a,2)
array([0, 1, 2, 0, 1, 2])
>>> tile(a,(1,2))
array([[0, 1, 2, 0, 1, 2]])
>>> tile(a,(2,2))
array([[0, 1, 2, 0, 1, 2],
[0, 1, 2, 0, 1, 2]])
>>> tile(a,(2,1,2))
array([[[0, 1, 2, 0, 1, 2]],
<BLANKLINE>
[[0, 1, 2, 0, 1, 2]]])
See Also:
repeat
|
Return the sum along diagonals of the array. If a is 2-d, returns the sum along the diagonal of self with the given offset, i.e., the collection of elements of the form a[i,i+offset]. If a has more than two dimensions, then the axes specified by axis1 and axis2 are used to determine the 2-d subarray whose trace 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. Arrays of integer type are summed Parameters:
Returns:
Examples >>> trace(eye(3)) 3.0 >>> a = arange(8).reshape((2,2,2)) >>> trace(a) array([6, 8]) |
Return a view of the array with dimensions permuted. Permutes axis according to list axes. If axes is None (default) returns array with dimensions reversed. |
|
|
|
Union of 1D arrays with unique elements. Use unique1d() to generate arrays with only unique elements to use as inputs to this function. :Parameters: - `ar1` : array - `ar2` : array :Returns: - `union` : array :See also: numpy.lib.arraysetops has a number of other functions for performing set operations on arrays. |
Return sorted unique items from an array or sequence. Example: >>> unique([5,2,4,0,4,4,2,2,1]) array([0, 1, 2, 4, 5]) |
Find the unique elements of 1D array.
Most of the other array set operations operate on the unique arrays
generated by this function.
:Parameters:
- `ar1` : array
This array will be flattened if it is not already 1D.
- `return_index` : bool, optional
If True, also return the indices against ar1 that result in the unique
array.
:Returns:
- `unique` : array
The unique values.
- `unique_indices` : int array, optional
The indices of the unique values. Only provided if return_index is True.
:See also:
numpy.lib.arraysetops has a number of other functions for performing set
operations on arrays.
|
Convert a flat index into an index tuple for an array of given shape. e.g. for a 2x2 array, unravel_index(2,(2,2)) returns (1,0). Example usage: p = x.argmax() idx = unravel_index(p,x.shape) x[idx] == x.max() Note: x.flat[p] == x.max() Thus, it may be easier to use flattened indexing than to re-map the index to a tuple. |
X = vander(x,N=None) The Vandermonde matrix of vector x. The i-th column of X is the the i-th power of x. N is the maximum power to compute; if N is None it defaults to len(x). |
Compute the variance along the specified axis. Returns the variance of the array elements, a measure of the spread of a distribution. The variance is computed for the flattened array by default, otherwise over the specified axis. Parameters:
Returns:
See Also:
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. Examples >>> a = array([[1,2],[3,4]]) >>> var(a) 1.25 >>> var(a,0) array([ 1., 1.]) >>> var(a,1) array([ 0.25, 0.25]) |
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. |
Split ary into multiple rows of sub-arrays
Description:
Split a single array into multiple sub arrays. The array is
divided into groups of rows. If indices_or_sections is
an integer, ary is divided into that many equally sized sub arrays.
If it is impossible to make the sub-arrays equally sized, the
operation throws a ValueError exception. See array_split and
split for other options on indices_or_sections.
Arguments:
ary -- N-D array.
Array to be divided into sub-arrays.
indices_or_sections -- integer or 1D array.
If integer, defines the number of (close to) equal sized
sub-arrays. If it is a 1D array of sorted indices, it
defines the indexes at which ary is divided. Any empty
list results in a single sub-array equal to the original
array.
Returns:
sequence of sub-arrays. The returned arrays have the same
number of dimensions as the input array.
Caveats:
How should we handle 1D arrays here? I am currently raising
an error when I encounter them. Any better approach?
Should we reduce the returned array to their minium dimensions
by getting rid of any dimensions that are 1?
Related:
vstack, split, array_split, hsplit, dsplit.
Examples:
import numpy
>>> a = array([[1,2,3,4],
... [1,2,3,4]])
>>> numpy.vsplit(a,2)
[array([[1, 2, 3, 4]]), array([[1, 2, 3, 4]])]
|
Stack arrays in sequence vertically (row wise)
Description:
Take a sequence of arrays and stack them vertically
to make a single array. All arrays in the sequence
must have the same shape along all but the first axis.
vstack will rebuild arrays divided by vsplit.
Arguments:
tup -- sequence of arrays. All arrays must have the same
shape.
Examples:
>>> import numpy
>>> a = array((1,2,3))
>>> b = array((2,3,4))
>>> numpy.vstack((a,b))
array([[1, 2, 3],
[2, 3, 4]])
>>> a = array([[1],[2],[3]])
>>> b = array([[2],[3],[4]])
>>> numpy.vstack((a,b))
array([[1],
[2],
[3],
[2],
[3],
[4]])
|
where(condition, x, y) or where(condition)
Return elements from `x` or `y`, depending on `condition`.
*Parameters*:
condition : array of bool
When True, yield x, otherwise yield y.
x,y : 1-dimensional arrays
Values from which to choose.
*Notes*
This is equivalent to
[xv if c else yv for (c,xv,yv) in zip(condition,x,y)]
The result is shaped like `condition` and has elements of `x`
or `y` where `condition` is respectively True or False.
In the special case, where only `condition` is given, the
tuple condition.nonzero() is returned, instead.
*Examples*
>>> where([True,False,True],[1,2,3],[4,5,6])
array([1, 5, 3])
|
zeros((d1,...,dn),dtype=float,order='C') Return a new array of shape (d1,...,dn) and type typecode with all it's entries initialized to zero. |
Return an array of zeros of the shape and typecode of a. If you don't explicitly need the array to be zeroed, you should instead use empty_like(), which is faster as it only allocates memory. |
|
|||
ScalarType
|
cast
|
index_exp
|
nbytes
|
s_
|
sctypeDict
|
sctypeNA
|
sctypes
|
typeDict
|
typeNA
|
typecodes
|
| Trees | Indices | Help |
|---|
| Generated by Epydoc 3.0beta1 on Tue Jun 3 09:41:17 2008 | http://epydoc.sourceforge.net |