[Numpysvn] r8128  in trunk: doc/source/reference doc/source/user numpy numpy/core/code_generators numpy/doc
numpysvn@scip...
numpysvn@scip...
Wed Feb 17 17:55:17 CST 2010
Author: jarrod.millman
Date: 20100217 17:55:16 0600 (Wed, 17 Feb 2010)
New Revision: 8128
Modified:
trunk/doc/source/reference/arrays.classes.rst
trunk/doc/source/reference/arrays.dtypes.rst
trunk/doc/source/reference/arrays.indexing.rst
trunk/doc/source/reference/arrays.ndarray.rst
trunk/doc/source/reference/capi.coremath.rst
trunk/doc/source/reference/capi.typesandstructures.rst
trunk/doc/source/reference/capi.ufunc.rst
trunk/doc/source/reference/index.rst
trunk/doc/source/reference/internals.codeexplanations.rst
trunk/doc/source/reference/maskedarray.generic.rst
trunk/doc/source/reference/routines.arraycreation.rst
trunk/doc/source/reference/routines.rst
trunk/doc/source/user/basics.indexing.rst
trunk/doc/source/user/basics.rec.rst
trunk/doc/source/user/basics.rst
trunk/doc/source/user/basics.types.rst
trunk/doc/source/user/cinfo.beyondbasics.rst
trunk/doc/source/user/cinfo.pythonasglue.rst
trunk/doc/source/user/howtofind.rst
trunk/doc/source/user/install.rst
trunk/doc/source/user/misc.rst
trunk/doc/source/user/performance.rst
trunk/numpy/add_newdocs.py
trunk/numpy/core/code_generators/ufunc_docstrings.py
trunk/numpy/doc/constants.py
Log:
updated documentation from pydoc website (thanks to everyone who contributed!)
Modified: trunk/doc/source/reference/arrays.classes.rst
===================================================================
 trunk/doc/source/reference/arrays.classes.rst 20100217 23:53:04 UTC (rev 8127)
+++ trunk/doc/source/reference/arrays.classes.rst 20100217 23:55:16 UTC (rev 8128)
@@ 13,8 +13,8 @@
several tools for simplifying how your new object interacts with other
array objects, and so the choice may not be significant in the
end. One way to simplify the question is by asking yourself if the
object you are interested in can be replaced as a single array or does it
really require two or more arrays at its core.
+object you are interested in can be replaced as a single array or does
+it really require two or more arrays at its core.
Note that :func:`asarray` always returns the baseclass ndarray. If
you are confident that your use of the array object can handle any
@@ 42,10 +42,10 @@
This method is called whenever the system internally allocates a
new array from *obj*, where *obj* is a subclass (subtype) of the
 :class:`ndarray`. It can be used to change attributes of *self* after
 construction (so as to ensure a 2d matrix for example), or to
 update metainformation from the "parent." Subclasses inherit a
 default implementation of this method that does nothing.
+ :class:`ndarray`. It can be used to change attributes of *self*
+ after construction (so as to ensure a 2d matrix for example), or
+ to update metainformation from the "parent." Subclasses inherit
+ a default implementation of this method that does nothing.
.. function:: __array_prepare__(array, context=None)
@@ 66,10 +66,10 @@
the output object if one was specified. The ufunccomputed array
is passed in and whatever is returned is passed to the user.
Subclasses inherit a default implementation of this method, which
 transforms the array into a new instance of the object's class. Subclasses
 may opt to use this method to transform the output array into an
 instance of the subclass and update metadata before returning the
 array to the user.
+ transforms the array into a new instance of the object's class.
+ Subclasses may opt to use this method to transform the output array
+ into an instance of the subclass and update metadata before
+ returning the array to the user.
.. data:: __array_priority__
@@ 96,21 +96,21 @@
unexpected results when you use matrices but expect them to act like
arrays:
1. Matrix objects can be created using a string notation to allow Matlab
 style syntax where spaces separate columns and semicolons (';')
 separate rows.
+1. Matrix objects can be created using a string notation to allow
+ Matlabstyle syntax where spaces separate columns and semicolons
+ (';') separate rows.
2. Matrix objects are always twodimensional. This has farreaching
 implications, in that m.ravel() is still twodimensional (with a 1 in
 the first dimension) and item selection returns twodimensional
+ implications, in that m.ravel() is still twodimensional (with a 1
+ in the first dimension) and item selection returns twodimensional
objects so that sequence behavior is fundamentally different than
arrays.
3. Matrix objects override multiplication to be
matrixmultiplication. **Make sure you understand this for
functions that you may want to receive matrices. Especially in
 light of the fact that asanyarray(m) returns a matrix when m is a
 matrix.**
+ light of the fact that asanyarray(m) returns a matrix when m is
+ a matrix.**
4. Matrix objects override power to be matrix raised to a power. The
same warning about using power inside a function that uses
@@ 119,8 +119,8 @@
5. The default __array_priority\__ of matrix objects is 10.0, and
therefore mixed operations with ndarrays always produce matrices.
6. Matrices have special attributes which make calculations easier. These
 are
+6. Matrices have special attributes which make calculations easier.
+ These are
.. autosummary::
:toctree: generated/
@@ 132,11 +132,12 @@
.. warning::
 Matrix objects override multiplication, '*', and power, '**', to be
 matrixmultiplication and matrix power, respectively. If your
 subroutine can accept subclasses and you do not convert to baseclass
 arrays, then you must use the ufuncs multiply and power to be sure
 that you are performing the correct operation for all inputs.
+ Matrix objects override multiplication, '*', and power, '**', to
+ be matrixmultiplication and matrix power, respectively. If your
+ subroutine can accept subclasses and you do not convert to base
+ class arrays, then you must use the ufuncs multiply and power to
+ be sure that you are performing the correct operation for all
+ inputs.
The matrix class is a Python subclass of the ndarray and can be used
as a reference for how to construct your own subclass of the ndarray.
@@ 194,10 +195,10 @@
.. note::
 Memorymapped arrays use the the Python memorymap object which (prior
 to Python 2.5) does not allow files to be larger than a certain size
 depending on the platform. This size is always < 2GB even on 64bit
 systems.
+ Memorymapped arrays use the the Python memorymap object which
+ (prior to Python 2.5) does not allow files to be larger than a
+ certain size depending on the platform. This size is always
+ < 2GB even on 64bit systems.
.. autosummary::
:toctree: generated/
@@ 228,10 +229,11 @@
single: character arrays
.. note::
 The chararray module exists for backwards compatibility with
 Numarray, it is not recommended for new development. If one needs
 arrays of strings, use arrays of `dtype` `object_`, `str` or
 `unicode`.
