From 5be67675762180503e1b3c4824d2009d3614f181 Mon Sep 17 00:00:00 2001 From: Jaime Fernandez Date: Sat, 30 May 2015 14:19:07 -0700 Subject: DOC: Better document 'order' argument of 'sort' and friends Closes #5927 --- numpy/add_newdocs.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'numpy/add_newdocs.py') diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index 55bcf8ee1..b0306957e 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -4191,10 +4191,12 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('sort', last axis. kind : {'quicksort', 'mergesort', 'heapsort'}, optional Sorting algorithm. Default is 'quicksort'. - order : list, optional + order : str or list of str, optional When `a` is an array with fields defined, this argument specifies - which fields to compare first, second, etc. Not all fields need be - specified. + which fields to compare first, second, etc. A single field can + be specified as a string, and not all fields need be specified, + but unspecified fields will still be used, in the order in which + they come up in the dtype, to break ties. See Also -------- @@ -4258,10 +4260,12 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('partition', last axis. kind : {'introselect'}, optional Selection algorithm. Default is 'introselect'. - order : list, optional + order : str or list of str, optional When `a` is an array with fields defined, this argument specifies - which fields to compare first, second, etc. Not all fields need be - specified. + which fields to compare first, second, etc. A single field can + be specified as a string, and not all fields need be specified, + but unspecified fields will still be used, in the order in which + they come up in the dtype, to break ties. See Also -------- -- cgit v1.2.1 From 91e8cd29c93ec310b0665e6c3a823c3f095fc516 Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Sat, 30 May 2015 16:24:49 -0600 Subject: DOC: Document '@' and matmul. Document the matmul function and add '@' to the operator section of the reference manual. --- numpy/add_newdocs.py | 127 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 126 insertions(+), 1 deletion(-) (limited to 'numpy/add_newdocs.py') diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index b0306957e..11a2688e5 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -1943,6 +1943,7 @@ add_newdoc('numpy.core', 'dot', vdot : Complex-conjugating dot product. tensordot : Sum products over arbitrary axes. einsum : Einstein summation convention. + matmul : '@' operator as method with out parameter. Examples -------- @@ -1954,7 +1955,7 @@ add_newdoc('numpy.core', 'dot', >>> np.dot([2j, 3j], [2j, 3j]) (-13+0j) - For 2-D arrays it's the matrix product: + For 2-D arrays it is the matrix product: >>> a = [[1, 0], [0, 1]] >>> b = [[4, 1], [2, 2]] @@ -1971,6 +1972,130 @@ add_newdoc('numpy.core', 'dot', """) +add_newdoc('numpy.core', 'matmul', + """ + matmul(a, b, out=None) + + Matrix product of two arrays. + + The behavior depends on the arguments in the following way. + + - If both arguments are 2-D they are multiplied like conventional + matrices. + - If either argument is N-D, N > 2, it is treated as a stack of + matrices residing in the last two indexes and broadcast accordingly. + - If the first argument is 1-D, it is promoted to a matrix by + prepending a 1 to its dimensions. After matrix multiplication + the prepended 1 is removed. + - If the second argument is 1-D, it is promoted to a matrix by + appending a 1 to its dimensions. After matrix multiplication + the appended 1 is removed. + + Multiplication by a scalar is not allowed, use ``*`` instead. Note that + multiplying a stack of matrices with a vector will result in a stack of + vectors, but matmul will not recognize it as such. + + ``matmul`` differs from ``dot`` in two important ways. + + - Multiplication by scalars is not allowed. + - Stacks of matrices are broadcast together as if the matrices + were elements. + + .. warning:: + This function is preliminary and included in Numpy 1.10 for testing + and documentation. Its semantics will not change, but the number and + order of the optional arguments will. + + .. versionadded:: 1.10.0 + + Parameters + ---------- + a : array_like + First argument. + b : array_like + Second argument. + out : ndarray, optional + Output argument. This must have the exact kind that would be returned + if it was not used. In particular, it must have the right type, must be + C-contiguous, and its dtype must be the dtype that would be returned + for `dot(a,b)`. This is a performance feature. Therefore, if these + conditions are not met, an exception is raised, instead of attempting + to be flexible. + + Returns + ------- + output : ndarray + Returns the dot product of `a` and `b`. If `a` and `b` are both + 1-D arrays then a scalar is returned; otherwise an array is + returned. If `out` is given, then it is returned. + + Raises + ------ + ValueError + If the last dimension of `a` is not the same size as + the second-to-last dimension of `b`. + + If scalar value is passed. + + See Also + -------- + vdot : Complex-conjugating dot product. + tensordot : Sum products over arbitrary axes. + einsum : Einstein summation convention. + dot : alternative matrix product with different broadcasting rules. + + Notes + ----- + The matmul function implements the semantics of the `@` operator introduced + in Python 3.5 following PEP465. + + Examples + -------- + For 2-D arrays it is the matrix product: + + >>> a = [[1, 0], [0, 1]] + >>> b = [[4, 1], [2, 2]] + >>> np.matmul(a, b) + array([[4, 1], + [2, 2]]) + + For 2-D mixed with 1-D, the result is the usual. + + >>> a = [[1, 0], [0, 1]] + >>> b = [1, 2] + >>> np.matmul(a, b) + array([1, 2]) + >>> np.matmul(b, a) + array([1, 2]) + + + Broadcasting is conventional for stacks of arrays + + >>> a = np.arange(2*2*4).reshape((2,2,4)) + >>> b = np.arange(2*2*4).reshape((2,4,2)) + >>> np.matmul(a,b).shape + (2, 2, 2) + >>> np.matmul(a,b)[0,1,1] + 98 + >>> sum(a[0,1,:] * b[0,:,1]) + 98 + + Vector, vector returns the scalar inner product, but neither argument + is complex-conjugated: + + >>> np.matmul([2j, 3j], [2j, 3j]) + (-13+0j) + + Scalar multiplication raises an error. + + >>> np.matmul([1,2], 3) + Traceback (most recent call last): + ... + ValueError: Scalar operands are not allowed, use '*' instead + + """) + + add_newdoc('numpy.core', 'einsum', """ einsum(subscripts, *operands, out=None, dtype=None, order='K', casting='safe') -- cgit v1.2.1 From 4e5545f0bcc654fb0c6752dcf72120e6e7340d28 Mon Sep 17 00:00:00 2001 From: Gabor Kovacs Date: Sat, 23 Aug 2014 17:50:10 +0100 Subject: DOC: Update docs. Update docs for boolean array indexing and nonzero order. Add links to row-major and column-major terms where they appear. Closes #3177 --- numpy/add_newdocs.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'numpy/add_newdocs.py') diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index 11a2688e5..75f88a85f 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -28,9 +28,9 @@ add_newdoc('numpy.core', 'flatiter', It allows iterating over the array as if it were a 1-D array, either in a for-loop or by calling its `next` method. - Iteration is done in C-contiguous style, with the last index varying the - fastest. The iterator can also be indexed using basic slicing or - advanced indexing. + Iteration is done in row-major, C-style order (the last + index varying the fastest). The iterator can also be indexed using + basic slicing or advanced indexing. See Also -------- @@ -745,8 +745,9 @@ add_newdoc('numpy.core.multiarray', 'empty', dtype : data-type, optional Desired output data-type. order : {'C', 'F'}, optional - Whether to store multi-dimensional data in C (row-major) or - Fortran (column-major) order in memory. + Whether to store multi-dimensional data in row-major + (C-style) or column-major (Fortran-style) order in + memory. Returns ------- @@ -2419,7 +2420,7 @@ add_newdoc('numpy.core.multiarray', 'ndarray', strides : tuple of ints, optional Strides of data in memory. order : {'C', 'F'}, optional - Row-major or column-major order. + Row-major (C-style) or column-major (Fortran-style) order. Attributes ---------- @@ -3564,9 +3565,9 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('flatten', Parameters ---------- order : {'C', 'F', 'A'}, optional - Whether to flatten in C (row-major), Fortran (column-major) order, - or preserve the C/Fortran ordering from `a`. - The default is 'C'. + Whether to flatten in row-major (C-style) or + column-major (Fortran-style) order or preserve the + C/Fortran ordering from `a`. The default is 'C'. Returns ------- @@ -5144,8 +5145,9 @@ add_newdoc('numpy.core.multiarray', 'ravel_multi_index', In 'clip' mode, a negative index which would normally wrap will clip to 0 instead. order : {'C', 'F'}, optional - Determines whether the multi-index should be viewed as indexing in - C (row-major) order or FORTRAN (column-major) order. + Determines whether the multi-index should be viewed as + indexing in row-major (C-style) or column-major + (Fortran-style) order. Returns ------- @@ -5194,9 +5196,8 @@ add_newdoc('numpy.core.multiarray', 'unravel_index', The shape of the array to use for unraveling ``indices``. order : {'C', 'F'}, optional .. versionadded:: 1.6.0 - Determines whether the indices should be viewed as indexing in - C (row-major) order or FORTRAN (column-major) order. + row-major (C-style) or column-major (Fortran-style) order. Returns ------- -- cgit v1.2.1 From 1393a575c58f1ba86b1684ba9677ad134d057a93 Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Wed, 1 Jul 2015 13:18:22 -0600 Subject: DOC: Remove references to removed setasflat ndarray method. --- numpy/add_newdocs.py | 31 ------------------------------- 1 file changed, 31 deletions(-) (limited to 'numpy/add_newdocs.py') diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index 75f88a85f..be32d0cfa 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -3736,37 +3736,6 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('itemset', """)) -add_newdoc('numpy.core.multiarray', 'ndarray', ('setasflat', - """ - a.setasflat(arr) - - Equivalent to a.flat = arr.flat, but is generally more efficient. - This function does not check for overlap, so if ``arr`` and ``a`` - are viewing the same data with different strides, the results will - be unpredictable. - - Parameters - ---------- - arr : array_like - The array to copy into a. - - Examples - -------- - >>> a = np.arange(2*4).reshape(2,4)[:,:-1]; a - array([[0, 1, 2], - [4, 5, 6]]) - >>> b = np.arange(3*3, dtype='f4').reshape(3,3).T[::-1,:-1]; b - array([[ 2., 5.], - [ 1., 4.], - [ 0., 3.]], dtype=float32) - >>> a.setasflat(b) - >>> a - array([[2, 5, 1], - [4, 0, 3]]) - - """)) - - add_newdoc('numpy.core.multiarray', 'ndarray', ('max', """ a.max(axis=None, out=None) -- cgit v1.2.1 From f5e9adbbf87903e42d03bb3dd5f86b70a89e930c Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Wed, 1 Jul 2015 23:36:38 -0600 Subject: DOC: Fix docstring warnings in documetation generation. Most of these fixes involve putting blank lines around .. versionadded:: x.x.x and .. deprecated:: x.x.x Some of the examples were also fixed. --- numpy/add_newdocs.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'numpy/add_newdocs.py') diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index be32d0cfa..a6d7dc32e 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -790,14 +790,16 @@ add_newdoc('numpy.core.multiarray', 'empty_like', The shape and data-type of `a` define these same attributes of the returned array. dtype : data-type, optional - .. versionadded:: 1.6.0 Overrides the data type of the result. - order : {'C', 'F', 'A', or 'K'}, optional + .. versionadded:: 1.6.0 + order : {'C', 'F', 'A', or 'K'}, optional Overrides the memory layout of the result. 'C' means C-order, 'F' means F-order, 'A' means 'F' if ``a`` is Fortran contiguous, 'C' otherwise. 'K' means match the layout of ``a`` as closely as possible. + + .. versionadded:: 1.6.0 subok : bool, optional. If True, then the newly created array will use the sub-class type of 'a', otherwise it will be a base-class array. Defaults @@ -1703,6 +1705,7 @@ add_newdoc('numpy.core.multiarray', 'promote_types', Notes ----- .. versionadded:: 1.6.0 + Starting in NumPy 1.9, promote_types function now returns a valid string length when given an integer or float dtype as one argument and a string dtype as another argument. Previously it always returned the input string @@ -5039,10 +5042,10 @@ add_newdoc('numpy.core.multiarray', 'bincount', weights : array_like, optional Weights, array of the same shape as `x`. minlength : int, optional - .. versionadded:: 1.6.0 - A minimum number of bins for the output array. + .. versionadded:: 1.6.0 + Returns ------- out : ndarray of ints @@ -5164,10 +5167,11 @@ add_newdoc('numpy.core.multiarray', 'unravel_index', dims : tuple of ints The shape of the array to use for unraveling ``indices``. order : {'C', 'F'}, optional - .. versionadded:: 1.6.0 Determines whether the indices should be viewed as indexing in row-major (C-style) or column-major (Fortran-style) order. + .. versionadded:: 1.6.0 + Returns ------- unraveled_coords : tuple of ndarray -- cgit v1.2.1 From c484d41531c8e620ec6a9bd110a681f3dab6472c Mon Sep 17 00:00:00 2001 From: Samuel St-Jean Date: Tue, 18 Aug 2015 13:40:15 -0400 Subject: Doc : fixed paramter typo --- numpy/add_newdocs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'numpy/add_newdocs.py') diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index a6d7dc32e..195789a39 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -3242,7 +3242,7 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('astype', ------- arr_t : ndarray Unless `copy` is False and the other conditions for returning the input - array are satisfied (see description for `copy` input paramter), `arr_t` + array are satisfied (see description for `copy` input parameter), `arr_t` is a new array of the same shape as the input array, with dtype, order given by `dtype`, `order`. -- cgit v1.2.1 From 2b66f00bed834b2569bf22c0c519dad0bf5d5bda Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Tue, 11 Aug 2015 23:39:42 +0300 Subject: ENH: add shares_memory, implement may_share_memory using it --- numpy/add_newdocs.py | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) (limited to 'numpy/add_newdocs.py') diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index 195789a39..0af053f89 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -3784,24 +3784,41 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('min', """)) -add_newdoc('numpy.core.multiarray', 'may_share_memory', +add_newdoc('numpy.core.multiarray', 'shares_memory', """ - Determine if two arrays can share memory + shares_memory(a, b, max_work=None) - The memory-bounds of a and b are computed. If they overlap then - this function returns True. Otherwise, it returns False. - - A return of True does not necessarily mean that the two arrays - share any element. It just means that they *might*. + Determine if two arrays share memory Parameters ---------- a, b : ndarray + Input arrays + max_work : int, optional + Effort to spend on solving the overlap problem (maximum number + of candidate solutions to consider). Note max_work=1 handles + most usual cases. In addition, the following special values + are recognized: + + max_work=MAY_SHARE_EXACT (default) + The problem is solved exactly. In this case, the function returns + True only if there is an element shared between the arrays. + max_work=MAY_SHARE_BOUNDS + Only the memory bounds of a and b are checked. + + Raises + ------ + numpy.TooHardError + Exceeded max_work. Returns ------- out : bool + See Also + -------- + may_share_memory + Examples -------- >>> np.may_share_memory(np.array([1,2]), np.array([5,8,9])) -- cgit v1.2.1 From 3a52e1942aac937e8ae8381f9ea519b9328fd052 Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Sat, 29 Aug 2015 18:16:52 +0300 Subject: DOC: update docs + release notes vs shares_memory --- numpy/add_newdocs.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'numpy/add_newdocs.py') diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index 0af053f89..607e28a28 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -3796,9 +3796,8 @@ add_newdoc('numpy.core.multiarray', 'shares_memory', Input arrays max_work : int, optional Effort to spend on solving the overlap problem (maximum number - of candidate solutions to consider). Note max_work=1 handles - most usual cases. In addition, the following special values - are recognized: + of candidate solutions to consider). The following special + values are recognized: max_work=MAY_SHARE_EXACT (default) The problem is solved exactly. In this case, the function returns -- cgit v1.2.1 From 0589e9694b378215c5519183dccbccef5c421382 Mon Sep 17 00:00:00 2001 From: Hassan Kibirige Date: Tue, 8 Sep 2015 00:30:54 -0500 Subject: DOC: Document Datetime, Timedelta dtype kinds --- numpy/add_newdocs.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'numpy/add_newdocs.py') diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index 607e28a28..ce5ef6d09 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -6223,7 +6223,7 @@ add_newdoc('numpy.core.multiarray', 'dtype', ('itemsize', add_newdoc('numpy.core.multiarray', 'dtype', ('kind', """ - A character code (one of 'biufcOSUV') identifying the general kind of data. + A character code (one of 'biufcmMOSUV') identifying the general kind of data. = ====================== b boolean @@ -6231,6 +6231,8 @@ add_newdoc('numpy.core.multiarray', 'dtype', ('kind', u unsigned integer f floating-point c complex floating-point + m timedelta + M datetime O object S (byte-)string U Unicode -- cgit v1.2.1 From a1a03f2d73d8587d6ddc4cf410b0b9738b33bd28 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Fri, 25 Sep 2015 15:44:27 -0700 Subject: Document empty(..., object) initialization to None. Behavior goes back at least to 1.6.2. Fixes #6367. --- numpy/add_newdocs.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'numpy/add_newdocs.py') diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index ce5ef6d09..293005434 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -752,8 +752,8 @@ add_newdoc('numpy.core.multiarray', 'empty', Returns ------- out : ndarray - Array of uninitialized (arbitrary) data with the given - shape, dtype, and order. + Array of uninitialized (arbitrary) data of the given shape, dtype, and + order. Object arrays will be initialized to None. See Also -------- -- cgit v1.2.1 From e9f44ffb5232a298733c4299b6be2b078b34c2a9 Mon Sep 17 00:00:00 2001 From: eulerreich Date: Sun, 4 Oct 2015 22:26:27 -0500 Subject: typo --- numpy/add_newdocs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'numpy/add_newdocs.py') diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index 293005434..a53db35d4 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -2108,7 +2108,7 @@ add_newdoc('numpy.core', 'einsum', Using the Einstein summation convention, many common multi-dimensional array operations can be represented in a simple fashion. This function - provides a way compute such summations. The best way to understand this + provides a way to compute such summations. The best way to understand this function is to try the examples below, which show how many common NumPy functions can be implemented as calls to `einsum`. -- cgit v1.2.1 From 07c66c8ea72181954f4fcf9f62af677d22eec639 Mon Sep 17 00:00:00 2001 From: Samuel St-Jean Date: Fri, 16 Oct 2015 11:33:51 +0200 Subject: Fixed a typo in np.inner doc --- numpy/add_newdocs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'numpy/add_newdocs.py') diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index a53db35d4..b00e229c3 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -1228,7 +1228,7 @@ add_newdoc('numpy.core', 'inner', Parameters ---------- a, b : array_like - If `a` and `b` are nonscalar, their last dimensions of must match. + If `a` and `b` are nonscalar, their last dimensions must match. Returns ------- -- cgit v1.2.1 From 8efc87ec599c0b3eac4e63bea6eda9023d8ed96d Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Thu, 12 Nov 2015 20:15:37 +0200 Subject: ENH: reimplement may_share_memory in C to improve its performance --- numpy/add_newdocs.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'numpy/add_newdocs.py') diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index b00e229c3..c14036089 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -3826,6 +3826,45 @@ add_newdoc('numpy.core.multiarray', 'shares_memory', """) +add_newdoc('numpy.core.multiarray', 'may_share_memory', + """ + may_share_memory(a, b, max_work=None) + + Determine if two arrays might share memory + + A return of True does not necessarily mean that the two arrays + share any element. It just means that they *might*. + + Only the memory bounds of a and b are checked by default. + + Parameters + ---------- + a, b : ndarray + Input arrays + max_work : int, optional + Effort to spend on solving the overlap problem. See + `shares_memory` for details. Default for ``may_share_memory`` + is to do a bounds check. + + Returns + ------- + out : bool + + See Also + -------- + shares_memory + + Examples + -------- + >>> np.may_share_memory(np.array([1,2]), np.array([5,8,9])) + False + >>> x = np.zeros([3, 4]) + >>> np.may_share_memory(x[:,0], x[:,1]) + True + + """) + + add_newdoc('numpy.core.multiarray', 'ndarray', ('newbyteorder', """ arr.newbyteorder(new_order='S') -- cgit v1.2.1 From 088e20e272389395fb3fd24fed144ed19bae8cdb Mon Sep 17 00:00:00 2001 From: gfyoung Date: Fri, 11 Dec 2015 04:24:16 +0000 Subject: DEP: Stricter arg checking for array ordering The bug traces to the PyArray_OrderConverter method in conversion_utils.c, where no errors are thrown if the ORDER parameter passed in is not of the string data-type or has a string value of length greater than one. This commit causes a DeprecationWarning to be raised, which will later be turned into a TypeError or another type of error in a future release. Closes gh-6598. --- numpy/add_newdocs.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'numpy/add_newdocs.py') diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index c14036089..01ef24a5b 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -3567,10 +3567,14 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('flatten', Parameters ---------- - order : {'C', 'F', 'A'}, optional - Whether to flatten in row-major (C-style) or - column-major (Fortran-style) order or preserve the - C/Fortran ordering from `a`. The default is 'C'. + order : {'C', 'F', 'A', 'K'}, optional + 'C' means to flatten in row-major (C-style) order. + 'F' means to flatten in column-major (Fortran- + style) order. 'A' means to flatten in column-major + order if `a` is Fortran *contiguous* in memory, + row-major order otherwise. 'K' means to flatten + `a` in the order the elements occur in memory. + The default is 'C'. Returns ------- -- cgit v1.2.1 From 8bc592fabf4a2b0bc76db996b1523330ba095be3 Mon Sep 17 00:00:00 2001 From: gfyoung Date: Sat, 19 Dec 2015 16:49:35 -0800 Subject: DOC: Use print only as function when print_function is imported from __future__ Closes gh-6863. --- numpy/add_newdocs.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'numpy/add_newdocs.py') diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index 01ef24a5b..7eef07c4a 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -49,7 +49,7 @@ add_newdoc('numpy.core', 'flatiter', >>> type(fl) >>> for item in fl: - ... print item + ... print(item) ... 0 1 @@ -1548,7 +1548,7 @@ add_newdoc('numpy.core.multiarray', 'lexsort', >>> a = [1,5,1,4,3,4,4] # First column >>> b = [9,4,0,4,0,2,1] # Second column >>> ind = np.lexsort((b,a)) # Sort by a, then by b - >>> print ind + >>> print(ind) [2 0 4 6 5 3 1] >>> [(a[i],b[i]) for i in ind] @@ -4773,7 +4773,7 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('view', >>> y = x.view(dtype=np.int16, type=np.matrix) >>> y matrix([[513]], dtype=int16) - >>> print type(y) + >>> print(type(y)) Creating a view on a structured array so it can be used in calculations @@ -4789,7 +4789,7 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('view', Making changes to the view changes the underlying array >>> xv[0,1] = 20 - >>> print x + >>> print(x) [(1, 20) (3, 4)] Using a view to convert an array to a recarray: @@ -4915,7 +4915,7 @@ add_newdoc('numpy.core.umath', 'geterrobj', [10000, 0, None] >>> def err_handler(type, flag): - ... print "Floating point error (%s), with flag %s" % (type, flag) + ... print("Floating point error (%s), with flag %s" % (type, flag)) ... >>> old_bufsize = np.setbufsize(20000) >>> old_err = np.seterr(divide='raise') @@ -4979,7 +4979,7 @@ add_newdoc('numpy.core.umath', 'seterrobj', [10000, 0, None] >>> def err_handler(type, flag): - ... print "Floating point error (%s), with flag %s" % (type, flag) + ... print("Floating point error (%s), with flag %s" % (type, flag)) ... >>> new_errobj = [20000, 12, err_handler] >>> np.seterrobj(new_errobj) @@ -5064,7 +5064,7 @@ add_newdoc('numpy.core.multiarray', 'digitize', >>> inds array([1, 4, 3, 2]) >>> for n in range(x.size): - ... print bins[inds[n]-1], "<=", x[n], "<", bins[inds[n]] + ... print(bins[inds[n]-1], "<=", x[n], "<", bins[inds[n]]) ... 0.0 <= 0.2 < 1.0 4.0 <= 6.4 < 10.0 @@ -5473,7 +5473,7 @@ add_newdoc('numpy.core', 'ufunc', ('identity', 1 >>> np.power.identity 1 - >>> print np.exp.identity + >>> print(np.exp.identity) None """)) @@ -6181,7 +6181,7 @@ add_newdoc('numpy.core.multiarray', 'dtype', ('fields', Examples -------- >>> dt = np.dtype([('name', np.str_, 16), ('grades', np.float64, (2,))]) - >>> print dt.fields + >>> print(dt.fields) {'grades': (dtype(('float64',(2,))), 16), 'name': (dtype('|S16'), 0)} """)) -- cgit v1.2.1 From 40e47e06e741797efef60211c58e30ff82c7191f Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Tue, 5 Jan 2016 12:56:26 -0700 Subject: DOC,BUG: Fix some latex generation problems. Some of the documentation for newbyteorder, copy and pasted in several spots, had paragraphs ending in `::`, initiating a sphinx generated Verbatim environment and resulting in "LaTeX Error: Too deeply nested". The user_array.container class needed non-empty class documentation. That that caused a problem is probably a numpydoc bug, but it is easy to fix. [skip ci] --- numpy/add_newdocs.py | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'numpy/add_newdocs.py') diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index 7eef07c4a..e79720c77 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -3888,13 +3888,13 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('newbyteorder', ---------- new_order : string, optional Byte order to force; a value from the byte order specifications - above. `new_order` codes can be any of:: + below. `new_order` codes can be any of: - * 'S' - swap dtype from current to opposite endian - * {'<', 'L'} - little endian - * {'>', 'B'} - big endian - * {'=', 'N'} - native order - * {'|', 'I'} - ignore (no change to byte order) + * 'S' - swap dtype from current to opposite endian + * {'<', 'L'} - little endian + * {'>', 'B'} - big endian + * {'=', 'N'} - native order + * {'|', 'I'} - ignore (no change to byte order) The default value ('S') results in swapping the current byte order. The code does a case-insensitive check on the first @@ -6359,16 +6359,15 @@ add_newdoc('numpy.core.multiarray', 'dtype', ('newbyteorder', Parameters ---------- new_order : string, optional - Byte order to force; a value from the byte order - specifications below. The default value ('S') results in - swapping the current byte order. - `new_order` codes can be any of:: + Byte order to force; a value from the byte order specifications + below. The default value ('S') results in swapping the current + byte order. `new_order` codes can be any of: - * 'S' - swap dtype from current to opposite endian - * {'<', 'L'} - little endian - * {'>', 'B'} - big endian - * {'=', 'N'} - native order - * {'|', 'I'} - ignore (no change to byte order) + * 'S' - swap dtype from current to opposite endian + * {'<', 'L'} - little endian + * {'>', 'B'} - big endian + * {'=', 'N'} - native order + * {'|', 'I'} - ignore (no change to byte order) The code does a case-insensitive check on the first letter of `new_order` for these alternatives. For example, any of '>' @@ -7231,10 +7230,10 @@ add_newdoc('numpy.core.numerictypes', 'generic', ('newbyteorder', The `new_order` code can be any from the following: + * 'S' - swap dtype from current to opposite endian * {'<', 'L'} - little endian * {'>', 'B'} - big endian * {'=', 'N'} - native order - * 'S' - swap dtype from current to opposite endian * {'|', 'I'} - ignore (no change to byte order) Parameters -- cgit v1.2.1 From c0f6c3744ff6a54d4e9be5a98aa2d4253f537f49 Mon Sep 17 00:00:00 2001 From: "Nathaniel J. Smith" Date: Thu, 14 Jan 2016 17:27:40 -0800 Subject: DOC: Clean up/fix several references to the "future" 1.10 release Fixes gh-7010 --- numpy/add_newdocs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'numpy/add_newdocs.py') diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index e79720c77..8940f537d 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -3466,7 +3466,7 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('diagonal', Return specified diagonals. In NumPy 1.9 the returned array is a read-only view instead of a copy as in previous NumPy versions. In - NumPy 1.10 the read-only restriction will be removed. + a future version the read-only restriction will be removed. Refer to :func:`numpy.diagonal` for full documentation. -- cgit v1.2.1 From 2f5bb353300796c0f96c5061ac4a08583eeda0a8 Mon Sep 17 00:00:00 2001 From: Michael Seifert Date: Tue, 22 Mar 2016 17:56:07 +0100 Subject: DOC: array link to full and full_like instead of fill ndarray.fill (not fill) is not appropriate here because it is a list how to create arrays not how to fill them. [ci skip] --- numpy/add_newdocs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'numpy/add_newdocs.py') diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index 8940f537d..0341a032f 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -686,7 +686,7 @@ add_newdoc('numpy.core.multiarray', 'array', See Also -------- - empty, empty_like, zeros, zeros_like, ones, ones_like, fill + empty, empty_like, zeros, zeros_like, ones, ones_like, full, full_like Examples -------- -- cgit v1.2.1 From 13dd07ad8d97920f8c6ea2933b7e19e5abb158b2 Mon Sep 17 00:00:00 2001 From: endolith Date: Mon, 4 Apr 2016 21:49:44 -0400 Subject: DOC: link frompyfunc and vectorize --- numpy/add_newdocs.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'numpy/add_newdocs.py') diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index 0341a032f..055c23480 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -4852,6 +4852,10 @@ add_newdoc('numpy.core.umath', 'frompyfunc', out : ufunc Returns a Numpy universal function (``ufunc``) object. + See Also + -------- + vectorize : evaluates pyfunc over input arrays using broadcasting rules of numpy + Notes ----- The returned ufunc always returns PyObject arrays. -- cgit v1.2.1 From eb8913d1a39e09b739a6e9449dc841a52ecbac37 Mon Sep 17 00:00:00 2001 From: Endolith Date: Wed, 11 May 2016 20:09:04 -0400 Subject: DOC: Fix some incorrect RST definition lists --- numpy/add_newdocs.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'numpy/add_newdocs.py') diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index 055c23480..16799887f 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -262,7 +262,7 @@ add_newdoc('numpy.core', 'nditer', has_multi_index : bool If True, the iterator was created with the "multi_index" flag, and the property `multi_index` can be used to retrieve it. - index : + index When the "c_index" or "f_index" flag was used, this property provides access to the index. Raises a ValueError if accessed and `has_index` is False. @@ -273,10 +273,10 @@ add_newdoc('numpy.core', 'nditer', An index which matches the order of iteration. itersize : int Size of the iterator. - itviews : + itviews Structured view(s) of `operands` in memory, matching the reordered and optimized iterator access pattern. - multi_index : + multi_index When the "multi_index" flag was used, this property provides access to the index. Raises a ValueError if accessed accessed and `has_multi_index` is False. @@ -288,7 +288,7 @@ add_newdoc('numpy.core', 'nditer', The array(s) to be iterated over. shape : tuple of ints Shape tuple, the shape of the iterator. - value : + value Value of `operands` at current iteration. Normally, this is a tuple of array scalars, but if the flag "external_loop" is used, it is a tuple of one dimensional arrays. @@ -481,6 +481,11 @@ add_newdoc('numpy.core', 'broadcast', Amongst others, it has ``shape`` and ``nd`` properties, and may be used as an iterator. + See Also + -------- + broadcast_arrays + broadcast_to + Examples -------- Manually adding two vectors, using broadcasting: -- cgit v1.2.1 From 987cd0c2e6e2c8a73917e0bee19f869058c3b20f Mon Sep 17 00:00:00 2001 From: MechCoder Date: Thu, 7 Apr 2016 12:25:02 -0400 Subject: DOC: Fix order='A' docs of np.array --- numpy/add_newdocs.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'numpy/add_newdocs.py') diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index 16799887f..269c17adf 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -647,7 +647,7 @@ add_newdoc('numpy.core', 'broadcast', ('reset', add_newdoc('numpy.core.multiarray', 'array', """ - array(object, dtype=None, copy=True, order=None, subok=False, ndmin=0) + array(object, dtype=None, copy=True, order='K', subok=False, ndmin=0) Create an array. @@ -668,14 +668,18 @@ add_newdoc('numpy.core.multiarray', 'array', will only be made if __array__ returns a copy, if obj is a nested sequence, or if a copy is needed to satisfy any of the other requirements (`dtype`, `order`, etc.). - order : {'C', 'F', 'A'}, optional + order : {'C', 'F', 'A', 'K'}, optional, default 'K' Specify the order of the array. If order is 'C', then the array will be in C-contiguous order (last-index varies the fastest). If order is 'F', then the returned array will be in Fortran-contiguous order (first-index varies the fastest). - If order is 'A' (default), then the returned array may be - in any order (either C-, Fortran-contiguous, or even discontiguous), - unless a copy is required, in which case it will be C-contiguous. + If ``copy=False``, and order is set to 'A' or 'K', nothing + is ensured about the memory layout of the output array. + If ``copy=True`` and + - Order is 'A', then the order of the output is C + unless the input is fortran-ordered. + - Order is 'K', then the memory layout of the returned array is + kept as close as possible to the original array. subok : bool, optional If True, then sub-classes will be passed-through, otherwise the returned array will be forced to be a base-class array (default). -- cgit v1.2.1 From e85d99863c55bcb06ff9ccf9afbee6435ebb9b09 Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Sat, 11 Jun 2016 22:00:44 -0600 Subject: DOC: Further clarification of order argument in np.array. Attempt to clarify the sometimes convoluted behavior of the various order options 'K', 'A', 'C', 'F'. --- numpy/add_newdocs.py | 58 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 24 deletions(-) (limited to 'numpy/add_newdocs.py') diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index 269c17adf..46601b8ef 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -654,32 +654,36 @@ add_newdoc('numpy.core.multiarray', 'array', Parameters ---------- object : array_like - An array, any object exposing the array interface, an - object whose __array__ method returns an array, or any - (nested) sequence. + An array, any object exposing the array interface, an object whose + __array__ method returns an array, or any (nested) sequence. dtype : data-type, optional - The desired data-type for the array. If not given, then - the type will be determined as the minimum type required - to hold the objects in the sequence. This argument can only - be used to 'upcast' the array. For downcasting, use the - .astype(t) method. + The desired data-type for the array. If not given, then the type will + be determined as the minimum type required to hold the objects in the + sequence. This argument can only be used to 'upcast' the array. For + downcasting, use the .astype(t) method. copy : bool, optional - If true (default), then the object is copied. Otherwise, a copy - will only be made if __array__ returns a copy, if obj is a - nested sequence, or if a copy is needed to satisfy any of the other - requirements (`dtype`, `order`, etc.). - order : {'C', 'F', 'A', 'K'}, optional, default 'K' - Specify the order of the array. If order is 'C', then the array - will be in C-contiguous order (last-index varies the fastest). - If order is 'F', then the returned array will be in - Fortran-contiguous order (first-index varies the fastest). - If ``copy=False``, and order is set to 'A' or 'K', nothing - is ensured about the memory layout of the output array. - If ``copy=True`` and - - Order is 'A', then the order of the output is C - unless the input is fortran-ordered. - - Order is 'K', then the memory layout of the returned array is - kept as close as possible to the original array. + If true (default), then the object is copied. Otherwise, a copy will + only be made if __array__ returns a copy, if obj is a nested sequence, + or if a copy is needed to satisfy any of the other requirements + (`dtype`, `order`, etc.). + order : {'K', 'A', 'C', 'F'}, optional + Specify the memory layout of the array. If object is not an array, the + newly created array will be in C order (row major) unless 'F' is + specified, in which case it will be in Fortran order (column major). + If object is an array the following holds. + + ===== ========= =================================================== + order no copy copy=True + ===== ========= =================================================== + 'K' unchanged F & C order preserved, otherwise most similar order + 'A' unchanged F order if input is F and not C, otherwise C order + 'C' C order C order + 'F' F order F order + ===== ========= =================================================== + + When ``copy=False`` and a copy is made for other reasons, the result is + the same as if ``copy=True``, with some exceptions for `A`, see the + Notes section. The default order is 'K'. subok : bool, optional If True, then sub-classes will be passed-through, otherwise the returned array will be forced to be a base-class array (default). @@ -697,6 +701,12 @@ add_newdoc('numpy.core.multiarray', 'array', -------- empty, empty_like, zeros, zeros_like, ones, ones_like, full, full_like + Notes + ----- + When order is 'A' and `object` is an array in neither 'C' nor 'F' order, + and a copy is forced by a change in dtype, then the order of the result is + not necessarily 'C' as expected. This is likely a bug. + Examples -------- >>> np.array([1, 2, 3]) -- cgit v1.2.1 From e22492340f9d89ee77f0dc3fbfcd499c855a9d14 Mon Sep 17 00:00:00 2001 From: Eric Wieser Date: Sun, 8 May 2016 14:12:57 -0400 Subject: ENH: Alias broadcast.ndim to broadcast.nd Both `ndarray` and `nditer` spell this property `ndim`, so broadcast objects should too. The existing property remains for compatibility --- numpy/add_newdocs.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'numpy/add_newdocs.py') diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index 46601b8ef..b00673d79 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -552,10 +552,26 @@ add_newdoc('numpy.core', 'broadcast', ('iters', """)) -add_newdoc('numpy.core', 'broadcast', ('nd', +add_newdoc('numpy.core', 'broadcast', ('ndim', """ Number of dimensions of broadcasted result. + .. versionadded:: 1.12.0 + + Examples + -------- + >>> x = np.array([1, 2, 3]) + >>> y = np.array([[4], [5], [6]]) + >>> b = np.broadcast(x, y) + >>> b.ndim + 2 + + """)) + +add_newdoc('numpy.core', 'broadcast', ('nd', + """ + Number of dimensions of broadcasted result. Alias for `ndim`. + Examples -------- >>> x = np.array([1, 2, 3]) -- cgit v1.2.1 From 71c18e964e36f3875db867ae45b6e22fb551ae85 Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Fri, 17 Jun 2016 11:08:43 -0600 Subject: MAINT: Tweak documentation of broadcast.nd and broadcast.ndim. Note that the newly added `ndim` property is an alias for `nd` and not available in numpy versions earlier than 1.12. Add back the tests for `nd`. They can be removed if/when `nd` is dropped. --- numpy/add_newdocs.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'numpy/add_newdocs.py') diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index b00673d79..c6ceb29c6 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -554,7 +554,7 @@ add_newdoc('numpy.core', 'broadcast', ('iters', add_newdoc('numpy.core', 'broadcast', ('ndim', """ - Number of dimensions of broadcasted result. + Number of dimensions of broadcasted result. Alias for `nd`. .. versionadded:: 1.12.0 @@ -570,7 +570,8 @@ add_newdoc('numpy.core', 'broadcast', ('ndim', add_newdoc('numpy.core', 'broadcast', ('nd', """ - Number of dimensions of broadcasted result. Alias for `ndim`. + Number of dimensions of broadcasted result. For code intended for Numpy + 1.12.0 and later the more consistent `ndim` is preferred. Examples -------- -- cgit v1.2.1 From 05f18c8d206387c54f00f13cbd34dfb3d7d0c573 Mon Sep 17 00:00:00 2001 From: Shayan Pooya Date: Wed, 22 Jun 2016 23:31:24 -0700 Subject: DOC: Remove a redundant the --- numpy/add_newdocs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'numpy/add_newdocs.py') diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index c6ceb29c6..4fc9bca7d 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -2442,7 +2442,7 @@ add_newdoc('numpy.core.multiarray', 'ndarray', a low-level method (`ndarray(...)`) for instantiating an array. For more information, refer to the `numpy` module and examine the - the methods and attributes of an array. + methods and attributes of an array. Parameters ---------- -- cgit v1.2.1 From 0fc9e4520b1d00b58a77f28936da2fec2672de83 Mon Sep 17 00:00:00 2001 From: gfyoung Date: Fri, 29 Jan 2016 03:25:53 +0000 Subject: ENH: added axis param for np.count_nonzero Closes gh-391. --- numpy/add_newdocs.py | 28 ---------------------------- 1 file changed, 28 deletions(-) (limited to 'numpy/add_newdocs.py') diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index 4fc9bca7d..41267b797 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -942,34 +942,6 @@ add_newdoc('numpy.core.multiarray', 'zeros', """) -add_newdoc('numpy.core.multiarray', 'count_nonzero', - """ - count_nonzero(a) - - Counts the number of non-zero values in the array ``a``. - - Parameters - ---------- - a : array_like - The array for which to count non-zeros. - - Returns - ------- - count : int or array of int - Number of non-zero values in the array. - - See Also - -------- - nonzero : Return the coordinates of all the non-zero values. - - Examples - -------- - >>> np.count_nonzero(np.eye(4)) - 4 - >>> np.count_nonzero([[0,1,7,0,0],[3,0,0,2,19]]) - 5 - """) - add_newdoc('numpy.core.multiarray', 'set_typeDict', """set_typeDict(dict) -- cgit v1.2.1 From 2a55233b81a6ea18a57d1dd4f7bc5fff9f2fb681 Mon Sep 17 00:00:00 2001 From: Pierre de Buyl Date: Tue, 6 Sep 2016 14:42:08 +0200 Subject: DOC: change Numpy to NumPy in dosctrings and comments The strings in error messages were left untouched --- numpy/add_newdocs.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'numpy/add_newdocs.py') diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index 41267b797..adeaff90c 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -296,7 +296,7 @@ add_newdoc('numpy.core', 'nditer', Notes ----- `nditer` supersedes `flatiter`. The iterator implementation behind - `nditer` is also exposed by the Numpy C API. + `nditer` is also exposed by the NumPy C API. The Python exposure supplies two iteration interfaces, one which follows the Python iterator protocol, and another which mirrors the C-style @@ -570,7 +570,7 @@ add_newdoc('numpy.core', 'broadcast', ('ndim', add_newdoc('numpy.core', 'broadcast', ('nd', """ - Number of dimensions of broadcasted result. For code intended for Numpy + Number of dimensions of broadcasted result. For code intended for NumPy 1.12.0 and later the more consistent `ndim` is preferred. Examples @@ -2014,7 +2014,7 @@ add_newdoc('numpy.core', 'matmul', were elements. .. warning:: - This function is preliminary and included in Numpy 1.10 for testing + This function is preliminary and included in NumPy 1.10 for testing and documentation. Its semantics will not change, but the number and order of the optional arguments will. @@ -4841,7 +4841,7 @@ add_newdoc('numpy.core.umath', 'frompyfunc', """ frompyfunc(func, nin, nout) - Takes an arbitrary Python function and returns a Numpy ufunc. + Takes an arbitrary Python function and returns a NumPy ufunc. Can be used, for example, to add broadcasting to a built-in Python function (see Examples section). @@ -4858,7 +4858,7 @@ add_newdoc('numpy.core.umath', 'frompyfunc', Returns ------- out : ufunc - Returns a Numpy universal function (``ufunc``) object. + Returns a NumPy universal function (``ufunc``) object. See Also -------- @@ -4888,7 +4888,7 @@ add_newdoc('numpy.core.umath', 'geterrobj', Return the current object that defines floating-point error handling. The error object contains all information that defines the error handling - behavior in Numpy. `geterrobj` is used internally by the other + behavior in NumPy. `geterrobj` is used internally by the other functions that get and set error handling behavior (`geterr`, `seterr`, `geterrcall`, `seterrcall`). @@ -4952,7 +4952,7 @@ add_newdoc('numpy.core.umath', 'seterrobj', Set the object that defines floating-point error handling. The error object contains all information that defines the error handling - behavior in Numpy. `seterrobj` is used internally by the other + behavior in NumPy. `seterrobj` is used internally by the other functions that set error handling behavior (`seterr`, `seterrcall`). Parameters @@ -5028,7 +5028,7 @@ add_newdoc('numpy.core.multiarray', 'digitize', Parameters ---------- x : array_like - Input array to be binned. Prior to Numpy 1.10.0, this array had to + Input array to be binned. Prior to NumPy 1.10.0, this array had to be 1-dimensional, but can now have any shape. bins : array_like Array of bins. It has to be 1-dimensional and monotonic. @@ -6235,7 +6235,7 @@ add_newdoc('numpy.core.multiarray', 'dtype', ('isbuiltin', 2 if the dtype is for a user-defined numpy type A user-defined type uses the numpy C-API machinery to extend numpy to handle a new array type. See - :ref:`user.user-defined-data-types` in the Numpy manual. + :ref:`user.user-defined-data-types` in the NumPy manual. = ======================================================================== Examples @@ -7623,7 +7623,7 @@ add_newdoc('numpy.core.numerictypes', 'generic', ('view', ############################################################################## add_newdoc('numpy.core.numerictypes', 'bool_', - """Numpy's Boolean type. Character code: ``?``. Alias: bool8""") + """NumPy's Boolean type. Character code: ``?``. Alias: bool8""") add_newdoc('numpy.core.numerictypes', 'complex64', """ -- cgit v1.2.1 From db0b231f17fb2148772181626235e2644eb67c3e Mon Sep 17 00:00:00 2001 From: Pierre de Buyl Date: Wed, 7 Sep 2016 09:48:40 +0200 Subject: DOC: change version references from x.y to x.y.z --- numpy/add_newdocs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'numpy/add_newdocs.py') diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index adeaff90c..1cf031546 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -2014,7 +2014,7 @@ add_newdoc('numpy.core', 'matmul', were elements. .. warning:: - This function is preliminary and included in NumPy 1.10 for testing + This function is preliminary and included in NumPy 1.10.0 for testing and documentation. Its semantics will not change, but the number and order of the optional arguments will. -- cgit v1.2.1 From 1b22317ca16e14070400eedc714ae97e022b747d Mon Sep 17 00:00:00 2001 From: AustereCuriosity Date: Sun, 11 Sep 2016 20:48:08 +0530 Subject: Update add_newdocs.py (#8040) DOC: Fix bad partition example. --- numpy/add_newdocs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'numpy/add_newdocs.py') diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index 1cf031546..05904461c 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -4445,7 +4445,7 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('partition', Examples -------- >>> a = np.array([3, 4, 2, 1]) - >>> a.partition(a, 3) + >>> a.partition(3) >>> a array([2, 1, 3, 4]) -- cgit v1.2.1 From 8c1ca4cb5662a80110fd2020634b4deea7717661 Mon Sep 17 00:00:00 2001 From: Matti Picus Date: Mon, 12 Sep 2016 23:16:53 +0300 Subject: ENH: a.resize(.., refcheck=True) is almost unusable on PyPy --- numpy/add_newdocs.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'numpy/add_newdocs.py') diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index 05904461c..755cdc303 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -4123,6 +4123,9 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('resize', ValueError If `a` does not own its own data or references or views to it exist, and the data memory must be changed. + PyPy only: will always raise if the data memory must be changed, since + there is no reliable way to determine if references or views to it + exist. SystemError If the `order` keyword argument is specified. This behaviour is a -- cgit v1.2.1 From 4c788f4e7f6f5af6b1c3cda98388768912349b46 Mon Sep 17 00:00:00 2001 From: Daniel Smith Date: Fri, 9 Sep 2016 14:47:21 -0400 Subject: ENH: Allows contraction order optimization in einsum function. --- numpy/add_newdocs.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'numpy/add_newdocs.py') diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index 755cdc303..da87bc29e 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -2108,9 +2108,9 @@ add_newdoc('numpy.core', 'matmul', """) -add_newdoc('numpy.core', 'einsum', +add_newdoc('numpy.core', 'c_einsum', """ - einsum(subscripts, *operands, out=None, dtype=None, order='K', casting='safe') + c_einsum(subscripts, *operands, out=None, dtype=None, order='K', casting='safe') Evaluates the Einstein summation convention on the operands. @@ -2120,6 +2120,8 @@ add_newdoc('numpy.core', 'einsum', function is to try the examples below, which show how many common NumPy functions can be implemented as calls to `einsum`. + This is the core C function. + Parameters ---------- subscripts : str @@ -2128,10 +2130,10 @@ add_newdoc('numpy.core', 'einsum', These are the arrays for the operation. out : ndarray, optional If provided, the calculation is done into this array. - dtype : data-type, optional + dtype : {data-type, None}, optional If provided, forces the calculation to use the data type specified. Note that you may have to also give a more liberal `casting` - parameter to allow the conversions. + parameter to allow the conversions. Default is None. order : {'C', 'F', 'A', 'K'}, optional Controls the memory layout of the output. 'C' means it should be C contiguous. 'F' means it should be Fortran contiguous, @@ -2150,6 +2152,8 @@ add_newdoc('numpy.core', 'einsum', like float64 to float32, are allowed. * 'unsafe' means any data conversions may be done. + Default is 'safe'. + Returns ------- output : ndarray @@ -2157,7 +2161,7 @@ add_newdoc('numpy.core', 'einsum', See Also -------- - dot, inner, outer, tensordot + einsum, dot, inner, outer, tensordot Notes ----- -- cgit v1.2.1 From 4733b0047c04e15b69d359fa347378a6399fd10b Mon Sep 17 00:00:00 2001 From: Allan Haldane Date: Tue, 18 Oct 2016 17:12:55 -0400 Subject: DOC: warn that dtype.descr is only for use in PEP3118 --- numpy/add_newdocs.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'numpy/add_newdocs.py') diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index da87bc29e..62faf09fe 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -6171,11 +6171,13 @@ add_newdoc('numpy.core.multiarray', 'dtype', ('char', add_newdoc('numpy.core.multiarray', 'dtype', ('descr', """ - Array-interface compliant full description of the data-type. + PEP3118 interface description of the data-type. The format is that required by the 'descr' key in the - `__array_interface__` attribute. + PEP3118 `__array_interface__` attribute. + Warning: This attribute exists specifically for PEP3118 compliance, and + is not a datatype description compatible with `np.dtype`. """)) add_newdoc('numpy.core.multiarray', 'dtype', ('fields', -- cgit v1.2.1 From f1aaff1948dfb3e008bb20ef5442bf0118104f4d Mon Sep 17 00:00:00 2001 From: Eric Wieser Date: Thu, 20 Oct 2016 15:36:41 +0100 Subject: DOC: Add missing arguments to np.ufunc.outer --- numpy/add_newdocs.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'numpy/add_newdocs.py') diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index 62faf09fe..78c1760ac 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -5896,7 +5896,7 @@ add_newdoc('numpy.core', 'ufunc', ('reduceat', add_newdoc('numpy.core', 'ufunc', ('outer', """ - outer(A, B) + outer(A, B, **kwargs) Apply the ufunc `op` to all pairs (a, b) with a in `A` and b in `B`. @@ -5919,6 +5919,8 @@ add_newdoc('numpy.core', 'ufunc', ('outer', First array B : array_like Second array + kwargs : any + Arguments to pass on to the ufunc. Typically `dtype` or `out`. Returns ------- -- cgit v1.2.1 From 5b9e7ee0d5b614fb312052feae98abdd8801ba7a Mon Sep 17 00:00:00 2001 From: Eric Wieser Date: Sat, 22 Oct 2016 02:47:40 +0100 Subject: DEP: Deprecate the keepdims argument to accumulate --- numpy/add_newdocs.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'numpy/add_newdocs.py') diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index 62faf09fe..3dcaebd48 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -5720,7 +5720,7 @@ add_newdoc('numpy.core', 'ufunc', ('reduce', add_newdoc('numpy.core', 'ufunc', ('accumulate', """ - accumulate(array, axis=0, dtype=None, out=None) + accumulate(array, axis=0, dtype=None, out=None, keepdims=None) Accumulate the result of applying the operator to all elements. @@ -5752,6 +5752,8 @@ add_newdoc('numpy.core', 'ufunc', ('accumulate', out : ndarray, optional A location into which the result is stored. If not provided a freshly-allocated array is returned. + keepdims : bool + Has no effect. Deprecated, and will be removed in future. Returns ------- -- cgit v1.2.1 From baef1f2291abfcdaedec12d7b5afa230fe1d3db5 Mon Sep 17 00:00:00 2001 From: gfyoung Date: Thu, 27 Oct 2016 14:20:29 -0400 Subject: DOC: Patch doc errors for atleast_nd and frombuffer Closes gh-8214. Closes gh-8215. --- numpy/add_newdocs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'numpy/add_newdocs.py') diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index e3304d191..8a24bead1 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -1126,7 +1126,7 @@ add_newdoc('numpy.core.multiarray', 'frombuffer', count : int, optional Number of items to read. ``-1`` means all data in the buffer. offset : int, optional - Start reading the buffer from this offset; default: 0. + Start reading the buffer from this offset (in bytes); default: 0. Notes ----- -- cgit v1.2.1 From 47c66c974b8fecb3a14a3a144d68d5c5a02a2073 Mon Sep 17 00:00:00 2001 From: Takuya Akiba Date: Tue, 29 Nov 2016 15:37:20 +0900 Subject: BUG: fix packbits and unpackbits to correctly handle empty arrays --- numpy/add_newdocs.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'numpy/add_newdocs.py') diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index 8a24bead1..2834c963b 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -5319,7 +5319,8 @@ add_newdoc('numpy.core.multiarray', 'packbits', Parameters ---------- myarray : array_like - An integer type array whose elements should be packed to bits. + An array of integers or booleans whose elements should be packed to + bits. axis : int, optional The dimension over which bit-packing is done. ``None`` implies packing the flattened array. -- cgit v1.2.1 From ec0e04694278ef9ea83537d308b07fc27c1b5f85 Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Tue, 13 Dec 2016 15:53:56 -0700 Subject: DEP: Fix escaped string characters deprecated in Python 3.6. In Python 3.6 a number of escape sequences that were previously accepted -- for instance "\(" that was translated to "\\(" -- are deprecated. To retain the previous behavior either raw strings must be used or the backslash must be properly escaped itself. --- numpy/add_newdocs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'numpy/add_newdocs.py') diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index 2834c963b..1d4bf4511 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -3722,7 +3722,7 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('itemset', Parameters ---------- - \*args : Arguments + \\*args : Arguments If one argument: a scalar, only used in case `a` is of size 1. If two arguments: the last argument is the value to be set and must be a scalar, the first argument specifies a single array -- cgit v1.2.1