diff options
author | Jarrod Millman <millman@berkeley.edu> | 2009-11-13 17:50:02 +0000 |
---|---|---|
committer | Jarrod Millman <millman@berkeley.edu> | 2009-11-13 17:50:02 +0000 |
commit | 6e91f0f59818c5bc9021f1913764bb667811fbcc (patch) | |
tree | f33d42be24ea2ea9c4f1dc2c052997c37b847e7e | |
parent | f07c79d3709a7f81219abc3c516fd772f469c167 (diff) | |
download | numpy-6e91f0f59818c5bc9021f1913764bb667811fbcc.tar.gz |
second set of checkins from doc editor
-rw-r--r-- | doc/source/reference/arrays.classes.rst | 8 | ||||
-rw-r--r-- | doc/source/reference/arrays.ndarray.rst | 41 | ||||
-rw-r--r-- | doc/source/reference/c-api.array.rst | 2 | ||||
-rw-r--r-- | doc/source/reference/distutils.rst | 30 | ||||
-rw-r--r-- | doc/source/reference/routines.math.rst | 7 | ||||
-rw-r--r-- | doc/source/reference/ufuncs.rst | 2 | ||||
-rw-r--r-- | doc/source/user/index.rst | 19 | ||||
-rw-r--r-- | doc/source/user/whatisnumpy.rst | 156 | ||||
-rw-r--r-- | numpy/add_newdocs.py | 644 | ||||
-rw-r--r-- | numpy/core/code_generators/ufunc_docstrings.py | 84 |
10 files changed, 799 insertions, 194 deletions
diff --git a/doc/source/reference/arrays.classes.rst b/doc/source/reference/arrays.classes.rst index 6d5e7bde0..51d97e53a 100644 --- a/doc/source/reference/arrays.classes.rst +++ b/doc/source/reference/arrays.classes.rst @@ -230,8 +230,8 @@ Character arrays (:mod:`numpy.char`) .. 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_`, `string_` or - `unicode_`. + arrays of strings, use arrays of `dtype` `object_`, `str` or + `unicode`. These are enhanced arrays of either :class:`string_` type or :class:`unicode_` type. These arrays inherit from the @@ -242,7 +242,7 @@ character type. In addition, the :class:`chararray` has all of the standard :class:`string <str>` (and :class:`unicode`) methods, executing them on an element-by-element basis. Perhaps the easiest way to create a chararray is to use :meth:`self.view(chararray) -<ndarray.view>` where *self* is an ndarray of string or unicode +<ndarray.view>` where *self* is an ndarray of str or unicode data-type. However, a chararray can also be created using the :meth:`numpy.chararray` constructor, or via the :func:`numpy.char.array <core.defchararray.array>` function: @@ -253,7 +253,7 @@ data-type. However, a chararray can also be created using the chararray core.defchararray.array -Another difference with the standard ndarray of string data-type is +Another difference with the standard ndarray of str data-type is that the chararray inherits the feature introduced by Numarray that white-space at the end of any element in the array will be ignored on item retrieval and comparison operations. diff --git a/doc/source/reference/arrays.ndarray.rst b/doc/source/reference/arrays.ndarray.rst index 1bf7d1ac8..0cad2ac6e 100644 --- a/doc/source/reference/arrays.ndarray.rst +++ b/doc/source/reference/arrays.ndarray.rst @@ -120,6 +120,8 @@ strided scheme, and correspond to the strides: .. index:: single-segment, contiguous, non-contiguous +where :math:`d_j` = `self.itemsize * self.shape[j]`. + Both the C and Fortran orders are :term:`contiguous`, *i.e.,* :term:`single-segment`, memory layouts, in which every part of the memory block can be accessed by some combination of the indices. @@ -231,7 +233,7 @@ Array methods An :class:`ndarray` object has many methods which operate on or with the array in some fashion, typically returning an array result. These -methods are briefly explained below. (Each method's doc string has a +methods are briefly explained below. (Each method's docstring has a more complete description.) For the following methods there are also corresponding functions in @@ -317,11 +319,45 @@ Many of these methods take an argument named *axis*. In such cases, - If *axis* is *None* (the default), the array is treated as a 1-D array and the operation is performed over the entire array. This behavior is also the default if self is a 0-dimensional array or - array scalar. + array scalar. (An array scalar is an instance of the types/classes + float32, float64, etc., whereas a 0-dimensional 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 1-D subarray that can be created along the given axis). +.. admonition:: Example of the *axis* argument + + A 3-dimensional array of size 3 x 3 x 3, summed over each of its + three axes + + >>> x + array([[[ 0, 1, 2], + [ 3, 4, 5], + [ 6, 7, 8]], + [[ 9, 10, 11], + [12, 13, 14], + [15, 16, 17]], + [[18, 19, 20], + [21, 22, 23], + [24, 25, 26]]]) + >>> x.sum(axis=0) + array([[27, 30, 33], + [36, 39, 42], + [45, 48, 51]]) + >>> # for sum, axis is the first keyword, so we may omit it, + >>> # specifying only its value + >>> x.sum(0), x.sum(1), x.sum(2) + (array([[27, 30, 33], + [36, 39, 42], + [45, 48, 51]]), + array([[ 9, 12, 15], + [36, 39, 42], + [63, 66, 69]]), + array([[ 3, 12, 21], + [30, 39, 48], + [57, 66, 75]])) + The parameter *dtype* specifies the data type over which a reduction operation (like summing) should take place. The default reduce data type is the same as the data type of *self*. To avoid overflow, it can @@ -333,7 +369,6 @@ argument must be an :class:`ndarray` and have the same number of elements. It can have a different data type in which case casting will be performed. - .. autosummary:: :toctree: generated/ diff --git a/doc/source/reference/c-api.array.rst b/doc/source/reference/c-api.array.rst index 3716fa16b..49d073b7e 100644 --- a/doc/source/reference/c-api.array.rst +++ b/doc/source/reference/c-api.array.rst @@ -2372,7 +2372,7 @@ Other conversions signed and unsigned integers, floating point numbers, and complex-floating point numbers are recognized and converted. Other values of gentype are returned. This function can be used to - convert, for example, the string'f4' to :cdata:`NPY_FLOAT32`. + convert, for example, the string 'f4' to :cdata:`NPY_FLOAT32`. Miscellaneous diff --git a/doc/source/reference/distutils.rst b/doc/source/reference/distutils.rst index bb01a529a..63174c2c7 100644 --- a/doc/source/reference/distutils.rst +++ b/doc/source/reference/distutils.rst @@ -6,7 +6,7 @@ Packaging (:mod:`numpy.distutils`) NumPy provides enhanced distutils functionality to make it easier to build and install sub-packages, auto-generate code, and extension -modules that use Fortran-compiled libraries. To use features of numpy +modules that use Fortran-compiled libraries. To use features of NumPy distutils, use the :func:`setup <core.setup>` command from :mod:`numpy.distutils.core`. A useful :class:`Configuration <misc_util.Configuration>` class is also provided in @@ -33,7 +33,6 @@ misc_util Configuration get_numpy_include_dirs - get_numarray_include_dirs dict_append appendpath allpath @@ -128,13 +127,13 @@ Other modules Building Installable C libraries ================================ -Conventional C libraries (installed through add_library) are not installed, and +Conventional C libraries (installed through `add_library`) are not installed, and are just used during the build (they are statically linked). An installable C library is a pure C library, which does not depend on the python C runtime, and -is installed such as it may be used by third-party packages. To build and -install the C library, you just use the method add_installed_library instead of -add_library, which takes the same arguments except for an additional -install_dir argument:: +is installed such that it may be used by third-party packages. To build and +install the C library, you just use the method `add_installed_library` instead of +`add_library`, which takes the same arguments except for an additional +``install_dir`` argument:: >>> config.add_installed_library('foo', sources=['foo.c'], install_dir='lib') @@ -142,8 +141,8 @@ npy-pkg-config files -------------------- To make the necessary build options available to third parties, you could use -the npy-pkg-config mechanism implemented in numpy.distutils. This mechanism is -based on an .ini file which contains all the options. A .ini file is very +the `npy-pkg-config` mechanism implemented in `numpy.distutils`. This mechanism is +based on a .ini file which contains all the options. A .ini file is very similar to .pc files as used by the pkg-config unix utility:: [meta] @@ -162,7 +161,7 @@ similar to .pc files as used by the pkg-config unix utility:: Generally, the file needs to be generated during the build, since it needs some information known at build time only (e.g. prefix). This is mostly automatic if -one uses the Configuration method add_npy_pkg_config. Assuming we have a +one uses the `Configuration` method `add_npy_pkg_config`. Assuming we have a template file foo.ini.in as follows:: [meta] @@ -186,22 +185,23 @@ and the following code in setup.py:: >>> config.add_npy_pkg_config('foo.ini.in', 'lib', subst_dict=subst) This will install the file foo.ini into the directory package_dir/lib, and the -foo.ini file will be generated from foo.ini.in, where each @version@ will be -replaced by subst_dict['version']. The dictionary has an additional prefix +foo.ini file will be generated from foo.ini.in, where each ``@version@`` will be +replaced by ``subst_dict['version']``. The dictionary has an additional prefix substitution rule automatically added, which contains the install prefix (since this is not easy to get from setup.py). npy-pkg-config files can also be installed at the same location as used for numpy, using the path returned from -get_npy_pkg_dir function. +`get_npy_pkg_dir` function. Reusing a C library from another package ---------------------------------------- -Info are easily retrieved from the get_info function in numpy.distutils.misc_util:: +Info are easily retrieved from the `get_info` function in +`numpy.distutils.misc_util`:: >>> info = get_info('npymath') >>> config.add_extension('foo', sources=['foo.c'], extra_info=**info) -An additional list of paths to look for .ini files can be given to get_info. +An additional list of paths to look for .ini files can be given to `get_info`. Conversion of ``.src`` files ============================ diff --git a/doc/source/reference/routines.math.rst b/doc/source/reference/routines.math.rst index 326391292..7ce77c24d 100644 --- a/doc/source/reference/routines.math.rst +++ b/doc/source/reference/routines.math.rst @@ -19,6 +19,8 @@ Trigonometric functions degrees radians unwrap + deg2rad + rad2deg Hyperbolic functions -------------------- @@ -43,6 +45,7 @@ Rounding fix floor ceil + trunc Sums, products, differences --------------------------- @@ -67,10 +70,13 @@ Exponents and logarithms exp expm1 + exp2 log log10 log2 log1p + logaddexp + logaddexp2 Other special functions ----------------------- @@ -86,6 +92,7 @@ Floating point routines :toctree: generated/ signbit + copysign frexp ldexp diff --git a/doc/source/reference/ufuncs.rst b/doc/source/reference/ufuncs.rst index 59cdb71de..77269be58 100644 --- a/doc/source/reference/ufuncs.rst +++ b/doc/source/reference/ufuncs.rst @@ -313,7 +313,7 @@ possess. None of the attributes can be set. ============ ================================================================= **__doc__** A docstring for each ufunc. The first part of the docstring is dynamically generated from the number of outputs, the name, and - the number of inputs. The second part of the doc string is + the number of inputs. The second part of the docstring is provided at creation time and stored with the ufunc. **__name__** The name of the ufunc. diff --git a/doc/source/user/index.rst b/doc/source/user/index.rst index ed8e186a7..c365c0af3 100644 --- a/doc/source/user/index.rst +++ b/doc/source/user/index.rst @@ -1,20 +1,23 @@ .. _user: ################ -Numpy User Guide +NumPy User Guide ################ -This guide explains how to make use of different features -of Numpy. For a detailed documentation about different functions -and classes, see :ref:`reference`. +This guide is intended as an introductory overview of NumPy and +explains how to install and make use of the most important features of +NumPy. For detailed reference documentation of the functions and +classes contained in the package, see the :ref:`reference`. .. warning:: - This "User Guide" is still very much work in progress; the material - is not organized, and many aspects of Numpy are not covered. + This "User Guide" is still a work in progress; some of the material + is not organized, and several aspects of NumPy are not yet covered + in sufficient detail. However, we are continually working to + improve the documentation. - More documentation for Numpy can be found on the - `scipy.org <http://www.scipy.org/Documentation>`__ website. + More documentation for NumPy can be found on the `numpy.org + <http://www.numpy.org>`__ website. .. toctree:: :maxdepth: 2 diff --git a/doc/source/user/whatisnumpy.rst b/doc/source/user/whatisnumpy.rst index 3a9abb79d..1c3f96b8b 100644 --- a/doc/source/user/whatisnumpy.rst +++ b/doc/source/user/whatisnumpy.rst @@ -2,52 +2,59 @@ What is NumPy? ************** -NumPy is the fundamental package for scientific computing in Python. It is a -Python library that provides a multidimensional array object, various derived -objects (such as masked arrays and matrices), and an assortment of routines -for fast operations on arrays, including mathematical, logical, shape -manipulation, sorting, I/O, discrete Fourier transform, basic linear algebra, -basic statistical and random simulation, etc., etc., etc. - -The core of the NumPy package, however, is the `ndarray` object. This -encapsulates *n*-dimensional arrays of homogeneous data. There are several -important differences between NumPy arrays and the standard Python sequences: - -- Unlike Python lists, NumPy arrays have a fixed size - changing their size - *will* create a new array and delete the original. - -- Unlike Python tuples, the elements in a NumPy array are all required to be - the same data type, and thus *will* be the same size in memory. The - exception: one can have arrays of (Python, including NumPy) objects, thereby +NumPy is the fundamental package for scientific computing in Python. +It is a Python library that provides a multidimensional array object, +various derived objects (such as masked arrays and matrices), and an +assortment of routines for fast operations on arrays, including +mathematical, logical, shape manipulation, sorting, selecting, I/O, +discrete Fourier transforms, basic linear algebra, basic statistical +operations, random simulation and much more. + +At the core of the NumPy package, is the `ndarray` object. This +encapsulates *n*-dimensional arrays of homogeneous data types, with +many operations being performed in compiled code for performance. +There are several important differences between NumPy arrays and the +standard Python sequences: + +- NumPy arrays have a fixed size at creation, unlike Python lists + (which can grow dynamically). Changing the size of an `ndarray` will + create a new array and delete the original. + +- The elements in a NumPy array are all required to be of the same + data type, and thus will be the same size in memory. The exception: + one can have arrays of (Python, including NumPy) objects, thereby allowing for arrays of different sized elements. -- NumPy arrays facilitate advanced mathematical and other types of operations - on large amounts of data. Typically, such operations are executed much - faster and with less code compared to what is possible using Python's - built-in sequences. +- NumPy arrays facilitate advanced mathematical and other types of + operations on large numbers of data. Typically, such operations are + executed more efficiently and with less code than is possible using + Python's built-in sequences. -- A growing plethora of scientific and mathematical Python-based packages are - keyed to using NumPy arrays; though these typically support Python-sequence - input, they convert such input to NumPy arrays prior to processing, and they - output NumPy arrays. In other words, in order to *efficiently* use much - (perhaps even most) of today's scientific/mathematical Python-based software, just - knowing how to use Python's built-in sequence types is insufficient - one - also needs to know how to use NumPy arrays. +- A growing plethora of scientific and mathematical Python-based + packages are using NumPy arrays; though these typically support + Python-sequence input, they convert such input to NumPy arrays prior + to processing, and they often output NumPy arrays. In other words, + in order to efficiently use much (perhaps even most) of today's + scientific/mathematical Python-based software, just knowing how to + use Python's built-in sequence types is insufficient - one also + needs to know how to use NumPy arrays. The points about sequence size and speed are particularly important in -scientific computing. For a simple example, consider the case of multiplying -every element in a 1-D sequence with the corresponding element in another -sequence of the same length. If the data are in two Python lists, ``a`` and -``b``, we could iterate over each element:: +scientific computing. As a simple example, consider the case of +multiplying each element in a 1-D sequence with the corresponding +element in another sequence of the same length. If the data are +stored in two Python lists, ``a`` and ``b``, we could iterate over +each element:: c = [] for i in range(len(a)): c.append(a[i]*b[i]) -This gives the right answer, but if ``a`` and ``b`` each contain millions of -numbers, we will be waiting a rather long time fot it. We could accomplish -the same task much more quickly in C by writing (neglecting variable -declarations and initializations, memory allocation, etc.) +This produces the correct answer, but if ``a`` and ``b`` each contain +millions of numbers, we will pay the price for the inefficiencies of +looping in Python. We could accomplish the same task much more +quickly in C by writing (for clarity we neglect variable declarations +and initializations, memory allocation, etc.) :: @@ -55,11 +62,11 @@ declarations and initializations, memory allocation, etc.) c[i] = a[i]*b[i]; } -This saves all the overhead involved in interpreting the Python code and -manipulating Python objects, but at the expense of our beloved Python benefits. -Furthermore, the coding work required increases with the dimensionality of our -data. In the case of a 2-D array, for example, the C code (abridged as before) -expands to +This saves all the overhead involved in interpreting the Python code +and manipulating Python objects, but at the expense of the benefits +gained from coding in Python. Furthermore, the coding work required +increases with the dimensionality of our data. In the case of a 2-D +array, for example, the C code (abridged as before) expands to :: @@ -69,9 +76,10 @@ expands to } } -NumPy gives us the best of both worlds: such element-by-element operation is -the "default mode" when an `ndarray` is involved, but the element-by-element -operation is speedily executed by pre-compiled C code. In NumPy +NumPy gives us the best of both worlds: element-by-element operations +are the "default mode" when an `ndarray` is involved, but the +element-by-element operation is speedily executed by pre-compiled C +code. In NumPy :: @@ -79,42 +87,42 @@ operation is speedily executed by pre-compiled C code. In NumPy does what the earlier examples do, at near-C speeds, but with the code simplicity we expect from something based on Python (indeed, the NumPy -idiom is even simpler!) This last example illustrates two of NumPy's +idiom is even simpler!). This last example illustrates two of NumPy's features which are the basis of much of its power: vectorization and broadcasting. -Vectorization describes the absence of any *explicit* looping, indexing, etc., -in the code - these things are taking place, of course, just "behind the -scenes" (in optimized, pre-compiled C code). Vectorized code has many -advantages, among which are: +Vectorization describes the absence of any explicit looping, indexing, +etc., in the code - these things are taking place, of course, just +"behind the scenes" (in optimized, pre-compiled C code). Vectorized +code has many advantages, among which are: - vectorized code is more concise and easier to read - fewer lines of code generally means fewer bugs -- the code more closely resembles standard mathematical notation (making it - easier, typically, to correctly code written mathematics) - -- vectorization results in more "Pythonic" code (without vectorization, our - code would still be littered with ``for`` loops; though of course not absent - in Python, generally speaking, we feel that if we have to use a ``for`` loop - in Python, we must be doing something wrong!) :-) - -Broadcasting, on the other hand, is the term used to describe the *implicit* -element-by-element behavior of operations; generally speaking, in NumPy all -"operations" (i.e., not just arithmetic operations, but logical, bit-wise, -function, etc.) behave in this implicit element-by-element fashion, i.e., they -"broadcast." Moreover, in the example above, ``a`` and ``b`` could be -multidimensional arrays of the same shape, or a scalar and an array, or even -two arrays of different shapes, as long as the smaller one is "expandable" to +- the code more closely resembles standard mathematical notation + (making it easier, typically, to correctly code mathematical + constructs) + +- vectorization results in more "Pythonic" code (without + vectorization, our code would still be littered with inefficient and + difficult to read ``for`` loops. + +Broadcasting is the term used to describe the implicit +element-by-element behavior of operations; generally speaking, in +NumPy all operations (i.e., not just arithmetic operations, but +logical, bit-wise, functional, etc.) behave in this implicit +element-by-element fashion, i.e., they broadcast. Moreover, in the +example above, ``a`` and ``b`` could be multidimensional arrays of the +same shape, or a scalar and an array, or even two arrays of with +different shapes. Provided that the smaller array is "expandable" to the shape of the larger in such a way that the resulting broadcast is -unambiguous and "makes sense" (the detailed "rules" of broadcasting are -described in `numpy.doc.broadcasting`). - -Finally, in tune with the rest of Python, NumPy fully supports an -object-oriented approach, starting, once again, with `ndarray`. -Unexceptionally, `ndarray` is a class, possessing many, *many* attributes, -both method and "other." Many, if not all, of its attributes duplicate -(indeed, call) functions in the outer-most NumPy namespace, so the programmer -has complete freedom to code in whichever paradigm she prefers and/or that -seems most appropriate to the task at hand. +unambiguous (for detailed "rules" of broadcasting see +`numpy.doc.broadcasting`). + +NumPy fully supports an object-oriented approach, starting, once +again, with `ndarray`. For example, `ndarray` is a class, possessing +numerous methods and attributes. Many, of it's methods mirror +functions in the outer-most NumPy namespace, giving the programmer has +complete freedom to code in whichever paradigm she prefers and/or +which seems most appropriate to the task at hand. diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index 4cd2984cc..711c25e42 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -594,7 +594,7 @@ add_newdoc('numpy.core.multiarray', 'fromfile', Parameters ---------- - file : file or string + file : file or str Open file object or filename. dtype : data-type Data type of the returned array. @@ -603,7 +603,7 @@ add_newdoc('numpy.core.multiarray', 'fromfile', count : int Number of items to read. ``-1`` means all items (i.e., the complete file). - sep : string + sep : str Separator between items if file is a text file. Empty ("") separator means the file should be treated as binary. Spaces (" ") in the separator match zero or more whitespace characters. @@ -1644,11 +1644,11 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('ctypes', Be careful using the ctypes attribute - especially on temporary arrays or arrays constructed on the fly. For example, calling - (a+b).ctypes.data_as(ctypes.c_void_p) returns a pointer to memory + ``(a+b).ctypes.data_as(ctypes.c_void_p)`` returns a pointer to memory that is invalid because the array created as (a+b) is deallocated before the next Python statement. You can avoid this problem using - either c=a+b or ct=(a+b).ctypes. In the latter case, ct will hold - a reference to the array until ct is deleted or re-assigned. + either ``c=a+b`` or ``ct=(a+b).ctypes``. In the latter case, ct will + hold a reference to the array until ct is deleted or re-assigned. If the ctypes module is not available, then the ctypes attribute of array objects still returns something useful, but ctypes objects @@ -1962,6 +1962,9 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('strides', offset = sum(np.array(i) * a.strides) + A more detailed explanation of strides can be found in the + "ndarray.rst" file in the NumPy reference guide. + Notes ----- Imagine an array of 32-bit integers (each 4 bytes):: @@ -2303,27 +2306,11 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('conj', Complex-conjugate all elements. - Parameters - ---------- - None - - Returns - ------- - conj : ndarray - A new array of the same size and shape as `a` each of whose - elements are the complex-conjugates of the positionally - respective elements of `a`. + Refer to `numpy.conjugate` for full documentation. - Examples + See Also -------- - >>> x = np.eye(2) + 1j * np.eye(2) - >>> x - array([[ 1.+1.j, 0.+0.j], - [ 0.+0.j, 1.+1.j]]) - >>> y = x.conj() - >>> y - array([[ 1.-1.j, 0.+0.j], - [ 0.+0.j, 1.-1.j]]) + numpy.conjugate : equivalent function """)) @@ -3998,6 +3985,9 @@ add_newdoc('numpy.core', 'ufunc', """ Functions that operate element by element on whole arrays. + A detailed explanation of ufuncs can be found in the "ufuncs.rst" + file in the NumPy reference guide. + Unary ufuncs: ============= @@ -4007,41 +3997,42 @@ add_newdoc('numpy.core', 'ufunc', Parameters ---------- X : array_like - Input array + Input array. out : array_like - An array to store the output. Must be the same shape as X. + An array to store the output. Must be the same shape as `X`. Returns ------- r : array_like - r will have the same shape as X; if out is provided, r will be - equal to out. + `r` will have the same shape as `X`; if out is provided, `r` + will be equal to out. Binary ufuncs: ============== op(X, Y, out=None) - Apply op to X and Y elementwise. May "broadcast" to make - the shapes of X and Y congruent. + Apply `op` to `X` and `Y` elementwise. May "broadcast" to make + the shapes of `X` and `Y` congruent. The broadcasting rules are: - * Dimensions of length 1 may be prepended to either array - * Arrays may be repeated along dimensions of length 1 + + * Dimensions of length 1 may be prepended to either array. + * Arrays may be repeated along dimensions of length 1. Parameters ---------- X : array_like - First input array + First input array. Y : array_like - Second input array - out : array-like + Second input array. + out : array_like An array to store the output. Must be the same shape as the output would have. Returns ------- - r : array-like - The return value; if out is provided, r will be equal to out. + r : array_like + The return value; if out is provided, `r` will be equal to out. """) @@ -4934,9 +4925,12 @@ add_newdoc('numpy.lib.index_tricks', 'mgrid', See Also -------- - numpy.lib.index_tricks.nd_grid : class of `ogrid` and `mgrid` objects - ogrid : like mgrid but returns open (not fleshed out) mesh grids - r_ : array concatenator + numpy.lib.index_tricks.nd_grid : + class of `ogrid` and `mgrid` objects + ogrid : + like mgrid but returns open (not fleshed out) mesh grids + + `r_` : array concatenator Examples -------- @@ -5004,173 +4998,439 @@ add_newdoc('numpy.lib.index_tricks', 'ogrid', add_newdoc('numpy.core.numerictypes', 'generic', """ + Base class for numpy scalar types. + + Class from which most (all?) numpy scalar types are derived. For + consistency, exposes the same API as `ndarray`, despite many + consequent attributes being either "get-only," or completely irrelevant. + This is the class from which it is strongly suggested users should derive + custom scalar types. + """) # Attributes add_newdoc('numpy.core.numerictypes', 'generic', ('T', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class so as to + provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('base', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class so as to + a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('data', - """ - """)) + """Pointer to start of data.""")) add_newdoc('numpy.core.numerictypes', 'generic', ('dtype', - """ - """)) + """Get array data-descriptor.""")) add_newdoc('numpy.core.numerictypes', 'generic', ('flags', - """ - """)) + """The integer value of flags.""")) add_newdoc('numpy.core.numerictypes', 'generic', ('flat', - """ - """)) + """A 1-D view of the scalar.""")) add_newdoc('numpy.core.numerictypes', 'generic', ('imag', - """ - """)) + """The imaginary part of the scalar.""")) add_newdoc('numpy.core.numerictypes', 'generic', ('itemsize', - """ - """)) + """The length of one element in bytes.""")) add_newdoc('numpy.core.numerictypes', 'generic', ('nbytes', - """ - """)) + """The length of the scalar in bytes.""")) add_newdoc('numpy.core.numerictypes', 'generic', ('ndim', - """ - """)) + """The number of array dimensions.""")) add_newdoc('numpy.core.numerictypes', 'generic', ('real', - """ - """)) + """The real part of the scalar.""")) add_newdoc('numpy.core.numerictypes', 'generic', ('shape', - """ - """)) + """Tuple of array dimensions.""")) add_newdoc('numpy.core.numerictypes', 'generic', ('size', - """ - """)) + """The number of elements in the gentype.""")) add_newdoc('numpy.core.numerictypes', 'generic', ('strides', - """ - """)) + """Tuple of bytes steps in each dimension.""")) # Methods add_newdoc('numpy.core.numerictypes', 'generic', ('all', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class + so as to provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('any', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class + so as to provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('argmax', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class + so as to provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('argmin', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class + so as to provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('argsort', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class + so as to provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('astype', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class + so as to provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('byteswap', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class so as to + provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('choose', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class + so as to provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('clip', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class + so as to provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('compress', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class + so as to provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('conjugate', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class + so as to provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('copy', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class + so as to provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('cumprod', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class + so as to provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('cumsum', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class + so as to provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('diagonal', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class + so as to provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('dump', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class + so as to provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('dumps', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class + so as to provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('fill', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class + so as to provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('flatten', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class + so as to provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('getfield', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class + so as to provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('item', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class + so as to provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('itemset', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class + so as to provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('max', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class + so as to provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('mean', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class + so as to provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('min', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class + so as to provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('newbyteorder', """ newbyteorder(new_order='S') - Return a new dtype with a different byte order. + Return a new `dtype` with a different byte order. Changes are also made in all fields and sub-arrays of the data type. @@ -5184,7 +5444,7 @@ add_newdoc('numpy.core.numerictypes', 'generic', ('newbyteorder', Parameters ---------- - new_order : string, optional + new_order : str, optional Byte order to force; a value from the byte order specifications above. The default value ('S') results in swapping the current byte order. The code does a case-insensitive check on the first @@ -5195,108 +5455,358 @@ add_newdoc('numpy.core.numerictypes', 'generic', ('newbyteorder', Returns ------- new_dtype : dtype - New dtype object with the given change to the byte order. + New `dtype` object with the given change to the byte order. """)) add_newdoc('numpy.core.numerictypes', 'generic', ('nonzero', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class + so as to provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('prod', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class + so as to provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('ptp', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class + so as to provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('put', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class + so as to provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('ravel', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class + so as to provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('repeat', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class + so as to provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('reshape', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class + so as to provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('resize', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class + so as to provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('round', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class + so as to provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('searchsorted', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class + so as to provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('setfield', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class + so as to provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('setflags', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class so as to + provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('sort', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class + so as to provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('squeeze', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class + so as to provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('std', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class + so as to provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('sum', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class + so as to provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('swapaxes', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class + so as to provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('take', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class + so as to provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('tofile', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class + so as to provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('tolist', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class + so as to provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('tostring', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class + so as to provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('trace', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class + so as to provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('transpose', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class + so as to provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('var', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class + so as to provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) add_newdoc('numpy.core.numerictypes', 'generic', ('view', """ + Not implemented (virtual attribute) + + Class generic exists solely to derive numpy scalars from, and possesses, + albeit unimplemented, all the attributes of the ndarray class + so as to provide a uniform API. + + See Also + -------- + The corresponding attribute of the derived class of interest. + """)) diff --git a/numpy/core/code_generators/ufunc_docstrings.py b/numpy/core/code_generators/ufunc_docstrings.py index ad5fccfc0..4adbf2376 100644 --- a/numpy/core/code_generators/ufunc_docstrings.py +++ b/numpy/core/code_generators/ufunc_docstrings.py @@ -268,6 +268,9 @@ add_newdoc('numpy.core.umath', 'arcsinh', ---------- x : array_like Input array. + out : ndarray, optional + Array into which the output is placed. Its type is preserved and it + must be of the right shape to hold the output. See `doc.ufuncs`. Returns ------- @@ -557,6 +560,9 @@ add_newdoc('numpy.core.umath', 'bitwise_or', ---------- x1, x2 : array_like Only integer types are handled (including booleans). + out : ndarray, optional + Array into which the output is placed. Its type is preserved and it + must be of the right shape to hold the output. See doc.ufuncs. Returns ------- @@ -735,6 +741,11 @@ add_newdoc('numpy.core.umath', 'conjugate', >>> np.conjugate(1+2j) (1-2j) + >>> x = np.eye(2) + 1j * np.eye(2) + >>> np.conjugate(x) + array([[ 1.-1.j, 0.-0.j], + [ 0.-0.j, 1.-1.j]]) + """) add_newdoc('numpy.core.umath', 'cos', @@ -829,7 +840,7 @@ add_newdoc('numpy.core.umath', 'degrees', Returns ------- - y : ndarray + y : ndarray of floats The corresponding degree values. See Also @@ -845,8 +856,10 @@ add_newdoc('numpy.core.umath', 'degrees', array([ 0., 30., 60., 90., 120., 150., 180., 210., 240., 270., 300., 330.]) - >>> foo = np.zeros((rad.shape)) - >>> degrees(rad, foo) + >>> out = np.zeros((rad.shape)) + >>> r = degrees(rad, out) + >>> np.all(r == out) + True """) @@ -858,6 +871,9 @@ add_newdoc('numpy.core.umath', 'rad2deg', ---------- x : array_like Angle in radians. + out : ndarray, optional + Array into which the output is placed. Its type is preserved and it + must be of the right shape to hold the output. See doc.ufuncs. Returns ------- @@ -892,6 +908,9 @@ add_newdoc('numpy.core.umath', 'divide', Dividend array. x2 : array_like Divisor array. + out : ndarray, optional + Array into which the output is placed. Its type is preserved and it + must be of the right shape to hold the output. See doc.ufuncs. Returns ------- @@ -1130,6 +1149,9 @@ add_newdoc('numpy.core.umath', 'fabs', x : array_like The array of numbers for which the absolute values are required. If `x` is a scalar, the result `y` will also be a scalar. + out : ndarray, optional + Array into which the output is placed. Its type is preserved and it + must be of the right shape to hold the output. See doc.ufuncs. Returns ------- @@ -1243,8 +1265,8 @@ add_newdoc('numpy.core.umath', 'fmod', ----- The result of the modulo operation for negative dividend and divisors is bound by conventions. In `fmod`, the sign of the remainder is the sign of - the dividend: in contrast to `remainder`, the sign of the divisor has no - influence on the sign of the result. + the dividend. In `remainder`, the sign of the divisor does not affect the + sign of the result. Examples -------- @@ -2531,8 +2553,10 @@ add_newdoc('numpy.core.umath', 'radians', 2.61799388, 3.14159265, 3.66519143, 4.1887902 , 4.71238898, 5.23598776, 5.75958653]) - >>> foo = np.zeros((deg.shape)) - >>> radians(deg, foo) + >>> out = np.zeros((deg.shape)) + >>> ret = np.radians(deg, out) + >>> ret is out + True """) @@ -2606,7 +2630,7 @@ add_newdoc('numpy.core.umath', 'remainder', """ Return element-wise remainder of division. - Computes ``x1 - floor(x1/x2)*x2``. + Computes ``x1 - floor(x1 / x2) * x2``. Parameters ---------- @@ -2614,6 +2638,9 @@ add_newdoc('numpy.core.umath', 'remainder', Dividend array. x2 : array_like Divisor array. + out : ndarray, optional + Array into which the output is placed. Its type is preserved and it + must be of the right shape to hold the output. See doc.ufuncs. Returns ------- @@ -2631,7 +2658,7 @@ add_newdoc('numpy.core.umath', 'remainder', Examples -------- - >>> np.remainder([4,7], [2,3]) + >>> np.remainder([4, 7], [2, 3]) array([0, 1]) >>> np.remainder(np.arange(7), 5) array([0, 1, 2, 3, 4, 0, 1]) @@ -2737,11 +2764,14 @@ add_newdoc('numpy.core.umath', 'signbit', ---------- x: array_like The input value(s). + out : ndarray, optional + Array into which the output is placed. Its type is preserved + and it must be of the right shape to hold the output. See doc.ufuncs. Returns ------- out : array_like, bool - Output. + Output array. Examples -------- @@ -2766,6 +2796,9 @@ add_newdoc('numpy.core.umath', 'copysign', Values to change the sign of. x2: array_like The sign of `x2` is copied to `x1`. + out : ndarray, optional + Array into which the output is placed. Its type is preserved and it + must be of the right shape to hold the output. See doc.ufuncs. Returns ------- @@ -2791,14 +2824,17 @@ add_newdoc('numpy.core.umath', 'copysign', add_newdoc('numpy.core.umath', 'nextafter', """ Return the next representable floating-point value after x1 in the direction - of y1 element-wise. + of x2 element-wise. Parameters ---------- - x1: array_like + x1 : array_like Values to find the next representable value of. - x2: array_like + x2 : array_like The direction where to look for the next representable value of `x1`. + out : ndarray, optional + Array into which the output is placed. Its type is preserved and it + must be of the right shape to hold the output. See `doc.ufuncs`. Returns ------- @@ -2807,8 +2843,12 @@ add_newdoc('numpy.core.umath', 'nextafter', Examples -------- - >>> np.nextrepresentable(1, 2) - 1 == np.finfo(np.float64).eps + >>> eps = np.finfo(np.float64).eps + >>> np.nextafter(1, 2) == eps + 1 True + >>> np.nextafter([1, 2], [2, 1]) == [eps + 1, 2 - eps] + array([ True, True], dtype=bool) + """) add_newdoc('numpy.core.umath', 'spacing', @@ -2825,18 +2865,20 @@ add_newdoc('numpy.core.umath', 'spacing', out : array_like The spacing of values of `x1`. + Notes + ----- + It can be considered as a generalization of EPS: + ``spacing(np.float64(1)) == np.finfo(np.float64).eps``, and there + should not be any representable number between ``x + spacing(x)`` and + x for any finite x. + + Spacing of +- inf and nan is nan. + Examples -------- >>> np.spacing(1, 2) == np.finfo(np.float64).eps True - Note - ---- - It can be considered as a generalization of EPS: spacing(np.float64(1)) == - np.finfo(np.float64).eps, and there should not be any representable number - between x + spacing(x) and x for any finite x. - - spacing of +- inf and nan is nan. """) add_newdoc('numpy.core.umath', 'sin', |