+ The `chararray` class exists for backwards compatibility with
+ Numarray, it is not recommended for new development. Starting from numpy
+ 1.4, if one needs arrays of strings, it is recommended to use arrays of
+ `dtype` `object_`, `string_` or `unicode_`, and use the free functions
+ in the `numpy.char` module for fast vectorized string operations.
These are enhanced arrays of either :class:`string_` type or
:class:`unicode_` type. These arrays inherit from the
@@ 240,8 +242,8 @@
operations are not available on the standard :class:`ndarray` of
character type. In addition, the :class:`chararray` has all of the
standard :class:`string <str>` (and :class:`unicode`) methods,
executing them on an elementbyelement basis. Perhaps the easiest way
to create a chararray is to use :meth:`self.view(chararray)
+executing them on an elementbyelement basis. Perhaps the easiest
+way to create a chararray is to use :meth:`self.view(chararray)
<ndarray.view>` where *self* is an ndarray of str or unicode
datatype. However, a chararray can also be created using the
:meth:`numpy.chararray` constructor, or via the
@@ 255,8 +257,8 @@
Another difference with the standard ndarray of str datatype is
that the chararray inherits the feature introduced by Numarray that
whitespace at the end of any element in the array will be ignored on
item retrieval and comparison operations.
+whitespace at the end of any element in the array will be ignored
+on item retrieval and comparison operations.
.. _arrays.classes.rec:
@@ 341,7 +343,8 @@
for i in arr.shape[0]:
val = arr[i]
This default iterator selects a subarray of dimension :math:`N1` from the array. This can be a useful construct for defining recursive
+This default iterator selects a subarray of dimension :math:`N1`
+from the array. This can be a useful construct for defining recursive
algorithms. To loop over the entire array requires :math:`N` forloops.
>>> a = arange(24).reshape(3,2,4)+10
Modified: trunk/doc/source/reference/arrays.dtypes.rst
===================================================================
 trunk/doc/source/reference/arrays.dtypes.rst 20100217 23:53:04 UTC (rev 8127)
+++ trunk/doc/source/reference/arrays.dtypes.rst 20100217 23:55:16 UTC (rev 8128)
@@ 148,8 +148,8 @@
.. admonition:: Example
 >>> dt = np.dtype(np.int32) # 32bit integer
 >>> dt = np.dtype(np.complex128) # 128bit complex floatingpoint number
+ >>> dt = np.dtype(np.int32) # 32bit integer
+ >>> dt = np.dtype(np.complex128) # 128bit complex floatingpoint number
Generic types
@@ 305,9 +305,9 @@
.. admonition:: Example
 >>> dt = np.dtype((np.int32, (2,2))) # 2 x 2 integer subarray
 >>> dt = np.dtype(('S10', 1)) # 10character string
 >>> dt = np.dtype(('i4, (2,3)f8, f4', (2,3))) # 2 x 3 record subarray
+ >>> dt = np.dtype((np.int32, (2,2))) # 2 x 2 integer subarray
+ >>> dt = np.dtype(('S10', 1)) # 10character string
+ >>> dt = np.dtype(('i4, (2,3)f8, f4', (2,3))) # 2 x 3 record subarray
``(base_dtype, new_dtype)``
@@ 321,7 +321,7 @@
32bit integer, whose first two bytes are interpreted as an integer
via field ``real``, and the following two bytes via field ``imag``.
 >>> dt = np.dtype((np.int32, {'real': (np.int16, 0), 'imag': (np.int16, 2)})
+ >>> dt = np.dtype((np.int32,{'real':(np.int16, 0),'imag':(np.int16, 2)})
32bit integer, which is interpreted as consisting of a subarray
of shape ``(4,)`` containing 8bit integers:
@@ 333,8 +333,6 @@
>>> dt = np.dtype(('i4', [('r','u1'),('g','u1'),('b','u1'),('a','u1')]))
.. note:: XXX: does the secondtolast example above make sense?

.. index::
triple: dtype; construction; from list
@@ 428,7 +426,8 @@
byte position 0), ``col2`` (32bit float at byte position 10),
and ``col3`` (integers at byte position 14):
 >>> dt = np.dtype({'col1': ('S10', 0), 'col2': (float32, 10), 'col3': (int, 14)})
+ >>> dt = np.dtype({'col1': ('S10', 0), 'col2': (float32, 10),
+ 'col3': (int, 14)})
:class:`dtype`
Modified: trunk/doc/source/reference/arrays.indexing.rst
===================================================================
 trunk/doc/source/reference/arrays.indexing.rst 20100217 23:53:04 UTC (rev 8127)
+++ trunk/doc/source/reference/arrays.indexing.rst 20100217 23:55:16 UTC (rev 8128)
@@ 318,13 +318,6 @@
Also recognize that ``x[[1,2,3]]`` will trigger advanced indexing,
whereas ``x[[1,2,slice(None)]]`` will trigger basic slicing.
.. note::

 XXX: this section may need some tuning...
 Also the above warning needs explanation as the last part is at odds
 with the definition of basic indexing.


.. _arrays.indexing.rec:
Record Access
Modified: trunk/doc/source/reference/arrays.ndarray.rst
===================================================================
 trunk/doc/source/reference/arrays.ndarray.rst 20100217 23:53:04 UTC (rev 8127)
+++ trunk/doc/source/reference/arrays.ndarray.rst 20100217 23:55:16 UTC (rev 8128)
@@ 9,9 +9,9 @@
An :class:`ndarray` is a (usually fixedsize) multidimensional
container of items of the same type and size. The number of dimensions
and items in an array is defined by its :attr:`shape <ndarray.shape>`,
which is a :class:`tuple` of *N* positive integers that specify the sizes of
each dimension. The type of items in the array is specified by a
separate :ref:`datatype object (dtype) <arrays.dtypes>`, one of which
+which is a :class:`tuple` of *N* positive integers that specify the
+sizes of each dimension. The type of items in the array is specified by
+a separate :ref:`datatype object (dtype) <arrays.dtypes>`, one of which
is associated with each ndarray.
As with other container objects in Python, the contents of an
@@ 32,7 +32,8 @@
.. admonition:: Example
 A 2dimensional array of size 2 x 3, composed of 4byte integer elements:
+ A 2dimensional array of size 2 x 3, composed of 4byte integer
+ elements:
>>> x = np.array([[1, 2, 3], [4, 5, 6]], np.int32)
>>> type(x)
@@ 44,10 +45,11 @@
The array can be indexed using Python containerlike syntax:
 >>> x[1,2] # i.e., the element of x in the *second* row, *third* column
 6
+ >>> x[1,2] # i.e., the element of x in the *second* row, *third*
+ column, namely, 6.
 For example :ref:`slicing <arrays.indexing>` can produce views of the array:
+ For example :ref:`slicing <arrays.indexing>` can produce views of
+ the array:
>>> y = x[:,1]
>>> y
@@ 96,14 +98,15 @@
the bytes are interpreted is defined by the :ref:`datatype object
<arrays.dtypes>` associated with the array.
.. index:: Corder, Fortranorder, rowmajor, columnmajor, stride, offset
+.. index:: Corder, Fortranorder, rowmajor, columnmajor, stride,
+ offset
A segment of memory is inherently 1dimensional, and there are many
different schemes for arranging the items of an *N*dimensional array in
a 1dimensional block. Numpy is flexible, and :class:`ndarray` objects
can accommodate any *strided indexing scheme*. In a strided scheme,
the Ndimensional index :math:`(n_0, n_1, ..., n_{N1})` corresponds
to the offset (in bytes)
+different schemes for arranging the items of an *N*dimensional array
+in a 1dimensional block. Numpy is flexible, and :class:`ndarray`
+objects can accommodate any *strided indexing scheme*. In a strided
+scheme, the Ndimensional index :math:`(n_0, n_1, ..., n_{N1})`
+corresponds to the offset (in bytes):
.. math:: n_{\mathrm{offset}} = \sum_{k=0}^{N1} s_k n_k
@@ 116,7 +119,8 @@
.. math::
 s_k^{\mathrm{column}} = \prod_{j=0}^{k1} d_j , \quad s_k^{\mathrm{row}} = \prod_{j=k+1}^{N1} d_j .
+ s_k^{\mathrm{column}} = \prod_{j=0}^{k1} d_j ,
+ \quad s_k^{\mathrm{row}} = \prod_{j=k+1}^{N1} d_j .
.. index:: singlesegment, contiguous, noncontiguous
@@ 172,8 +176,6 @@
ndarray.nbytes
ndarray.base
.. note:: XXX: update and check these docstrings.

Data type

@@ 187,8 +189,6 @@
ndarray.dtype
.. note:: XXX: update the dtype attribute docstring: setting etc.

Other attributes

@@ 223,9 +223,6 @@
ndarray.ctypes
.. note:: XXX: update and check these docstrings.


.. _array.ndarray.methods:
Array methods
@@ 241,11 +238,12 @@
:func:`argmin`, :func:`argsort`, :func:`choose`, :func:`clip`,
:func:`compress`, :func:`copy`, :func:`cumprod`, :func:`cumsum`,
:func:`diagonal`, :func:`imag`, :func:`max <amax>`, :func:`mean`,
:func:`min <amin>`, :func:`nonzero`, :func:`prod`, :func:`ptp`, :func:`put`,
:func:`ravel`, :func:`real`, :func:`repeat`, :func:`reshape`,
:func:`round <around>`, :func:`searchsorted`, :func:`sort`, :func:`squeeze`,
:func:`std`, :func:`sum`, :func:`swapaxes`, :func:`take`,
:func:`trace`, :func:`transpose`, :func:`var`.
+:func:`min <amin>`, :func:`nonzero`, :func:`prod`, :func:`ptp`,
+:func:`put`, :func:`ravel`, :func:`real`, :func:`repeat`,
+:func:`reshape`, :func:`round <around>`, :func:`searchsorted`,
+:func:`sort`, :func:`squeeze`, :func:`std`, :func:`sum`,
+:func:`swapaxes`, :func:`take`, :func:`trace`, :func:`transpose`,
+:func:`var`.
Array conversion

@@ 268,8 +266,6 @@
ndarray.setflags
ndarray.fill
.. note:: XXX: update and check these docstrings.

Shape manipulation

@@ 323,8 +319,8 @@
float32, float64, etc., whereas a 0dimensional array is an ndarray
instance containing precisely one array scalar.)
 If *axis* is an integer, then the operation is done over the given axis
 (for each 1D subarray that can be created along the given axis).
+ If *axis* is an integer, then the operation is done over the given
+ axis (for each 1D subarray that can be created along the given axis).
.. admonition:: Example of the *axis* argument
@@ 393,9 +389,6 @@
Arithmetic and comparison operations
====================================
.. note:: XXX: write all attributes explicitly here instead of relying on
 the auto\* stuff?

.. index:: comparison, arithmetic, operation, operator
Arithmetic and comparison operations on :class:`ndarrays <ndarray>`
@@ 435,9 +428,9 @@
:meth:`ndarray.__nonzero__`, which raises an error if the number of
elements in the the array is larger than 1, because the truth value
of such arrays is ambiguous. Use :meth:`.any() <ndarray.any>` and
 :meth:`.all() <ndarray.all>` instead to be clear about what is meant in
 such cases. (If the number of elements is 0, the array evaluates to
 ``False``.)
+ :meth:`.all() <ndarray.all>` instead to be clear about what is meant
+ in such cases. (If the number of elements is 0, the array evaluates
+ to ``False``.)
Unary operations:
Modified: trunk/doc/source/reference/capi.coremath.rst
===================================================================
 trunk/doc/source/reference/capi.coremath.rst 20100217 23:53:04 UTC (rev 8127)
+++ trunk/doc/source/reference/capi.coremath.rst 20100217 23:55:16 UTC (rev 8128)
@@ 125,7 +125,8 @@
.. cvar:: NPY_EULER
 The Euler constant (:math:`\lim_{n\rightarrow \infty}{\sum_{k=1}^n{\frac{1}{k}}  \ln n}`)
+ The Euler constant
+ :math:`\lim_{n\rightarrow\infty}({\sum_{k=1}^n{\frac{1}{k}}\ln n})`
Lowlevel floating point manipulation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Modified: trunk/doc/source/reference/capi.typesandstructures.rst
===================================================================
 trunk/doc/source/reference/capi.typesandstructures.rst 20100217 23:53:04 UTC (rev 8127)
+++ trunk/doc/source/reference/capi.typesandstructures.rst 20100217 23:55:16 UTC (rev 8128)
@@ 416,7 +416,8 @@
functions can (and must) deal with misbehaved arrays. The other
functions require behaved memory segments.
 .. cmember:: void cast(void *from, void *to, npy_intp n, void *fromarr, void *toarr)
+ .. cmember:: void cast(void *from, void *to, npy_intp n, void *fromarr,
+ void *toarr)
An array of function pointers to cast from the current type to
all of the other builtin types. Each function casts a
@@ 442,7 +443,8 @@
a zero is returned, otherwise, a negative one is returned (and
a Python error set).
 .. cmember:: void copyswapn(void *dest, npy_intp dstride, void *src, npy_intp sstride, npy_intp n, int swap, void *arr)
+ .. cmember:: void copyswapn(void *dest, npy_intp dstride, void *src,
+ npy_intp sstride, npy_intp n, int swap, void *arr)
.. cmember:: void copyswap(void *dest, void *src, int swap, void *arr)
@@ 468,7 +470,8 @@
``d1`` < * ``d2``. The array object arr is used to retrieve
itemsize and field information for flexible arrays.
 .. cmember:: int argmax(void* data, npy_intp n, npy_intp* max_ind, void* arr)
+ .. cmember:: int argmax(void* data, npy_intp n, npy_intp* max_ind,
+ void* arr)
A pointer to a function that retrieves the index of the
largest of ``n`` elements in ``arr`` beginning at the element
@@ 477,7 +480,8 @@
always 0. The index of the largest element is returned in
``max_ind``.
 .. cmember:: void dotfunc(void* ip1, npy_intp is1, void* ip2, npy_intp is2, void* op, npy_intp n, void* arr)
+ .. cmember:: void dotfunc(void* ip1, npy_intp is1, void* ip2, npy_intp is2,
+ void* op, npy_intp n, void* arr)
A pointer to a function that multiplies two ``n`` length
sequences together, adds them, and places the result in
@@ 527,7 +531,8 @@
computed by repeatedly adding this computed delta. The data
buffer must be wellbehaved.
 .. cmember:: void fillwithscalar(void* buffer, npy_intp length, void* value, void* arr)
+ .. cmember:: void fillwithscalar(void* buffer, npy_intp length,
+ void* value, void* arr)
A pointer to a function that fills a contiguous ``buffer`` of
the given ``length`` with a single scalar ``value`` whose
@@ 542,7 +547,8 @@
:cdata:`PyArray_MERGESORT` are defined). These sorts are done
inplace assuming contiguous and aligned data.
 .. cmember:: int argsort(void* start, npy_intp* result, npy_intp length, void \*arr)
+ .. cmember:: int argsort(void* start, npy_intp* result, npy_intp length,
+ void \*arr)
An array of function pointers to sorting algorithms for this
data type. The same sorting algorithms as for sort are
@@ 666,11 +672,12 @@
.. cmember:: int PyUFuncObject.identity
 Either :cdata:`PyUFunc_One`, :cdata:`PyUFunc_Zero`, or :cdata:`PyUFunc_None`
 to indicate the identity for this operation. It is only used
 for a reducelike call on an empty array.
+ Either :cdata:`PyUFunc_One`, :cdata:`PyUFunc_Zero`, or
+ :cdata:`PyUFunc_None` to indicate the identity for this operation.
+ It is only used for a reducelike call on an empty array.
 .. cmember:: void PyUFuncObject.functions(char** args, npy_intp* dims, npy_intp* steps, void* extradata)
+ .. cmember:: void PyUFuncObject.functions(char** args, npy_intp* dims,
+ npy_intp* steps, void* extradata)
An array of function pointers  one for each data type
supported by the ufunc. This is the vector loop that is called
@@ 764,8 +771,8 @@
.. ctype:: PyArrayIterObject
The Cstructure corresponding to an object of :cdata:`PyArrayIter_Type` is
 the :ctype:`PyArrayIterObject`. The :ctype:`PyArrayIterObject` is used to keep
 track of a pointer into an Ndimensional array. It contains associated
+ the :ctype:`PyArrayIterObject`. The :ctype:`PyArrayIterObject` is used to
+ keep track of a pointer into an Ndimensional array. It contains associated
information used to quickly march through the array. The pointer can
be adjusted in three basic ways: 1) advance to the "next" position in
the array in a Cstyle contiguous fashion, 2) advance to an arbitrary
@@ 928,8 +935,9 @@
.. ctype:: PyArrayNeighborhoodIterObject
 The Cstructure corresponding to an object of :cdata:`PyArrayNeighborhoodIter_Type` is
 the :ctype:`PyArrayNeighborhoodIterObject`.
+ The Cstructure corresponding to an object of
+ :cdata:`PyArrayNeighborhoodIter_Type` is the
+ :ctype:`PyArrayNeighborhoodIterObject`.
PyArrayFlags_Type

@@ 1183,4 +1191,3 @@
``arrayobject.h`` header. This type is not exposed to Python and
could be replaced with a Cstructure. As a Python type it takes
advantage of reference counted memory management.

Modified: trunk/doc/source/reference/capi.ufunc.rst
===================================================================
 trunk/doc/source/reference/capi.ufunc.rst 20100217 23:53:04 UTC (rev 8127)
+++ trunk/doc/source/reference/capi.ufunc.rst 20100217 23:55:16 UTC (rev 8128)
@@ 63,7 +63,9 @@
Functions

.. cfunction:: PyObject* PyUFunc_FromFuncAndData(PyUFuncGenericFunction* func, void** data, char* types, int ntypes, int nin, int nout, int identity, char* name, char* doc, int check_return)
+.. cfunction:: PyObject* PyUFunc_FromFuncAndData(PyUFuncGenericFunction* func,
+ void** data, char* types, int ntypes, int nin, int nout, int identity,
+ char* name, char* doc, int check_return)
Create a new broadcasting universal function from required variables.
Each ufunc builds around the notion of an elementbyelement
@@ 102,9 +104,6 @@
:param nout:
The number of outputs
 :param identity:
 XXX: Undocumented

:param name:
The name for the ufunc. Specifying a name of 'add' or
'multiply' enables a special behavior for integertyped
@@ 127,7 +126,8 @@
structure and it does get set with this value when the ufunc
object is created.
.. cfunction:: int PyUFunc_RegisterLoopForType(PyUFuncObject* ufunc, int usertype, PyUFuncGenericFunction function, int* arg_types, void* data)
+.. cfunction:: int PyUFunc_RegisterLoopForType(PyUFuncObject* ufunc,
+ int usertype, PyUFuncGenericFunction function, int* arg_types, void* data)
This function allows the user to register a 1d loop with an
already created ufunc to be used whenever the ufunc is called
@@ 140,7 +140,9 @@
in as *arg_types* which must be a pointer to memory at least as
large as ufunc>nargs.
.. cfunction:: int PyUFunc_ReplaceLoopBySignature(PyUFuncObject* ufunc, PyUFuncGenericFunction newfunc, int* signature, PyUFuncGenericFunction* oldfunc)
+.. cfunction:: int PyUFunc_ReplaceLoopBySignature(PyUFuncObject* ufunc,
+ PyUFuncGenericFunction newfunc, int* signature,
+ PyUFuncGenericFunction* oldfunc)
Replace a 1d loop matching the given *signature* in the
alreadycreated *ufunc* with the new 1d loop newfunc. Return the
@@ 150,7 +152,8 @@
signature is an array of datatype numbers indicating the inputs
followed by the outputs assumed by the 1d loop.
.. cfunction:: int PyUFunc_GenericFunction(PyUFuncObject* self, PyObject* args, PyArrayObject** mps)
+.. cfunction:: int PyUFunc_GenericFunction(PyUFuncObject* self,
+ PyObject* args, PyArrayObject** mps)
A generic ufunc call. The ufunc is passed in as *self*, the
arguments to the ufunc as *args*. The *mps* argument is an array
@@ 179,7 +182,8 @@
Clear the IEEE error flags.
.. cfunction:: void PyUFunc_GetPyValues(char* name, int* bufsize, int* errmask, PyObject** errobj)
+.. cfunction:: void PyUFunc_GetPyValues(char* name, int* bufsize,
+ int* errmask, PyObject** errobj)
Get the Python values used for ufunc processing from the
threadlocal storage area unless the defaults have been set in
@@ 206,21 +210,29 @@
functions stored in the functions member of the PyUFuncObject
structure.
.. cfunction:: void PyUFunc_f_f_As_d_d(char** args, npy_intp* dimensions, npy_intp* steps, void* func)
+.. cfunction:: void PyUFunc_f_f_As_d_d(char** args, npy_intp* dimensions,
+ npy_intp* steps, void* func)
.. cfunction:: void PyUFunc_d_d(char** args, npy_intp* dimensions, npy_intp* steps, void* func)
+.. cfunction:: void PyUFunc_d_d(char** args, npy_intp* dimensions,
+ npy_intp* steps, void* func)
.. cfunction:: void PyUFunc_f_f(char** args, npy_intp* dimensions, npy_intp* steps, void* func)
+.. cfunction:: void PyUFunc_f_f(char** args, npy_intp* dimensions,
+ npy_intp* steps, void* func)
.. cfunction:: void PyUFunc_g_g(char** args, npy_intp* dimensions, npy_intp* steps, void* func)
+.. cfunction:: void PyUFunc_g_g(char** args, npy_intp* dimensions,
+ npy_intp* steps, void* func)
.. cfunction:: void PyUFunc_F_F_As_D_D(char** args, npy_intp* dimensions, npy_intp* steps, void* func)
+.. cfunction:: void PyUFunc_F_F_As_D_D(char** args, npy_intp* dimensions,
+ npy_intp* steps, void* func)
.. cfunction:: void PyUFunc_F_F(char** args, npy_intp* dimensions, npy_intp* steps, void* func)
+.. cfunction:: void PyUFunc_F_F(char** args, npy_intp* dimensions,
+ npy_intp* steps, void* func)
.. cfunction:: void PyUFunc_D_D(char** args, npy_intp* dimensions, npy_intp* steps, void* func)
+.. cfunction:: void PyUFunc_D_D(char** args, npy_intp* dimensions,
+ npy_intp* steps, void* func)
.. cfunction:: void PyUFunc_G_G(char** args, npy_intp* dimensions, npy_intp* steps, void* func)
+.. cfunction:: void PyUFunc_G_G(char** args, npy_intp* dimensions,
+ npy_intp* steps, void* func)
Type specific, core 1d functions for ufuncs where each
calculation is obtained by calling a function taking one input
@@ 235,21 +247,29 @@
but calls out to a Cfunction that takes double and returns
double.
.. cfunction:: void PyUFunc_ff_f_As_dd_d(char** args, npy_intp* dimensions, npy_intp* steps, void* func)
+.. cfunction:: void PyUFunc_ff_f_As_dd_d(char** args, npy_intp* dimensions,
+ npy_intp* steps, void* func)
.. cfunction:: void PyUFunc_ff_f(char** args, npy_intp* dimensions, npy_intp* steps, void* func)
+.. cfunction:: void PyUFunc_ff_f(char** args, npy_intp* dimensions,
+ npy_intp* steps, void* func)
.. cfunction:: void PyUFunc_dd_d(char** args, npy_intp* dimensions, npy_intp* steps, void* func)
+.. cfunction:: void PyUFunc_dd_d(char** args, npy_intp* dimensions,
+ npy_intp* steps, void* func)
.. cfunction:: void PyUFunc_gg_g(char** args, npy_intp* dimensions, npy_intp* steps, void* func)
+.. cfunction:: void PyUFunc_gg_g(char** args, npy_intp* dimensions,
+ npy_intp* steps, void* func)
.. cfunction:: void PyUFunc_FF_F_As_DD_D(char** args, npy_intp* dimensions, npy_intp* steps, void* func)
+.. cfunction:: void PyUFunc_FF_F_As_DD_D(char** args, npy_intp* dimensions,
+ npy_intp* steps, void* func)
.. cfunction:: void PyUFunc_DD_D(char** args, npy_intp* dimensions, npy_intp* steps, void* func)
+.. cfunction:: void PyUFunc_DD_D(char** args, npy_intp* dimensions,
+ npy_intp* steps, void* func)
.. cfunction:: void PyUFunc_FF_F(char** args, npy_intp* dimensions, npy_intp* steps, void* func)
+.. cfunction:: void PyUFunc_FF_F(char** args, npy_intp* dimensions,
+ npy_intp* steps, void* func)
.. cfunction:: void PyUFunc_GG_G(char** args, npy_intp* dimensions, npy_intp* steps, void* func)
+.. cfunction:: void PyUFunc_GG_G(char** args, npy_intp* dimensions,
+ npy_intp* steps, void* func)
Type specific, core 1d functions for ufuncs where each
calculation is obtained by calling a function taking two input
@@ 261,25 +281,29 @@
of one data type but cast the values at each iteration of the loop
to use the underlying function that takes a different data type.
.. cfunction:: void PyUFunc_O_O(char** args, npy_intp* dimensions, npy_intp* steps, void* func)
+.. cfunction:: void PyUFunc_O_O(char** args, npy_intp* dimensions,
+ npy_intp* steps, void* func)
.. cfunction:: void PyUFunc_OO_O(char** args, npy_intp* dimensions, npy_intp* steps, void* func)
+.. cfunction:: void PyUFunc_OO_O(char** args, npy_intp* dimensions,
+ npy_intp* steps, void* func)
Oneinput, oneoutput, and twoinput, oneoutput core 1d functions
 for the :cdata:`NPY_OBJECT` data type. These functions handle reference count
 issues and return early on error. The actual function to call is *func*
 and it must accept calls with the signature ``(PyObject*)(PyObject*)``
 for :cfunc:`PyUFunc_O_O` or ``(PyObject*)(PyObject *, PyObject *)``
 for :cfunc:`PyUFunc_OO_O`.
+ for the :cdata:`NPY_OBJECT` data type. These functions handle reference
+ count issues and return early on error. The actual function to call is
+ *func* and it must accept calls with the signature ``(PyObject*)
+ (PyObject*)`` for :cfunc:`PyUFunc_O_O` or ``(PyObject*)(PyObject *,
+ PyObject *)`` for :cfunc:`PyUFunc_OO_O`.
.. cfunction:: void PyUFunc_O_O_method(char** args, npy_intp* dimensions, npy_intp* steps, void* func)
+.. cfunction:: void PyUFunc_O_O_method(char** args, npy_intp* dimensions,
+ npy_intp* steps, void* func)
This general purpose 1d core function assumes that *func* is a string
representing a method of the input object. For each
iteration of the loop, the Python obejct is extracted from the array
and its *func* method is called returning the result to the output array.
.. cfunction:: void PyUFunc_OO_O_method(char** args, npy_intp* dimensions, npy_intp* steps, void* func)
+.. cfunction:: void PyUFunc_OO_O_method(char** args, npy_intp* dimensions,
+ npy_intp* steps, void* func)
This general purpose 1d core function assumes that *func* is a
string representing a method of the input object that takes one
@@ 288,7 +312,8 @@
function. The output of the function is stored in the third entry
of *args*.
.. cfunction:: void PyUFunc_On_Om(char** args, npy_intp* dimensions, npy_intp* steps, void* func)
+.. cfunction:: void PyUFunc_On_Om(char** args, npy_intp* dimensions,
+ npy_intp* steps, void* func)
This is the 1d core function used by the dynamic ufuncs created
by umath.frompyfunc(function, nin, nout). In this case *func* is a
Modified: trunk/doc/source/reference/index.rst
===================================================================
 trunk/doc/source/reference/index.rst 20100217 23:53:04 UTC (rev 8127)
+++ trunk/doc/source/reference/index.rst 20100217 23:55:16 UTC (rev 8128)
@@ 34,7 +34,8 @@
Public Domain in August 2008). The reference documentation for many of
the functions are written by numerous contributors and developers of
Numpy, both prior to and during the
`Numpy Documentation Marathon <http://scipy.org/Developer_Zone/DocMarathon2008>`__.
+`Numpy Documentation Marathon
+<http://scipy.org/Developer_Zone/DocMarathon2008>`__.
Please help to improve NumPy's documentation! Instructions on how to
join the ongoing documentation marathon can be found
Modified: trunk/doc/source/reference/internals.codeexplanations.rst
===================================================================
 trunk/doc/source/reference/internals.codeexplanations.rst 20100217 23:53:04 UTC (rev 8127)
