Note This page describes the numpy-specific API for accessing the contents of a numpy array from other C extensions. PEP 3118 ? The Revised Buffer Protocol introduces similar, standardized API to Python 2.6 and 3.0 for any extension module to use. Cython?s buffer array support uses the PEP 3118 API; see the Cython numpy tutorial. Cython provides a way to write code that supports the buffer protocol with Python versions older than 2.6 because it has a backward-compatible implementation utilizi

Window functions

Various windows bartlett(M) Return the Bartlett window. blackman(M) Return the Blackman window. hamming(M) Return the Hamming window. hanning(M) Return the Hanning window. kaiser(M, beta) Return the Kaiser window.


vectorize.__call__(*args, **kwargs) [source] Return arrays with the results of pyfunc broadcast (vectorized) over args and kwargs not in excluded.

Using the Convenience Classes

The convenience classes provided by the polynomial package are: Name Provides Polynomial Power series Chebyshev Chebyshev series Legendre Legendre series Laguerre Laguerre series Hermite Hermite series HermiteE HermiteE series The series in this context are finite sums of the corresponding polynomial basis functions multiplied by coefficients. For instance, a power series looks like and has coefficients . The Chebyshev series with the same coefficients looks like and more generally


Constants UFUNC_ERR_{HANDLER} {HANDLER} can be IGNORE, WARN, RAISE, or CALL UFUNC_{THING}_{ERR} {THING} can be MASK, SHIFT, or FPE, and {ERR} can be DIVIDEBYZERO, OVERFLOW, UNDERFLOW, and INVALID. PyUFunc_{VALUE} {VALUE} can be One (1), Zero (0), or None (-1) Macros NPY_LOOP_BEGIN_THREADS Used in universal function code to only release the Python GIL if loop->obj is not true (i.e. this is not an OBJECT array loop). Requires use of NPY_BEGIN_THREADS_DEF in variable decl

The numpy.ma module

Rationale Masked arrays are arrays that may have missing or invalid entries. The numpy.ma module provides a nearly work-alike replacement for numpy that supports data arrays with masks. What is a masked array? In many circumstances, datasets can be incomplete or tainted by the presence of invalid data. For example, a sensor may have failed to record a data, or recorded an invalid value. The numpy.ma module provides a convenient way to address this issue, by introducing masked arrays. A mask

The N-dimensional array (ndarray)

An ndarray is a (usually fixed-size) multidimensional container of items of the same type and size. The number of dimensions and items in an array is defined by its shape, which is a tuple of N positive integers that specify the sizes of each dimension. The type of items in the array is specified by a separate data-type object (dtype), one of which is associated with each ndarray. As with other container objects in Python, the contents of an ndarray can be accessed and modified by indexing or

Test Support (numpy.testing)

Common test support for all numpy test scripts. This single module should provide all the common functionality for numpy tests in a single location, so that test scripts can just import it and work right away. Asserts assert_almost_equal(actual, desired[, ...]) Raises an AssertionError if two items are not equal up to desired precision. assert_approx_equal(actual, desired[, ...]) Raises an AssertionError if two items are not equal up to significant digits. assert_array_almost_equal(x, y[,

String operations

This module provides a set of vectorized string operations for arrays of type numpy.string_ or numpy.unicode_. All of them are based on the string methods in the Python standard library. String operations add(x1, x2) Return element-wise string concatenation for two arrays of str or unicode. multiply(a, i) Return (a * i), that is string multiple concatenation, element-wise. mod(a, values) Return (a % i), that is pre-Python 2.6 string formatting (iterpolation), element-wise for a pair of arr


Order statistics amin(a[, axis, out, keepdims]) Return the minimum of an array or minimum along an axis. amax(a[, axis, out, keepdims]) Return the maximum of an array or maximum along an axis. nanmin(a[, axis, out, keepdims]) Return minimum of an array or minimum along an axis, ignoring any NaNs. nanmax(a[, axis, out, keepdims]) Return the maximum of an array or maximum along an axis, ignoring any NaNs. ptp(a[, axis, out]) Range of values (maximum - minimum) along an axis. percentile(a,