From 94005e8a5eb50b1abdcccbc69885021056398be3 Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Tue, 9 May 2017 13:00:21 -0600 Subject: [PATCH 1/2] MAINT: Update .mailmap to include new contributers. [ci skip] --- .mailmap | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.mailmap b/.mailmap index 498d7a6c7c09..675c5e386e36 100644 --- a/.mailmap +++ b/.mailmap @@ -13,6 +13,7 @@ Abdul Muneer abdulmuneer Adam Ginsburg Adam Ginsburg Albert Jornet Puig jurnix Alexander Belopolsky Alexander Belopolsky +Alexander Shadchin Alexandr Shadchin Alex Griffing alex Alex Griffing argriffing Alex Griffing argriffing @@ -111,6 +112,7 @@ Mark Wiebe Mark Wiebe Mark Wiebe Mark Wiebe Martin Goodson martingoodson Martin Teichmann Martin Teichmann +Martino Sorbaro martinosorb Mattheus Ueckermann empeeu Matthew Harrigan MattHarrigan Matti Picus mattip @@ -127,6 +129,7 @@ Pat Miller patmiller Paul Ivanov Paul Ivanov Paul Jacobson hpaulj Pearu Peterson Pearu Peterson +Pete Peeradej Tanruangporn petetanru Peter J Cock peterjc Phil Elson Pierre GM pierregm @@ -155,6 +158,7 @@ Stephan Hoyer Stephan Hoyer Steven J Kern Thomas A Caswell Thomas A Caswell Tim Cera tim cera +Tom Boyd pezcore Tom Poole tpoole Travis Oliphant Travis E. Oliphant Travis Oliphant Travis Oliphant @@ -163,3 +167,4 @@ Warren Weckesser Warren Weckesser Wendell Smith William Spotz wfspotz@sandia.gov Wojtek Ruszczewski wrwrwr +Zixu Zhao ZZhaoTireless From 72b50eb41f3b2911dce7c44b958f22b7c835c90d Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Tue, 9 May 2017 13:01:15 -0600 Subject: [PATCH 2/2] DOC: Update 1.13 release notes. * Rearrange entries * Add "New functions" section * Replace `~` by `-`. [ci skip] --- doc/release/1.13.0-notes.rst | 258 +++++++++++++++++++---------------- 1 file changed, 137 insertions(+), 121 deletions(-) diff --git a/doc/release/1.13.0-notes.rst b/doc/release/1.13.0-notes.rst index 9dea7086a71d..a712c6949899 100644 --- a/doc/release/1.13.0-notes.rst +++ b/doc/release/1.13.0-notes.rst @@ -4,7 +4,7 @@ NumPy 1.13.0 Release Notes This release supports Python 2.7 and 3.4 - 3.6. - + Highlights ========== @@ -12,12 +12,23 @@ Highlights resulting in less memory use and faster execution. * Inplace operations check if inputs overlap outputs and create temporaries to avoid problems. - * Improved ability for classes to override default ufunc behavior. See - ``__array_ufunc__`` below. + * New ``__array_ufunc__`` attribute provides improved ability for classes to + override default ufunc behavior. + * New ``np.block`` function for creating blocked arrays. + +New functions +============= -Dropped Support -=============== +* New ``np.positive`` ufunc. +* New ``np.divmod`` ufunc provides more efficient divmod. +* New ``np.isnat`` ufunc tests for NaT special values. +* New ``np.heaviside`` ufunc computes the Heaviside function. +* New ``np.isin`` function, improves on ``in1d``. +* New ``np.block`` function for creating blocked arrays. +* New ``PyArray_MapIterArrayCopyIfOverlap`` added to NumPy C-API. + +See below for details. Deprecations @@ -43,12 +54,6 @@ Deprecations * Calling ``ndarray.conjugate`` on non-numeric dtypes is deprecated (it should match the behavior of ``np.conjugate``, which throws an error). -Build System Changes -==================== - -* ``numpy.distutils`` now automatically determines C-file dependencies with - GCC compatible compilers. - Future Changes ============== @@ -62,6 +67,13 @@ Future Changes NumPy 1.14. +Build System Changes +==================== + +* ``numpy.distutils`` now automatically determines C-file dependencies with + GCC compatible compilers. + + Compatibility notes =================== @@ -126,11 +138,11 @@ now issue a DeprecationWarning - ``.__getitem__(slice(start, end))`` should be used instead. -C API ------ +C API changes +============= GUfuncs on empty arrays and NpyIter axis removal -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +------------------------------------------------ It is now allowed to remove a zero-sized axis from NpyIter. Which may mean that code removing axes from NpyIter has to add an additional check when accessing the removed dimensions later on. @@ -143,6 +155,14 @@ For most gufuncs no change should be necessary. However, it is now possible for gufuncs with a signature such as ``(..., N, M) -> (..., M)`` to return a valid result if ``N=0`` without further wrapping code. +``PyArray_MapIterArrayCopyIfOverlap`` added to NumPy C-API +---------------------------------------------------------- +Similar to ``PyArray_MapIterArray`` but with an additional ``copy_if_overlap`` +argument. If ``copy_if_overlap != 0``, checks if input has memory overlap with +any of the other arrays and make copies as appropriate to avoid problems if the +input is modified during the iteration. See the documentation for more complete +documentation. + New Features ============ @@ -155,15 +175,67 @@ override the behavior of NumPy's ufuncs. This works quite similarly to Python's ``__mul__`` and other binary operation routines. See the documentation for a more detailed description of the implementation and behavior of this new option. The API is provisional, we do not yet guarantee backward compatibility -as modifications may be made pending feedback. +as modifications may be made pending feedback. See the NEP_ and +documentation_ for more details. -``PyArray_MapIterArrayCopyIfOverlap`` added to NumPy C-API ----------------------------------------------------------- -Similar to ``PyArray_MapIterArray`` but with an additional ``copy_if_overlap`` -argument. If ``copy_if_overlap != 0``, checks if input has memory overlap with -any of the other arrays and make copies as appropriate to avoid problems if the -input is modified during the iteration. See the documentation for more complete -documentation. +.. _NEP: https://github.com/numpy/numpy/blob/master/doc/neps/ufunc-overrides.rst +.. _documentation: https://github.com/charris/numpy/blob/master/doc/source/reference/arrays.classes.rst + +New ``positive`` ufunc +---------------------- +This ufunc corresponds to unary `+`, but unlike `+` on an ndarray it will raise +an error if array values do not support numeric operations. + +New ``divmod`` ufunc +-------------------- +This ufunc corresponds to the Python builtin `divmod`, and is used to implement +`divmod` when called on numpy arrays. ``np.divmod(x, y)`` calculates a result +equivalent to ``(np.floor_divide(x, y), np.remainder(x, y))`` but is +approximately twice as fast as calling the functions separately. + +``np.isnat`` ufunc tests for NaT special datetime and timedelta values +---------------------------------------------------------------------- +The new ufunc ``np.isnat`` finds the positions of special NaT values +within datetime and timedelta arrays. This is analogous to ``np.isnan``. + +``np.heaviside`` ufunc computes the Heaviside function +------------------------------------------------------ +The new function ``np.heaviside(x, h0)`` (a ufunc) computes the Heaviside +function: +.. code:: + { 0 if x < 0, + heaviside(x, h0) = { h0 if x == 0, + { 1 if x > 0. + +``np.block`` function for creating blocked arrays +------------------------------------------------- +Add a new ``block`` function to the current stacking functions ``vstack``, +``hstack``, and ``stack``. This allows concatenation across multiple axes +simultaneously, with a similar syntax to array creation, but where elements +can themselves be arrays. For instance:: + + >>> A = np.eye(2) * 2 + >>> B = np.eye(3) * 3 + >>> np.block([ + ... [A, np.zeros((2, 3))], + ... [np.ones((3, 2)), B ] + ... ]) + array([[ 2., 0., 0., 0., 0.], + [ 0., 2., 0., 0., 0.], + [ 1., 1., 3., 0., 0.], + [ 1., 1., 0., 3., 0.], + [ 1., 1., 0., 0., 3.]]) + +While primarily useful for block matrices, this works for arbitrary dimensions +of arrays. + +It is similar to Matlab's square bracket notation for creating block matrices. + +``isin`` function, improving on ``in1d`` +---------------------------------------- +The new function ``isin`` tests whether each element of an N-dimensonal +array is present anywhere within a second array. It is an enhancement +of ``in1d`` that preserves the shape of the first array. Temporary elision ----------------- @@ -179,17 +251,6 @@ In an N-dimensional array, the user can now choose the axis along which to look for duplicate N-1-dimensional elements using ``numpy.unique``. The original behaviour is recovered if ``axis=None`` (default). -``np.isnat`` function to test for NaT special datetime and timedelta values -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -``np.isnat`` can now be used to find the positions of special NaT values -within datetime and timedelta arrays. This is analogous to ``np.isnan``. - -``isin`` function, improving on ``in1d`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The new function ``isin`` tests whether each element of an N-dimensonal -array is present anywhere within a second array. It is an enhancement -of ``in1d`` that preserves the shape of the first array. - ``np.gradient`` now supports unevenly spaced data ------------------------------------------------- Users can now specify a not-constant spacing for data. @@ -211,15 +272,6 @@ This means that, e.g., it is now possible to do the following:: [array([[ 1. , 1. , -0.5], [ 1. , 1. , -0.5]]), array([[ 2. , 2. , 2. ], [ 2. , 1.7, 0.5]])] -``np.heaviside`` computes the Heaviside function ------------------------------------------------- -The new function ``np.heaviside(x, h0)`` (a ufunc) computes the Heaviside -function: -.. code:: - { 0 if x < 0, - heaviside(x, h0) = { h0 if x == 0, - { 1 if x > 0. - Support for returning arrays of arbitrary dimensions in ``apply_along_axis`` ---------------------------------------------------------------------------- Previously, only scalars or 1D arrays could be returned by the function passed @@ -232,30 +284,6 @@ being iterated over. For consistency with ``ndarray`` and ``broadcast``, ``d.ndim`` is a shorthand for ``len(d.shape)``. -``np.block`` function for creating blocked arrays -------------------------------------------------- -Add a new ``block`` function to the current stacking functions ``vstack``, -``hstack``, and ``stack``. This allows concatenation across multiple axes -simultaneously, with a similar syntax to array creation, but where elements -can themselves be arrays. For instance:: - - >>> A = np.eye(2) * 2 - >>> B = np.eye(3) * 3 - >>> np.block([ - ... [A, np.zeros((2, 3))], - ... [np.ones((3, 2)), B ] - ... ]) - array([[ 2., 0., 0., 0., 0.], - [ 0., 2., 0., 0., 0.], - [ 1., 1., 3., 0., 0.], - [ 1., 1., 0., 3., 0.], - [ 1., 1., 0., 0., 3.]]) - -While primarily useful for block matrices, this works for arbitrary dimensions -of arrays. - -It is similar to Matlab's square bracket notation for creating block matrices. - Support for tracemalloc in Python 3.6 ------------------------------------- NumPy now supports memory tracing with tracemalloc_ module of Python 3.6 or @@ -283,6 +311,49 @@ now disabled by default but can be enabled for test builds. Improvements ============ +Ufunc behavior for overlapping inputs +------------------------------------- + +Operations where ufunc input and output operands have memory overlap +produced undefined results in previous NumPy versions, due to data +dependency issues. In NumPy 1.13.0, results from such operations are +now defined to be the same as for equivalent operations where there is +no memory overlap. + +Operations affected now make temporary copies, as needed to eliminate +data dependency. As detecting these cases is computationally +expensive, a heuristic is used, which may in rare cases result to +needless temporary copies. For operations where the data dependency +is simple enough for the heuristic to analyze, temporary copies will +not be made even if the arrays overlap, if it can be deduced copies +are not necessary. As an example,``np.add(a, b, out=a)`` will not +involve copies. + +To illustrate a previously undefined operation:: + + >>> x = np.arange(16).astype(float) + >>> np.add(x[1:], x[:-1], out=x[1:]) + +In NumPy 1.13.0 the last line is guaranteed to be equivalent to:: + + >>> np.add(x[1:].copy(), x[:-1].copy(), out=x[1:]) + +A similar operation with simple non-problematic data dependence is:: + + >>> x = np.arange(16).astype(float) + >>> np.add(x[1:], x[:-1], out=x[:-1]) + +It will continue to produce the same results as in previous NumPy +versions, and will not involve unnecessary temporary copies. + +The change applies also to in-place binary operations, for example:: + + >>> x = np.random.rand(500, 500) + >>> x += x.T + +This statement is now guaranteed to be equivalent to ``x[...] = x + x.T``, +whereas in previous NumPy versions the results were undefined. + Partial support for 64-bit f2py extensions with MinGW ----------------------------------------------------- Extensions that incorporate Fortran libraries can now be built using the free @@ -363,18 +434,6 @@ regarding "workspace" sizes, and in some places may use faster algorithms. This now works on empty arrays, returning 0, and can reduce over multiple axes. Previously, a ``ValueError`` was thrown in these cases. -New ``positive`` ufunc ----------------------- -This ufunc corresponds to unary `+`, but unlike `+` on an ndarray it will raise -an error if array values do not support numeric operations. - -New ``divmod`` ufunc --------------------- -This ufunc corresponds to the Python builtin `divmod`, and is used to implement -`divmod` when called on numpy arrays. ``np.divmod(x, y)`` calculates a result -equivalent to ``(np.floor_divide(x, y), np.remainder(x, y))`` but is -approximately twice as fast as calling the functions separately. - Better ``repr`` of object arrays -------------------------------- Object arrays that contain themselves no longer cause a recursion error. @@ -385,49 +444,6 @@ clear the difference between a 2d object array, and a 1d object array of lists. Changes ======= -Ufunc behavior for overlapping inputs -------------------------------------- - -Operations where ufunc input and output operands have memory overlap -produced undefined results in previous NumPy versions, due to data -dependency issues. In NumPy 1.13.0, results from such operations are -now defined to be the same as for equivalent operations where there is -no memory overlap. - -Operations affected now make temporary copies, as needed to eliminate -data dependency. As detecting these cases is computationally -expensive, a heuristic is used, which may in rare cases result to -needless temporary copies. For operations where the data dependency -is simple enough for the heuristic to analyze, temporary copies will -not be made even if the arrays overlap, if it can be deduced copies -are not necessary. As an example,``np.add(a, b, out=a)`` will not -involve copies. - -To illustrate a previously undefined operation:: - - >>> x = np.arange(16).astype(float) - >>> np.add(x[1:], x[:-1], out=x[1:]) - -In NumPy 1.13.0 the last line is guaranteed to be equivalent to:: - - >>> np.add(x[1:].copy(), x[:-1].copy(), out=x[1:]) - -A similar operation with simple non-problematic data dependence is:: - - >>> x = np.arange(16).astype(float) - >>> np.add(x[1:], x[:-1], out=x[:-1]) - -It will continue to produce the same results as in previous NumPy -versions, and will not involve unnecessary temporary copies. - -The change applies also to in-place binary operations, for example:: - - >>> x = np.random.rand(500, 500) - >>> x += x.T - -This statement is now guaranteed to be equivalent to ``x[...] = x + x.T``, -whereas in previous NumPy versions the results were undefined. - ``argsort`` on masked arrays takes the same default arguments as ``sort`` ------------------------------------------------------------------------- By default, ``argsort`` now places the masked values at the end of the sorted