+++ trunk/doc/source/reference/internals.codeexplanations.rst 20100217 23:55:16 UTC (rev 8128)
@@ 99,7 +99,7 @@
dataptr member of the iterator object structure and call the macro
:cfunc:`PyArray_ITER_NEXT` (it) on the iterator object to move to the next
element. The "next" element is always in Ccontiguous order. The macro
works by first special casing the Ccontiguous, 1d, and 2d cases
+works by first special casing the Ccontiguous, 1D, and 2D cases
which work very simply.
For the general case, the iteration works by keeping track of a list
@@ 196,7 +196,7 @@
The implementation of advanced indexing represents some of the most
difficult code to write and explain. In fact, there are two
implementations of advanced indexing. The first works only with 1d
+implementations of advanced indexing. The first works only with 1D
arrays and is implemented to handle expressions involving a.flat[obj].
The second is generalpurpose that works for arrays of "arbitrary
dimension" (up to a fixed maximum). The onedimensional indexing
@@ 222,7 +222,7 @@
After these optimizations, the array_subscript function itself is
called. This function first checks for field selection which occurs
when a string is passed as the indexing object. Then, 0d arrays are
+when a string is passed as the indexing object. Then, 0D arrays are
given specialcase consideration. Finally, the code determines whether
or not advanced, or fancy, indexing needs to be performed. If fancy
indexing is not needed, then standard viewbased indexing is performed
@@ 330,12 +330,12 @@
single: ufunc
Universal functions are callable objects that take :math:`N` inputs
and produce :math:`M` outputs by wrapping basic 1d loops that work
+and produce :math:`M` outputs by wrapping basic 1D loops that work
elementbyelement into full easyto use functions that seamlessly
implement broadcasting, typechecking and buffered coercion, and
outputargument handling. New universal functions are normally created
in C, although there is a mechanism for creating ufuncs from Python
functions (:func:`frompyfunc`). The user must supply a 1d loop that
+functions (:func:`frompyfunc`). The user must supply a 1D loop that
implements the basic function taking the input scalar values and
placing the resulting scalars into the appropriate output slots as
explaine n implementation.
@@ 349,7 +349,7 @@
even though the actual calculation of the ufunc is very fast, you will
be able to write array and typespecific code that will work faster
for small arrays than the ufunc. In particular, using ufuncs to
perform many calculations on 0d arrays will be slower than other
+perform many calculations on 0D arrays will be slower than other
Pythonbased solutions (the silentlyimported scalarmath module exists
precisely to give array scalars the lookandfeel of ufuncbased
calculations with significantly reduced overhead).
@@ 366,9 +366,9 @@
dictionary the current values for the buffersize, the error mask, and
the associated error object. The state of the error mask controls what
happens when an errorcondiction is found. It should be noted that
checking of the hardware error flags is only performed after each 1d
+checking of the hardware error flags is only performed after each 1D
loop is executed. This means that if the input and output arrays are
contiguous and of the correct type so that a single 1d loop is
+contiguous and of the correct type so that a single 1D loop is
performed, then the flags may not be checked until all elements of the
array have been calcluated. Looking up these values in a thread
specific dictionary takes time which is easily ignored for all but
@@ 378,11 +378,11 @@
evaluated to determine how the ufunc should proceed and the input and
output arrays are constructed if necessary. Any inputs which are not
arrays are converted to arrays (using context if necessary). Which of
the inputs are scalars (and therefore converted to 0d arrays) is
+the inputs are scalars (and therefore converted to 0D arrays) is
noted.
Next, an appropriate 1d loop is selected from the 1d loops available
to the ufunc based on the input array types. This 1d loop is selected
+Next, an appropriate 1D loop is selected from the 1D loops available
+to the ufunc based on the input array types. This 1D loop is selected
by trying to match the signature of the datatypes of the inputs
against the available signatures. The signatures corresponding to
builtin types are stored in the types member of the ufunc structure.
@@ 394,10 +394,10 @@
input arrays can all be cast safely (ignoring any scalar arguments
which are not allowed to determine the type of the result). The
implication of this search procedure is that "lesser types" should be
placed below "larger types" when the signatures are stored. If no 1d
+placed below "larger types" when the signatures are stored. If no 1D
loop is found, then an error is reported. Otherwise, the argument_list
is updated with the stored signature  in case casting is necessary
and to fix the output types assumed by the 1d loop.
+and to fix the output types assumed by the 1D loop.
If the ufunc has 2 inputs and 1 output and the second input is an
Object array then a specialcase check is performed so that
@@ 406,7 +406,7 @@
method. In this way, Python is signaled to give the other object a
chance to complete the operation instead of using generic objectarray
calculations. This allows (for example) sparse matrices to override
the multiplication operator 1d loop.
+the multiplication operator 1D loop.
For input arrays that are smaller than the specified buffer size,
copies are made of all noncontiguous, misaligned, or outof
@@ 441,7 +441,7 @@
compilation, then the Python Global Interpreter Lock (GIL) is released
prior to calling all of these loops (as long as they don't involve
object arrays). It is reacquired if necessary to handle error
conditions. The hardware error flags are checked only after the 1d
+conditions. The hardware error flags are checked only after the 1D
loop is calcluated.
@@ 449,10 +449,10 @@
^^^^^^^^
This is the simplest case of all. The ufunc is executed by calling the
underlying 1d loop exactly once. This is possible only when we have
+underlying 1D loop exactly once. This is possible only when we have
aligned data of the correct type (including byteorder) for both input
and output and all arrays have uniform strides (either contiguous,
0d, or 1d). In this case, the 1d computational loop is called once
+0D, or 1D). In this case, the 1D computational loop is called once
to compute the calculation for the entire array. Note that the
hardware error flags are only checked after the entire calculation is
complete.
@@ 462,13 +462,13 @@
^^^^^^^^^^^^
When the input and output arrays are aligned and of the correct type,
but the striding is not uniform (noncontiguous and 2d or larger),
+but the striding is not uniform (noncontiguous and 2D or larger),
then a second looping structure is employed for the calculation. This
approach converts all of the iterators for the input and output
arguments to iterate over all but the largest dimension. The inner
loop is then handled by the underlying 1d computational loop. The
+loop is then handled by the underlying 1D computational loop. The
outer loop is a standard iterator loop on the converted iterators. The
hardware error flags are checked after each 1d loop is completed.
+hardware error flags are checked after each 1D loop is completed.
Buffered Loop
@@ 476,12 +476,12 @@
This is the code that handles the situation whenever the input and/or
output arrays are either misaligned or of the wrong datatype
(including being byteswapped) from what the underlying 1d loop
+(including being byteswapped) from what the underlying 1D loop
expects. The arrays are also assumed to be noncontiguous. The code
works very much like the strided loop except for the inner 1d loop is
+works very much like the strided loop except for the inner 1D loop is
modified so that preprocessing is performed on the inputs and post
processing is performed on the outputs in bufsize chunks (where
bufsize is a usersettable parameter). The underlying 1d
+bufsize is a usersettable parameter). The underlying 1D
computational loop is called on data that is copied over (if it needs
to be). The setup code and the loop code is considerably more
complicated in this case because it has to handle:
@@ 497,10 +497,10 @@
 specialcasing Object arrays so that reference counts are properly
handled when copies and/or casts are necessary.
 breaking up the inner 1d loop into bufsize chunks (with a possible
+ breaking up the inner 1D loop into bufsize chunks (with a possible
remainder).
Again, the hardware error flags are checked at the end of each 1d
+Again, the hardware error flags are checked at the end of each 1D
loop.
@@ 544,7 +544,7 @@
This function creates a reducing loop object and fills it with
parameters needed to complete the loop. All of the methods only work
on ufuncs that take 2inputs and return 1 output. Therefore, the
underlying 1d loop is selected assuming a signature of [ ``otype``,
+underlying 1D loop is selected assuming a signature of [ ``otype``,
``otype``, ``otype`` ] where ``otype`` is the requested reduction
datatype. The buffer size and error handling is then retrieved from
(perthread) global storage. For small arrays that are misaligned or
@@ 573,10 +573,10 @@
.. index::
triple: ufunc; methods; reduce
All of the ufunc methods use the same underlying 1d computational
+All of the ufunc methods use the same underlying 1D computational
loops with input and output arguments adjusted so that the appropriate
reduction takes place. For example, the key to the functioning of
reduce is that the 1d loop is called with the output and the second
+reduce is that the 1D loop is called with the output and the second
input pointing to the same position in memory and both having a step
size of 0. The first input is pointing to the input array with a step
size given by the appropriate stride for the selected axis. In this
@@ 594,7 +594,7 @@
:math:`o` is the output, and :math:`i[k]` is the
:math:`k^{\textrm{th}}` element of :math:`i` along the selected axis.
This basic operations is repeated for arrays with greater than 1
dimension so that the reduction takes place for every 1d subarray
+dimension so that the reduction takes place for every 1D subarray
along the selected axis. An iterator with the selected dimension
removed handles this looping.
@@ 625,9 +625,10 @@
o[k] & = & i[k]\textrm{<op>}o[k1]\quad k=1\ldots N.
\end{align*}
The output has the same shape as the input and each 1d loop operates
over :math:`N` elements when the shape in the selected axis is :math:`N+1`. Again, buffered loops take care to copy and cast the data before
calling the underlying 1d computational loop.
+The output has the same shape as the input and each 1D loop operates
+over :math:`N` elements when the shape in the selected axis is :math:`N+1`.
+Again, buffered loops take care to copy and cast the data before
+calling the underlying 1D computational loop.
Reduceat
@@ 645,21 +646,21 @@
loop implementation is handled using code that is very similar to the
reduce code repeated as many times as there are elements in the
indices input. In particular: the first input pointer passed to the
underlying 1d computational loop points to the input array at the
+underlying 1D computational loop points to the input array at the
correct location indicated by the index array. In addition, the output
pointer and the second input pointer passed to the underlying 1d loop
point to the same position in memory. The size of the 1d
+pointer and the second input pointer passed to the underlying 1D loop
+point to the same position in memory. The size of the 1D
computational loop is fixed to be the difference between the current
index and the next index (when the current index is the last index,
then the next index is assumed to be the length of the array along the
selected dimension). In this way, the 1d loop will implement a reduce
+selected dimension). In this way, the 1D loop will implement a reduce
over the specified indices.
Misaligned or a loop datatype that does not match the input and/or
output datatype is handled using buffered code wherein data is
copied to a temporary buffer and cast to the correct datatype if
necessary prior to calling the underlying 1d function. The temporary
+necessary prior to calling the underlying 1D function. The temporary
buffers are created in (element) sizes no bigger than the user
settable buffersize value. Thus, the loop must be flexible enough to
call the underlying 1d computational loop enough times to complete
+call the underlying 1D computational loop enough times to complete
the total calculation in chunks no bigger than the buffersize.
Modified: trunk/doc/source/reference/maskedarray.generic.rst
===================================================================
 trunk/doc/source/reference/maskedarray.generic.rst 20100217 23:53:04 UTC (rev 8127)
+++ trunk/doc/source/reference/maskedarray.generic.rst 20100217 23:55:16 UTC (rev 8128)
@@ 19,11 +19,19 @@
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 :mod:`numpy.ma` module provides a convenient way to address this issue, by introducing masked arrays.
+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 :mod:`numpy.ma` module provides a convenient
+way to address this issue, by introducing masked arrays.
A masked array is the combination of a standard :class:`numpy.ndarray` and a mask. A mask is either :attr:`nomask`, indicating that no value of the associated array is invalid, or an array of booleans that determines for each element of the associated array whether the value is valid or not. When an element of the mask is ``False``, the corresponding element of the associated array is valid and is said to be unmasked. When an element of the mask is ``True``, the corresponding element of the associated array is said to be masked (invalid).
+A masked array is the combination of a standard :class:`numpy.ndarray` and a
+mask. A mask is either :attr:`nomask`, indicating that no value of the
+associated array is invalid, or an array of booleans that determines for each
+element of the associated array whether the value is valid or not. When an
+element of the mask is ``False``, the corresponding element of the associated
+array is valid and is said to be unmasked. When an element of the mask is
+``True``, the corresponding element of the associated array is said to be
+masked (invalid).
The package ensures that masked entries are not used in computations.
@@ 38,7 +46,8 @@
>>> mx = ma.masked_array(x, mask=[0, 0, 0, 1, 0])
We can now compute the mean of the dataset, without taking the invalid data into account::
+We can now compute the mean of the dataset, without taking the invalid data
+into account::
>>> mx.mean()
2.75
@@ 48,8 +57,9 @@

The main feature of the :mod:`numpy.ma` module is the :class:`MaskedArray` class, which is a subclass of :class:`numpy.ndarray`.
The class, its attributes and methods are described in more details in the
+The main feature of the :mod:`numpy.ma` module is the :class:`MaskedArray`
+class, which is a subclass of :class:`numpy.ndarray`. The class, its
+attributes and methods are described in more details in the
:ref:`MaskedArray class <maskedarray.baseclass>` section.
The :mod:`numpy.ma` module can be used as an addition to :mod:`numpy`: ::
@@ 138,30 +148,40 @@
The underlying data of a masked array can be accessed in several ways:
* through the :attr:`~MaskedArray.data` attribute. The output is a view of the array as
 a :class:`numpy.ndarray` or one of its subclasses, depending on the type
 of the underlying data at the masked array creation.
+* through the :attr:`~MaskedArray.data` attribute. The output is a view of the
+ array as a :class:`numpy.ndarray` or one of its subclasses, depending on the
+ type of the underlying data at the masked array creation.
* through the :meth:`~MaskedArray.__array__` method. The output is then a :class:`numpy.ndarray`.
+* through the :meth:`~MaskedArray.__array__` method. The output is then a
+ :class:`numpy.ndarray`.
* by directly taking a view of the masked array as a :class:`numpy.ndarray` or one of its subclass (which is actually what using the :attr:`~MaskedArray.data` attribute does).
+* by directly taking a view of the masked array as a :class:`numpy.ndarray`
+ or one of its subclass (which is actually what using the
+ :attr:`~MaskedArray.data` attribute does).
* by using the :func:`getdata` function.
None of these methods is completely satisfactory if some entries have been marked as invalid. As a general rule, where a representation of the array is required without any masked entries, it is recommended to fill the array with the :meth:`filled` method.
+None of these methods is completely satisfactory if some entries have been
+marked as invalid. As a general rule, where a representation of the array is
+required without any masked entries, it is recommended to fill the array with
+the :meth:`filled` method.
Accessing the mask

The mask of a masked array is accessible through its :attr:`~MaskedArray.mask` attribute.
We must keep in mind that a ``True`` entry in the mask indicates an *invalid* data.
+The mask of a masked array is accessible through its :attr:`~MaskedArray.mask`
+attribute. We must keep in mind that a ``True`` entry in the mask indicates an
+*invalid* data.
Another possibility is to use the :func:`getmask` and :func:`getmaskarray` functions. :func:`getmask(x)` outputs the mask of ``x`` if ``x`` is a masked array, and the special value :data:`nomask` otherwise.
:func:`getmaskarray(x)` outputs the mask of ``x`` if ``x`` is a masked array.
If ``x`` has no invalid entry or is not a masked array, the function outputs a boolean array of ``False`` with as many elements as ``x``.
+Another possibility is to use the :func:`getmask` and :func:`getmaskarray`
+functions. :func:`getmask(x)` outputs the mask of ``x`` if ``x`` is a masked
+array, and the special value :data:`nomask` otherwise. :func:`getmaskarray(x)`
+outputs the mask of ``x`` if ``x`` is a masked array. If ``x`` has no invalid
+entry or is not a masked array, the function outputs a boolean array of
+``False`` with as many elements as ``x``.
@@ 169,7 +189,9 @@
Accessing only the valid entries

To retrieve only the valid entries, we can use the inverse of the mask as an index. The inverse of the mask can be calculated with the :func:`numpy.logical_not` function or simply with the ``~`` operator::
+To retrieve only the valid entries, we can use the inverse of the mask as an
+index. The inverse of the mask can be calculated with the
+:func:`numpy.logical_not` function or simply with the ``~`` operator::
>>> x = ma.array([[1, 2], [3, 4]], mask=[[0, 1], [1, 0]])
>>> x[~x.mask]
@@ 177,9 +199,10 @@
mask = [False False],
fill_value = 999999)
Another way to retrieve the valid data is to use the :meth:`compressed` method,
which returns a onedimensional :class:`~numpy.ndarray` (or one of its subclasses,
depending on the value of the :attr:`~MaskedArray.baseclass` attribute)::
+Another way to retrieve the valid data is to use the :meth:`compressed`
+method, which returns a onedimensional :class:`~numpy.ndarray` (or one of its
+subclasses, depending on the value of the :attr:`~MaskedArray.baseclass`
+attribute)::
>>> x.compressed()
array([1, 4])
@@ 194,7 +217,8 @@
Masking an entry
~~~~~~~~~~~~~~~~
The recommended way to mark one or several specific entries of a masked array as invalid is to assign the special value :attr:`masked` to them::
+The recommended way to mark one or several specific entries of a masked array
+as invalid is to assign the special value :attr:`masked` to them::
>>> x = ma.array([1, 2, 3])
>>> x[0] = ma.masked
@@ 226,10 +250,15 @@
but this usage is discouraged.
.. note::
 When creating a new masked array with a simple, nonstructured datatype, the mask is initially set to the special value :attr:`nomask`, that corresponds roughly to the boolean ``False``. Trying to set an element of :attr:`nomask` will fail with a :exc:`TypeError` exception, as a boolean does not support item assignment.
+ When creating a new masked array with a simple, nonstructured datatype,
+ the mask is initially set to the special value :attr:`nomask`, that
+ corresponds roughly to the boolean ``False``. Trying to set an element of
+ :attr:`nomask` will fail with a :exc:`TypeError` exception, as a boolean
+ does not support item assignment.
All the entries of an array can be masked at once by assigning ``True`` to the mask::
+All the entries of an array can be masked at once by assigning ``True`` to the
+mask::
>>> x = ma.array([1, 2, 3], mask=[0, 0, 1])
>>> x.mask = True
@@ 238,7 +267,8 @@
mask = [ True True True],
fill_value = 999999)
Finally, specific entries can be masked and/or unmasked by assigning to the mask a sequence of booleans::
+Finally, specific entries can be masked and/or unmasked by assigning to the
+mask a sequence of booleans::
>>> x = ma.array([1, 2, 3])
>>> x.mask = [0, 1, 0]
@@ 250,7 +280,8 @@
Unmasking an entry
~~~~~~~~~~~~~~~~~~
To unmask one or several specific entries, we can just assign one or several new valid values to them::
+To unmask one or several specific entries, we can just assign one or several
+new valid values to them::
>>> x = ma.array([1, 2, 3], mask=[0, 0, 1])
>>> x
@@ 264,12 +295,12 @@
fill_value = 999999)
.. note::
 Unmasking an entry by direct assignment will silently fail if the masked array
 has a *hard* mask, as shown by the :attr:`hardmask` attribute.
 This feature was introduced to prevent overwriting the mask.
 To force the unmasking of an entry where the array has a hard mask, the mask must first
 to be softened using the :meth:`soften_mask` method before the allocation. It can be rehardened
 with :meth:`harden_mask`::
+ Unmasking an entry by direct assignment will silently fail if the masked
+ array has a *hard* mask, as shown by the :attr:`hardmask` attribute. This
+ feature was introduced to prevent overwriting the mask. To force the
+ unmasking of an entry where the array has a hard mask, the mask must first
+ to be softened using the :meth:`soften_mask` method before the allocation.
+ It can be rehardened with :meth:`harden_mask`::
>>> x = ma.array([1, 2, 3], mask=[0, 0, 1], hard_mask=True)
>>> x
@@ 290,7 +321,9 @@
>>> x.harden_mask()
To unmask all masked entries of a masked array (provided the mask isn't a hard mask), the simplest solution is to assign the constant :attr:`nomask` to the mask::
+To unmask all masked entries of a masked array (provided the mask isn't a hard
+mask), the simplest solution is to assign the constant :attr:`nomask` to the
+mask::
>>> x = ma.array([1, 2, 3], mask=[0, 0, 1])
>>> x
@@ 308,9 +341,13 @@
Indexing and slicing

As a :class:`MaskedArray` is a subclass of :class:`numpy.ndarray`, it inherits its mechanisms for indexing and slicing.
+As a :class:`MaskedArray` is a subclass of :class:`numpy.ndarray`, it inherits
+its mechanisms for indexing and slicing.
When accessing a single entry of a masked array with no named fields, the output is either a scalar (if the corresponding entry of the mask is ``False``) or the special value :attr:`masked` (if the corresponding entry of the mask is ``True``)::
+When accessing a single entry of a masked array with no named fields, the
+output is either a scalar (if the corresponding entry of the mask is
+``False``) or the special value :attr:`masked` (if the corresponding entry of
+the mask is ``True``)::
>>> x = ma.array([1, 2, 3], mask=[0, 0, 1])
>>> x[0]
@@ 323,7 +360,9 @@
True
If the masked array has named fields, accessing a single entry returns a
:class:`numpy.void` object if none of the fields are masked, or a 0d masked array with the same dtype as the initial array if at least one of the fields is masked.
+:class:`numpy.void` object if none of the fields are masked, or a 0d masked
+array with the same dtype as the initial array if at least one of the fields
+is masked.
>>> y = ma.masked_array([(1,2), (3, 4)],
... mask=[(0, 0), (0, 1)],
@@ 337,7 +376,11 @@
dtype = [('a', '<i4'), ('b', '<i4')])
When accessing a slice, the output is a masked array whose :attr:`~MaskedArray.data` attribute is a view of the original data, and whose mask is either :attr:`nomask` (if there was no invalid entries in the original array) or a copy of the corresponding slice of the original mask. The copy is required to avoid propagation of any modification of the mask to the original.
+When accessing a slice, the output is a masked array whose
+:attr:`~MaskedArray.data` attribute is a view of the original data, and whose
+mask is either :attr:`nomask` (if there was no invalid entries in the original
+array) or a copy of the corresponding slice of the original mask. The copy is
+required to avoid propagation of any modification of the mask to the original.
>>> x = ma.array([1, 2, 3, 4, 5], mask=[0, 1, 0, 0, 1])
>>> mx = x[:3]
@@ 356,31 +399,39 @@
array([ 1, 1, 3, 4, 5])
Accessing a field of a masked array with structured datatype returns a :class:`MaskedArray`.
+Accessing a field of a masked array with structured datatype returns a
+:class:`MaskedArray`.


Operations on masked arrays

Arithmetic and comparison operations are supported by masked arrays.
As much as possible, invalid entries of a masked array are not processed, meaning that the
corresponding :attr:`data` entries *should* be the same before and after the operation.
+As much as possible, invalid entries of a masked array are not processed,
+meaning that the corresponding :attr:`data` entries *should* be the same
+before and after the operation.
.. warning::
 We need to stress that this behavior may not be systematic, that masked data may be affected
 by the operation in some cases and therefore users should not rely on this data remaining unchanged.
+ We need to stress that this behavior may not be systematic, that masked
+ data may be affected by the operation in some cases and therefore users
+ should not rely on this data remaining unchanged.
The :mod:`numpy.ma` module comes with a specific implementation of most
ufuncs.
Unary and binary functions that have a validity domain (such as :func:`~numpy.log` or :func:`~numpy.divide`) return the :data:`masked` constant whenever the input is masked or falls outside the validity domain::
+ufuncs. Unary and binary functions that have a validity domain (such as
+:func:`~numpy.log` or :func:`~numpy.divide`) return the :data:`masked`
+constant whenever the input is masked or falls outside the validity domain::
>>> ma.log([1, 0, 1, 2])
masked_array(data = [  0.0 0.69314718056],
mask = [ True True False False],
fill_value = 1e+20)
Masked arrays also support standard numpy ufuncs. The output is then a masked array. The result of a unary ufunc is masked wherever the input is masked. The result of a binary ufunc is masked wherever any of the input is masked. If the ufunc also returns the optional context output (a 3element tuple containing the name of the ufunc, its arguments and its domain), the context is processed and entries of the output masked array are masked wherever the corresponding input fall outside the validity domain::
+Masked arrays also support standard numpy ufuncs. The output is then a masked
+array. The result of a unary ufunc is masked wherever the input is masked. The
+result of a binary ufunc is masked wherever any of the input is masked. If the
+ufunc also returns the optional context output (a 3element tuple containing
+the name of the ufunc, its arguments and its domain), the context is processed
+and entries of the output masked array are masked wherever the corresponding
+input fall outside the validity domain::
>>> x = ma.array([1, 1, 0, 2, 3], mask=[0, 0, 0, 0, 1])
>>> np.log(x)
@@ 396,8 +447,9 @@
Data with a given value representing missing data

Let's consider a list of elements, ``x``, where values of 9999. represent missing data.
We wish to compute the average value of the data and the vector of anomalies (deviations from the average)::
+Let's consider a list of elements, ``x``, where values of 9999. represent
+missing data. We wish to compute the average value of the data and the vector
+of anomalies (deviations from the average)::
>>> import numpy.ma as ma
>>> x = [0.,1.,9999.,3.,4.]
@@ 423,7 +475,8 @@
Numerical operations

Numerical operations can be easily performed without worrying about missing values, dividing by zero, square roots of negative numbers, etc.::
+Numerical operations can be easily performed without worrying about missing
+values, dividing by zero, square roots of negative numbers, etc.::
>>> import numpy as np, numpy.ma as ma
>>> x = ma.array([1., 1., 3., 4., 5., 6.], mask=[0,0,0,0,1,0])
@@ 431,13 +484,16 @@
>>> print np.sqrt(x/y)
[1.0   1.0  ]
Four values of the output are invalid: the first one comes from taking the square root of a negative number, the second from the division by zero, and the last two where the inputs were masked.
+Four values of the output are invalid: the first one comes from taking the
+square root of a negative number, the second from the division by zero, and
+the last two where the inputs were masked.
Ignoring extreme values

Let's consider an array ``d`` of random floats between 0 and 1.
We wish to compute the average of the values of ``d`` while ignoring any data outside the range ``[0.1, 0.9]``::
+Let's consider an array ``d`` of random floats between 0 and 1. We wish to
+compute the average of the values of ``d`` while ignoring any data outside
+the range ``[0.1, 0.9]``::
>>> print ma.masked_outside(d, 0.1, 0.9).mean()
Modified: trunk/doc/source/reference/routines.arraycreation.rst
===================================================================
 trunk/doc/source/reference/routines.arraycreation.rst 20100217 23:53:04 UTC (rev 8127)
+++ trunk/doc/source/reference/routines.arraycreation.rst 20100217 23:55:16 UTC (rev 8128)
@@ 44,7 +44,8 @@
Creating record arrays (:mod:`numpy.rec`)

.. note:: :mod:`numpy.rec` is the preferred alias for :mod:`numpy.core.records`.
+.. note:: :mod:`numpy.rec` is the preferred alias for
+ :mod:`numpy.core.records`.
.. autosummary::
:toctree: generated/
@@ 60,7 +61,8 @@
Creating character arrays (:mod:`numpy.char`)

.. note:: :mod:`numpy.char` is the preferred alias for :mod:`numpy.core.defchararray`.
+.. note:: :mod:`numpy.char` is the preferred alias for
+ :mod:`numpy.core.defchararray`.
.. autosummary::
:toctree: generated/
Modified: trunk/doc/source/reference/routines.rst
===================================================================
 trunk/doc/source/reference/routines.rst 20100217 23:53:04 UTC (rev 8127)
+++ trunk/doc/source/reference/routines.rst 20100217 23:55:16 UTC (rev 8128)
@@ 2,6 +2,16 @@
Routines
********
+In this chapter routine docstrings are presented, grouped by functionality.
+Many docstrings contain example code, which demonstrates basic usage
+of the routine. The examples assume that NumPy is imported with::
+
+ >>> import numpy as np
+
+A convenient way to execute examples is the ``%doctest_mode`` mode of
+IPython, which allows for pasting of multiline examples and preserves
+indentation.
+
.. toctree::
:maxdepth: 2
Modified: trunk/doc/source/user/basics.indexing.rst
===================================================================
 trunk/doc/source/user/basics.indexing.rst 20100217 23:53:04 UTC (rev 8127)
+++ trunk/doc/source/user/basics.indexing.rst 20100217 23:55:16 UTC (rev 8128)
@@ 6,11 +6,4 @@
.. seealso:: :ref:`Indexing routines <routines.indexing>`
.. note::

 XXX: Combine ``numpy.doc.indexing`` with material
 section 2.2 Basic indexing?
 Or incorporate the material directly here?


.. automodule:: numpy.doc.indexing
Modified: trunk/doc/source/user/basics.rec.rst
===================================================================
 trunk/doc/source/user/basics.rec.rst 20100217 23:53:04 UTC (rev 8127)
+++ trunk/doc/source/user/basics.rec.rst 20100217 23:55:16 UTC (rev 8128)
@@ 1,3 +1,5 @@
+.. _structured_arrays:
+
***************************************
Structured arrays (aka "Record arrays")
***************************************
Modified: trunk/doc/source/user/basics.rst
===================================================================
 trunk/doc/source/user/basics.rst 20100217 23:53:04 UTC (rev 8127)
+++ trunk/doc/source/user/basics.rst 20100217 23:55:16 UTC (rev 8128)
@@ 2,11 +2,6 @@
Numpy basics
************
.. note::

 XXX: there is overlap between this text extracted from ``numpy.doc``
 and "Guide to Numpy" chapter 2. Needs combining?

.. toctree::
:maxdepth: 2
Modified: trunk/doc/source/user/basics.types.rst
===================================================================
 trunk/doc/source/user/basics.types.rst 20100217 23:53:04 UTC (rev 8127)
+++ trunk/doc/source/user/basics.types.rst 20100217 23:55:16 UTC (rev 8128)
@@ 4,11 +4,4 @@
.. seealso:: :ref:`Data type objects <arrays.dtypes>`
.. note::

 XXX: Combine ``numpy.doc.indexing`` with material from
 "Guide to Numpy" (section 2.1 DataType descriptors)?
 Or incorporate the material directly here?


.. automodule:: numpy.doc.basics
Modified: trunk/doc/source/user/cinfo.beyondbasics.rst
===================================================================
 trunk/doc/source/user/cinfo.beyondbasics.rst 20100217 23:53:04 UTC (rev 8127)
+++ trunk/doc/source/user/cinfo.beyondbasics.rst 20100217 23:55:16 UTC (rev 8128)
@@ 159,17 +159,18 @@
.. index::
single: broadcasting
When multiple arrays are involved in an operation, you may want to use the same
broadcasting rules that the math operations ( *i.e.* the ufuncs) use. This can
be done easily using the :ctype:`PyArrayMultiIterObject`. This is the object
returned from the Python command numpy.broadcast and it is almost as easy to
use from C. The function :cfunc:`PyArray_MultiIterNew` ( ``n``, ``...`` ) is
used (with ``n`` input objects in place of ``...`` ). The input objects can be
arrays or anything that can be converted into an array. A pointer to a
PyArrayMultiIterObject is returned. Broadcasting has already been accomplished
which adjusts the iterators so that all that needs to be done to advance to the
next element in each array is for PyArray_ITER_NEXT to be called for each of
the inputs. This incrementing is automatically performed by
+When multiple arrays are involved in an operation, you may want to use the
+same broadcasting rules that the math operations (*i.e.* the ufuncs) use.
+This can be done easily using the :ctype:`PyArrayMultiIterObject`. This is
+the object returned from the Python command numpy.broadcast and it is almost
+as easy to use from C. The function
+:cfunc:`PyArray_MultiIterNew` ( ``n``, ``...`` ) is used (with ``n`` input
+objects in place of ``...`` ). The input objects can be arrays or anything
+that can be converted into an array. A pointer to a PyArrayMultiIterObject is
+returned. Broadcasting has already been accomplished which adjusts the
+iterators so that all that needs to be done to advance to the next element in
+each array is for PyArray_ITER_NEXT to be called for each of the inputs. This
+incrementing is automatically performed by
:cfunc:`PyArray_MultiIter_NEXT` ( ``obj`` ) macro (which can handle a
multiterator ``obj`` as either a :ctype:`PyArrayMultiObject *` or a
:ctype:`PyObject *`). The data from input number ``i`` is available using
@@ 233,15 +234,19 @@
builtin datatypes is given below. A different mechanism is used to
register ufuncs for userdefined datatypes.
.. cfunction:: PyObject *PyUFunc_FromFuncAndData( PyUFuncGenericFunction* func, void** data, char* types, int ntypes, int nin, int nout, int identity, char* name, char* doc, int check_return)
+.. cfunction:: PyObject *PyUFunc_FromFuncAndData( PyUFuncGenericFunction* func,
+ void** data, char* types, int ntypes, int nin, int nout, int identity,
+ char* name, char* doc, int check_return)
*func*
A pointer to an array of 1d functions to use. This array must be at
 least ntypes long. Each entry in the array must be a ``PyUFuncGenericFunction`` function. This function has the following signature. An example of a
 valid 1d loop function is also given.
+ least ntypes long. Each entry in the array must be a
+ ``PyUFuncGenericFunction`` function. This function has the following
+ signature. An example of a valid 1d loop function is also given.
 .. cfunction:: void loop1d(char** args, npy_intp* dimensions, npy_intp* steps, void* data)
+ .. cfunction:: void loop1d(char** args, npy_intp* dimensions,
+ npy_intp* steps, void* data)
*args*
@@ 269,7 +274,8 @@
.. codeblock:: c
static void
 double_add(char *args, npy_intp *dimensions, npy_intp *steps, void *extra)
+ double_add(char *args, npy_intp *dimensions, npy_intp *steps,
+ void *extra)
{
npy_intp i;
npy_intp is1=steps[0], is2=steps[1];
@@ 320,9 +326,9 @@
*identity*
 Either :cdata:`PyUFunc_One`, :cdata:`PyUFunc_Zero`, :cdata:`PyUFunc_None`.
 This specifies what should be returned when an empty array is
 passed to the reduce method of the ufunc.
+ Either :cdata:`PyUFunc_One`, :cdata:`PyUFunc_Zero`,
+ :cdata:`PyUFunc_None`. This specifies what should be returned when
+ an empty array is passed to the reduce method of the ufunc.
*name*
@@ 458,7 +464,8 @@
these functions with the datatype descriptor. A lowlevel casting
function has the signature.
.. cfunction:: void castfunc( void* from, void* to, npy_intp n, void* fromarr, void* toarr)
+.. cfunction:: void castfunc( void* from, void* to, npy_intp n, void* fromarr,
+ void* toarr)
Cast ``n`` elements ``from`` one type ``to`` another. The data to
cast from is in a contiguous, correctlyswapped and aligned chunk
@@ 531,7 +538,8 @@
this function is ``0`` if the process was successful and ``1`` with
an error condition set if it was not successful.
.. cfunction:: int PyUFunc_RegisterLoopForType( PyUFuncObject* ufunc, int usertype, PyUFuncGenericFunction function, int* arg_types, void* data)
+.. cfunction:: int PyUFunc_RegisterLoopForType( PyUFuncObject* ufunc,
+ int usertype, PyUFuncGenericFunction function, int* arg_types, void* data)
*ufunc*
@@ 661,10 +669,6 @@
Some special methods and attributes are used by arrays in order to
facilitate the interoperation of subtypes with the base ndarray type.
.. note:: XXX: some of the documentation below needs to be moved to the
 reference guide.


The __array_finalize\__ method
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Modified: trunk/doc/source/user/cinfo.pythonasglue.rst
===================================================================
 trunk/doc/source/user/cinfo.pythonasglue.rst 20100217 23:53:04 UTC (rev 8127)
+++ trunk/doc/source/user/cinfo.pythonasglue.rst 20100217 23:55:16 UTC (rev 8128)
@@ 13,7 +13,7 @@
Many people like to say that Python is a fantastic glue language.
Hopefully, this Chapter will convince you that this is true. The first
adopters of Python for science were typically people who used it to
glue together large applicaton codes running on supercomputers. Not
+glue together large application codes running on supercomputers. Not
only was it much nicer to code in Python than in a shell script or
Perl, in addition, the ability to easily extend Python made it
relatively easy to create new classes and types specifically adapted
@@ 123,8 +123,7 @@
interfaces to routines in Fortran 77/90/95 code. It has the ability to
parse Fortran 77/90/95 code and automatically generate Python
signatures for the subroutines it encounters, or you can guide how the
subroutine interfaces with Python by constructing an interface
defintionfile (or modifying the f2pyproduced one).
+subroutine interfaces with Python by constructing an interfacedefinitionfile (or modifying the f2pyproduced one).
.. index::
single: f2py
@@ 175,7 +174,7 @@
This command leaves a file named add.{ext} in the current directory
(where {ext} is the appropriate extension for a python extension
module on your platform  so, pyd, *etc.* ). This module may then be
imported from Python. It will contain a method for each subroutin in
+imported from Python. It will contain a method for each subroutine in
add (zadd, cadd, dadd, sadd). The docstring of each method contains
information about how the module method may be called:
@@ 586,7 +585,7 @@
One final note about weave.inline: if you have additional code you
want to include in the final extension module such as supporting
function calls, include statments, etc. you can pass this code in as a
+function calls, include statements, etc. you can pass this code in as a
string using the keyword support_code: ``weave.inline(code, variables,
support_code=support)``. If you need the extension module to link
against an additional library then you can also pass in
@@ 784,7 +783,7 @@
Pyrexfilter

The twodimensional example we created using weave is a bit uglierto
+The twodimensional example we created using weave is a bit uglier to
implement in Pyrex because twodimensional indexing using Pyrex is not
as simple. But, it is straightforward (and possibly faster because of
precomputed indices). Here is the Pyrexfile I named image.pyx.
@@ 873,7 +872,7 @@
4. Multidimensional arrays are "bulky" to index (appropriate macros
may be able to fix this).
5. The Ccode generated by Prex is hard to read and modify (and typically
+5. The Ccode generated by Pyrex is hard to read and modify (and typically
compiles with annoying but harmless warnings).
Writing a good Pyrex extension module still takes a bit of effort
@@ 1126,8 +1125,8 @@
area of an ndarray. You may still want to wrap the function in an
additional Python wrapper to make it userfriendly (hiding some
obvious arguments and making some arguments output arguments). In this
process, the **requires** function in NumPy may be useful to return the right kind of array from
a given input.
+process, the **requires** function in NumPy may be useful to return the right
+kind of array from a given input.
Complete example
Modified: trunk/doc/source/user/howtofind.rst
===================================================================
 trunk/doc/source/user/howtofind.rst 20100217 23:53:04 UTC (rev 8127)
+++ trunk/doc/source/user/howtofind.rst 20100217 23:55:16 UTC (rev 8128)
@@ 4,6 +4,4 @@
.. seealso:: :ref:`Numpyspecific help functions <routines.help>`
.. note:: XXX: this part is not yet written.

.. automodule:: numpy.doc.howtofind
Modified: trunk/doc/source/user/install.rst
===================================================================
 trunk/doc/source/user/install.rst 20100217 23:53:04 UTC (rev 8127)
+++ trunk/doc/source/user/install.rst 20100217 23:55:16 UTC (rev 8128)
@@ 12,29 +12,30 @@

Good solutions for Windows are, The Enthought Python Distribution `(EPD)
<http://www.enthought.com/products/epd.php>`_ (which provides binary installers
for Windows, OS X and Redhat) and `Python (x, y) <http://www.pythonxy.com>`_.
Both of these packages include Python, NumPy and many additional packages.
A lightweight alternative is to download the Python installer from
`www.python.org <http://www.python.org>`_ and the NumPy installer for your
Python version from the Sourceforge `download site
<http://sourceforge.net/project/showfiles.php?group_id=1369&package_id=175103>`_
+<http://www.enthought.com/products/epd.php>`_ (which provides binary
+installers for Windows, OS X and Redhat) and `Python (x, y)
+<http://www.pythonxy.com>`_. Both of these packages include Python, NumPy and
+many additional packages. A lightweight alternative is to download the Python
+installer from `www.python.org <http://www.python.org>`_ and the NumPy
+installer for your Python version from the Sourceforge `download site <http://
+sourceforge.net/project/showfiles.php?group_id=1369&package_id=175103>`_
Linux

Most of the major distributions provide packages for NumPy, but these can lag
behind the most recent NumPy release. Prebuilt binary packages for Ubuntu are
available on the `scipy ppa <https://edge.launchpad.net/~scipy/+archive/ppa>`_.
Redhat binaries are available in the `EPD
<http://www.enthought.com/products/epd.php>`_.
+available on the `scipy ppa
+<https://edge.launchpad.net/~scipy/+archive/ppa>`_. Redhat binaries are
+available in the `EPD <http://www.enthought.com/products/epd.php>`_.
Mac OS X

A universal binary installer for NumPy is available from the `download site
<http://sourceforge.net/project/showfiles.php?group_id=1369&package_id=175103>`_.
The `EPD <http://www.enthought.com/products/epd.php>`_ provides NumPy binaries.
+<http://sourceforge.net/project/showfiles.php?group_id=1369&
+package_id=175103>`_. The `EPD <http://www.enthought.com/products/epd.php>`_
+provides NumPy binaries.
Building from source
====================
@@ 62,21 +63,22 @@
2) Compilers
 To build any extension modules for Python, you'll need a C compiler. Various
 NumPy modules use FORTRAN 77 libraries, so you'll also need a FORTRAN 77
 compiler installed.
+ To build any extension modules for Python, you'll need a C compiler.
+ Various NumPy modules use FORTRAN 77 libraries, so you'll also need a
+ FORTRAN 77 compiler installed.
 Note that NumPy is developed mainly using GNU compilers. Compilers from other
 vendors such as Intel, Absoft, Sun, NAG, Compaq, Vast, Porland, Lahey, HP,
 IBM, Microsoft are only supported in the form of community feedback, and may
 not work out of the box. GCC 3.x (and later) compilers are recommended.
+ Note that NumPy is developed mainly using GNU compilers. Compilers from
+ other vendors such as Intel, Absoft, Sun, NAG, Compaq, Vast, Porland,
+ Lahey, HP, IBM, Microsoft are only supported in the form of community
+ feedback, and may not work out of the box. GCC 3.x (and later) compilers
+ are recommended.
3) Linear Algebra libraries
 NumPy does not require any external linear algebra libraries to be installed.
 However, if these are available, NumPy's setup script can detect them and use
 them for building. A number of different LAPACK library setups can be used,
 including optimized LAPACK libraries such as ATLAS, MKL or the
+ NumPy does not require any external linear algebra libraries to be
+ installed. However, if these are available, NumPy's setup script can detect
+ them and use them for building. A number of different LAPACK library setups
+ can be used, including optimized LAPACK libraries such as ATLAS, MKL or the
Accelerate/vecLib framework on OS X.
FORTRAN ABI mismatch
@@ 87,8 +89,8 @@
should avoid mixing libraries built with one with another. In particular, if
your blas/lapack/atlas is built with g77, you *must* use g77 when building
numpy and scipy; on the contrary, if your atlas is built with gfortran, you
*must* build numpy/scipy with gfortran. This applies for most other cases where
different FORTRAN compilers might have been used.
+*must* build numpy/scipy with gfortran. This applies for most other cases
+where different FORTRAN compilers might have been used.
Choosing the fortran compiler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ 110,9 +112,9 @@
One relatively simple and reliable way to check for the compiler used to build
a library is to use ldd on the library. If libg2c.so is a dependency, this
means that g77 has been used. If libgfortran.so is a a dependency, gfortran has
been used. If both are dependencies, this means both have been used, which is
almost always a very bad idea.
+means that g77 has been used. If libgfortran.so is a a dependency, gfortran
+has been used. If both are dependencies, this means both have been used, which
+is almost always a very bad idea.
Building with ATLAS support

Modified: trunk/doc/source/user/misc.rst
===================================================================
 trunk/doc/source/user/misc.rst 20100217 23:53:04 UTC (rev 8127)
+++ trunk/doc/source/user/misc.rst 20100217 23:55:16 UTC (rev 8128)
@@ 2,8 +2,6 @@
Miscellaneous
*************
.. note:: XXX: This section is not yet written.

.. automodule:: numpy.doc.misc
.. automodule:: numpy.doc.methods_vs_functions
Modified: trunk/doc/source/user/performance.rst
===================================================================
 trunk/doc/source/user/performance.rst 20100217 23:53:04 UTC (rev 8127)
+++ trunk/doc/source/user/performance.rst 20100217 23:55:16 UTC (rev 8128)
@@ 2,6 +2,4 @@
Performance
***********
.. note:: XXX: This section is not yet written.

.. automodule:: numpy.doc.performance
Modified: trunk/numpy/add_newdocs.py
===================================================================
 trunk/numpy/add_newdocs.py 20100217 23:53:04 UTC (rev 8127)
+++ trunk/numpy/add_newdocs.py 20100217 23:55:16 UTC (rev 8128)
@@ 3985,6 +3985,12 @@
"""
Functions that operate element by element on whole arrays.
+ To see the documentation for a specific ufunc, use np.info(). For
+ example, np.info(np.sin). Because ufuncs are written in C
+ (for speed) and linked into Python with NumPy's ufunc facility,
+ Python's help() function finds this page whenever help() is called
+ on a ufunc.
+
A detailed explanation of ufuncs can be found in the "ufuncs.rst"
file in the NumPy reference guide.
Modified: trunk/numpy/core/code_generators/ufunc_docstrings.py
===================================================================
 trunk/numpy/core/code_generators/ufunc_docstrings.py 20100217 23:53:04 UTC (rev 8127)
+++ trunk/numpy/core/code_generators/ufunc_docstrings.py 20100217 23:55:16 UTC (rev 8128)
@@ 1641,7 +1641,7 @@
x1 : array_like of integer type
Input values.
x2 : array_like of integer type
 Number of zeros to append to `x1`.
+ Number of zeros to append to `x1`. Has to be nonnegative.
Returns

@@ 1849,6 +1849,16 @@
handles the floatingpoint negative zero as an infinitesimal negative
number, conforming to the C99 standard.
+ Examples
+ 
+ >>> x = np.array([0, 1, 2, 2**4])
+ >>> np.log2(x)
+ array([Inf, 0., 1., 4.])
+
+ >>> xi = np.array([0+1.j, 1, 2+0.j, 4.j])
+ >>> np.log2(xi)
+ array([ 0.+2.26618007j, 0.+0.j , 1.+0.j , 2.+2.26618007j])
+
""")
add_newdoc('numpy.core.umath', 'logaddexp',
Modified: trunk/numpy/doc/constants.py
===================================================================
 trunk/numpy/doc/constants.py 20100217 23:53:04 UTC (rev 8127)
+++ trunk/numpy/doc/constants.py 20100217 23:55:16 UTC (rev 8128)
@@ 75,8 +75,8 @@
isnan : Shows which elements are Not a Number
 isfinite : Shows which elements are finite (not one of
 Not a Number, positive infinity and negative infinity)
+ isfinite : Shows which elements are finite (not one of Not a Number,
+ positive infinity and negative infinity)
Notes

@@ 214,7 +214,7 @@
"""
Euler's constant, base of natural logarithms, Napier's constant.
 `e = 2.71828182845904523536028747135266249775724709369995...`
+ ``e = 2.71828182845904523536028747135266249775724709369995...``
See Also

@@ 246,8 +246,8 @@
isnan : Shows which elements are Not a Number
 isfinite : Shows which elements are finite (not one of
 Not a Number, positive infinity and negative infinity)
+ isfinite : Shows which elements are finite (not one of Not a Number,
+ positive infinity and negative infinity)
Notes

@@ 322,20 +322,20 @@
Examples

 >>> np.newaxis is None
+ >>> newaxis is None
True
>>> x = np.arange(3)
>>> x
array([0, 1, 2])
 >>> x[:, np.newaxis]
+ >>> x[:, newaxis]
array([[0],
[1],
[2]])
 >>> x[:, np.newaxis, np.newaxis]
+ >>> x[:, newaxis, newaxis]
array([[[0]],
[[1]],
[[2]]])
 >>> x[:, np.newaxis] * x
+ >>> x[:, newaxis] * x
array([[0, 0, 0],
[0, 1, 2],
[0, 2, 4]])
@@ 343,20 +343,20 @@
Outer product, same as ``outer(x, y)``:
>>> y = np.arange(3, 6)
 >>> x[:, np.newaxis] * y
+ >>> x[:, newaxis] * y
array([[ 0, 0, 0],
[ 3, 4, 5],
[ 6, 8, 10]])
``x[newaxis, :]`` is equivalent to ``x[newaxis]`` and ``x[None]``:
 >>> x[np.newaxis, :].shape
+ >>> x[newaxis, :].shape
(1, 3)
 >>> x[np.newaxis].shape
+ >>> x[newaxis].shape
(1, 3)
>>> x[None].shape
(1, 3)
 >>> x[:, np.newaxis].shape
+ >>> x[:, newaxis].shape
(3, 1)
""")
More information about the Numpysvn
mailing list