8000 Merge pull request #8240 from charris/prepare-for-1.12-branch · numpy/numpy@1718ee8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1718ee8

Browse files
authored
Merge pull request #8240 from charris/prepare-for-1.12-branch
REL: Prepare for 1.12.x branch
2 parents 8c49b92 + c2503ed commit 1718ee8

File tree

4 files changed

+88
-85
lines changed

4 files changed

+88
-85
lines changed

doc/release/1.12.0-notes.rst

Lines changed: 85 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
NumPy 1.12.0 Release Notes
22
**************************
33

4-
This release supports Python 2.7 and 3.4 - 3.5.
4+
This release supports Python 2.7 and 3.4 - 3.6.
55

66
Highlights
77
==========
88

99
* Order of operations in ``np.einsum`` now can be optimized for large speed improvements.
1010
* New ``signature`` argument to ``np.vectorize`` for vectorizing with core dimensions.
11+
* The ``keepdims`` argument was added to many functions.
1112

1213
Dropped Support
1314
===============
@@ -43,8 +44,9 @@ corresponding to intervening fields in the original array, unlike the copy in
4344
1.12, which will affect code such as ``arr[['f1', 'f3']].view(newdtype)``.
4445

4546
Second, for numpy versions 1.6 to 1.12 assignment between structured arrays
46-
occurs "by field name": Fields in the dst array are set to the
47-
identically-named field in the src or to 0 if the src does not have a field:
47+
occurs "by field name": Fields in the destination array are set to the
48+
identically-named field in the source array or to 0 if the source does not have
49+
a field::
4850

4951
>>> a = np.array([(1,2),(3,4)], dtype=[('x', 'i4'), ('y', 'i4')])
5052
>>> b = np.ones(2, dtype=[('z', 'i4'), ('y', 'i4'), ('x', 'i4')])
@@ -53,10 +55,11 @@ identically-named field in the src or to 0 if the src does not have a field:
5355
array([(0, 2, 1), (0, 4, 3)],
5456
dtype=[('z', '<i4'), ('y', '<i4'), ('x', '<i4')])
5557

56-
In 1.13 assignment will instead occur "by position": The Nth field of the dst
57-
will be set to the Nth field of the src, regardless of field name. The old
58-
behavior can be obtained by using indexing to reorder the fields before
59-
assignment, eg ``b[['x', 'y']] = a[['y', 'x']]``.
58+
In 1.13 assignment will instead occur "by position": The Nth field of the
59+
destination will be set to the Nth field of the source regardless of field
60+
name. The old behavior can be obtained by using indexing to reorder the fields
61+
before
62+
assignment, e.g., ``b[['x', 'y']] = a[['y', 'x']]``.
6063

6164

6265
Compatibility notes
@@ -74,6 +77,14 @@ DeprecationWarning to error
7477
* Non-integers used as index values raise ``TypeError``,
7578
e.g., in ``reshape``, ``take``, and specifying reduce axis.
7679

80+
FutureWarning to changed behavior
81+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
82+
83+
* ``np.full`` now returns an array of the fill-value's dtype if no dtype is
84+
given, instead of defaulting to float.
85+
* np.average will emit a warning if the argument is a subclass of ndarray,
86+
as the subclass will be preserved starting in 1.13. (see Future Changes)
87+
7788
``power`` and ``**`` raise errors for integer to negative integer powers
7889
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7990
The previous behavior depended on whether numpy scalar integers or numpy
@@ -98,20 +109,17 @@ felt that a simple rule was the best way to go rather than have special
98109
exceptions for the integer units. If you need negative powers, use an inexact
99110
type.
100111

101-
102-
103112
Relaxed stride checking is the default
104113
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
105114
This will have some impact on code that assumed that ``F_CONTIGUOUS`` and
106115
``C_CONTIGUOUS`` were mutually exclusive and could be set to determine the
107116
default order for arrays that are now both.
108117

109-
``np.percentile`` 'midpoint' interpolation method fixed for exact indices
110-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
111-
'midpoint' interpolator now gives the same result as 'lower' and 'higher' when
118+
The ``np.percentile`` 'midpoint' interpolation method fixed for exact indices
119+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
120+
The 'midpoint' interpolator now gives the same result as 'lower' and 'higher' when
112121
the two coincide. Previous behavior of 'lower' + 0.5 is fixed.
113122

114-
115123
``keepdims`` kwarg is passed through to user-class methods
116124
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
117125
numpy functions that take a ``keepdims`` kwarg now pass the value
@@ -127,7 +135,6 @@ the following behavior:
127135
This will raise in the case where the method does not support a
128136
``keepdims`` kwarg and the user explicitly passes in ``keepdims``.
129137

130-
131138
The following functions are changed: ``sum``, ``product``,
132139
``sometrue``, ``alltrue``, ``any``, ``all``, ``amax``, ``amin``,
133140
``prod``, ``mean``, ``std``, ``var``, ``nanmin``, ``nanmax``,
@@ -139,18 +146,10 @@ The following functions are changed: ``sum``, ``product``,
139146
The previous identity was 1, it is now -1. See entry in `Improvements`_ for
140147
more explanation.
141148

142-
FutureWarning to changed behavior
143-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
144-
145-
* ``np.full`` now returns an array of the fill-value's dtype if no dtype is
146-
given, instead of defaulting to float.
147-
* np.average will emit a warning if the argument is a subclass of ndarray,
148-
as the subclass will be preserved starting in 1.13. (see Future Changes)
149-
150149
Greater consistancy in ``assert_almost_equal``
151150
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
152151
The precision check for scalars has been changed to match that for arrays. It
153-
is now
152+
is now::
154153

155154
abs(actual - desired) < 1.5 * 10**(-decimal)
156155

@@ -178,9 +177,9 @@ may mean that warnings that were incorrectly ignored will now be shown
178177
or raised. See also the new ``suppress_warnings`` context manager.
179178
The same is true for the ``deprecated`` decorator.
180179

181-
182180
C API
183181
~~~~~
182+
No changes.
184183

185184

186185
New Features
@@ -193,7 +192,6 @@ keyword argument. It can be set to False when no write operation
193192
to the returned array is expected to avoid accidental
194193
unpredictable writes.
195194

196-
197195
``axes`` keyword argument for ``rot90``
198196
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
199197
The ``axes`` keyword argument in ``rot90`` determines the plane in which the
@@ -217,7 +215,6 @@ the numpy repo or source distribution).
217215

218216
Hook in ``numpy/__init__.py`` to run distribution-specific checks
219217
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
220-
221218
Binary distributions of numpy may need to run specific hardware checks or load
222219
specific libraries during numpy initialization. For example, if we are
223220
distributing numpy with a BLAS library that requires SSE2 instructions, we
@@ -230,7 +227,7 @@ but that can be overwritten by people making binary distributions of numpy.
230227

231228
New nanfunctions ``nancumsum`` and ``nancumprod`` added
232229
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
233-
Nanfunctions ``nancumsum`` and ``nancumprod`` have been added to
230+
Nan-functions ``nancumsum`` and ``nancumprod`` have been added to
234231
compute ``cumsum`` and ``cumprod`` by ignoring nans.
235232

236233
``np.interp`` can now interpolate complex values
@@ -254,7 +251,6 @@ to ``logspace``, but with start and stop specified directly:
254251

255252
New context manager for testing warnings
256253
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
257-
258254
A new context manager ``suppress_warnings`` has been added to the testing
259255
utils. This context manager is designed to help reliably test warnings.
260256
Specifically to reliably filter/ignore warnings. Ignoring warnings
@@ -284,10 +280,6 @@ integer powers and a popular proposal was that the ``__pow__`` operator should
284280
always return results of at least float64 precision. The ``float_power``
285281
function implements that option. Note that it does not support object arrays.
286282

287-
288-
Improvements
289-
============
290-
291283
``np.loadtxt`` now supports a single integer as ``usecol`` argument
292284
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
293285
Instead of using ``usecol=(n,)`` to read the nth column of a file
@@ -300,25 +292,13 @@ Added 'doane' and 'sqrt' estimators to ``histogram`` via the ``bins``
300292
argument. Added support for range-restricted histograms with automated
301293
bin estimation.
302294

303-
``bitwise_and`` identity changed
304-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
305-
The previous identity was 1 with the result that all bits except the LSB were
306-
masked out when the reduce method was used. The new identity is -1, which
307-
should work properly on twos complement machines as all bits will be set to
308-
one.
309-
310-
Generalized Ufuncs will now unlock the GIL
311-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
312-
Generalized Ufuncs, including most of the linalg module, will now unlock
313-
the Python global interpreter lock.
314-
315-
``np.roll can now roll multiple axes at the same time``
295+
``np.roll`` can now roll multiple axes at the same time
316296
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
317297
The ``shift`` and ``axis`` arguments to ``roll`` are now broadcast against each
318298
other, and each specified axis is shifted accordingly.
319299

320-
The *__complex__* method has been implemented on the ndarray object
321-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
300+
The ``__complex__`` method has been implemented for the ndarrays
301+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
322302
Calling ``complex()`` on a size 1 array will now cast to a python
323303
complex.
324304

@@ -328,11 +308,59 @@ The standard ``np.load``, ``np.save``, ``np.loadtxt``, ``np.savez``, and similar
328308
functions can now take ``pathlib.Path`` objects as an argument instead of a
329309
filename or open file object.
330310

331-
Add ``bits`` attribute to ``np.finfo``
332-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
311+
New ``bits`` attribute for ``np.finfo``
312+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
333313
This makes ``np.finfo`` consistent with ``np.iinfo`` which already has that
334314
attribute.
335315

316+
New ``signature`` argument to ``np.vectorize``
317+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
318+
This argument allows for vectorizing user defined functions with core
319+
dimensions, in the style of NumPy's
320+
:ref:`generalized universal functions<c-api.generalized-ufuncs>`. This allows
321+
for vectorizing a much broader class of functions. For example, an arbitrary
322+
distance metric that combines two vectors to produce a scalar could be
323+
vectorized with ``signature='(n),(n)->()'``. See ``np.vectorize`` for full
324+
details.
325+
326+
Emit py3kwarnings for division of integer arrays
327+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
328+
To help people migrate their code bases from Python 2 to Python 3, the
329+
python interpreter has a handy option -3, which issues warnings at runtime.
330+
One of its warnings is for integer division::
331+
332+
$ python -3 -c "2/3"
333+
334+
-c:1: DeprecationWarning: classic int division
335+
336+
In Python 3, the new integer division semantics also apply to numpy arrays.
337+
With this version, numpy will emit a similar warning::
338+
339+
$ python -3 -c "import numpy as np; np.array(2)/np.array(3)"
340+
341+
-c:1: DeprecationWarning: numpy: classic int division
342+
343+
numpy.sctypes now includes bytes on Python3 too
344+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
345+
Previously, it included str (bytes) and unicode on Python2, but only str
346+
(unicode) on Python3.
347+
348+
349+
Improvements
350+
============
351+
352+
``bitwise_and`` identity changed
353+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
354+
The previous identity was 1 with the result that all bits except the LSB were
355+
masked out when the reduce method was used. The new identity is -1, which
356+
should work properly on twos complement machines as all bits will be set to
357+
one.
358+
359+
Generalized Ufuncs will now unlock the GIL
360+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
361+
Generalized Ufuncs, including most of the linalg module, will now unlock
362+
the Python global interpreter lock.
363+
336364
Caches in `np.fft` are now bounded in total size and item count
337365
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
338366
The caches in `np.fft` that speed up successive FFTs of the same length can no
@@ -364,29 +392,13 @@ an intermediate array to reduce this scaling to ``N^3`` or effectively
364392
been applied to the general einsum summation notation. See ``np.einsum_path``
365393
for more details.
366394

367-
New ``signature`` argument to ``np.vectorize``
368-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
369-
This argument allows for vectorizing user defined functions with core
370-
dimensions, in the style of NumPy's
371-
:ref:`generalized universal functions<c-api.generalized-ufuncs>`. This allows
372-
for vectorizing a much broader class of functions. For example, an arbitrary
373-
distance metric that combines two vectors to produce a scalar could be
374-
vectorized with ``signature='(n),(n)->()'``. See ``np.vectorize`` for full
375-
details.
395+
quicksort has been changed to an introsort
396+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
397+
The quicksort kind of ``np.sort`` and ``np.argsort`` is now an introsort which
398+
is regular quicksort but changing to a heapsort when not enough progress is
399+
made. This retains the good quicksort performance while changing the worst case
400+
runtime from ``O(N^2)`` to ``O(N*log(N))``.
376401

377-
Emit py3kwarnings for division of integer arrays
378-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
379-
To help people migrate their code bases from Python 2 to Python 3, the
380-
python interpreter has a handy option -3, which issues warnings at runtime.
381-
One of its warnings is for integer division:
382-
$ python -3 -c "2/3"
383-
384-
-c:1: DeprecationWarning: classic int division
385-
In Python 3, the new integer division semantics also apply to numpy arrays.
386-
With this version, numpy will emit a similar warning:
387-
$ python -3 -c "import numpy as np; np.array(2)/np.array(3)"
388-
389-
-c:1: DeprecationWarning: numpy: classic int division
390402

391403
Changes
392404
=======
@@ -410,28 +422,16 @@ from these operations.
410422
Also, reduction of a memmap (e.g. ``.sum(axis=None``) now returns a numpy
411423
scalar instead of a 0d memmap.
412424

413-
numpy.sctypes now includes bytes on Python3 too
414-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
415-
Previously, it included str (bytes) and unicode on Python2, but only str
416-
(unicode) on Python3.
417-
418-
quicksort has been changed to an introsort
419-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
420-
The quicksort kind of ``np.sort`` and ``np.argsort`` is now an introsort which
421-
is regular quicksort but changing to a heapsort when not enough progress is
422-
made. This retains the good quicksort performance while changing the worst case
423-
runtime from ``O(N^2)`` to ``O(N*log(N))``.
424-
425425
stacklevel of warnings increased
426426
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
427427
The stacklevel for python based warnings was increased so that most warnings
428428
will report the offending line of the user code instead of the line the
429429
warning itself is given. Passing of stacklevel is now tested to ensure that
430-
new warnings will recieve the ``stacklevel`` argument.
430+
new warnings will receive the ``stacklevel`` argument.
431431

432432
This causes warnings with the "default" or "module" filter to be shown once
433433
for every offending user code line or user module instead of only once. On
434-
python versions before 3.4, this can cause warnings to appear that were falsly
434+
python versions before 3.4, this can cause warnings to appear that were falsely
435435
ignored before, which may be surprising especially in test suits.
436436

437437

numpy/core/code_generators/cversions.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,5 @@
3232

3333
# Version 10 (NumPy 1.10) Added PyArray_CheckAnyScalarExact
3434
# Version 10 (NumPy 1.11) No change.
35+
# Version 10 (NumPy 1.12) No change.
3536
0x0000000a = 9b8bce614655d3eb02acddcb508203cb

numpy/core/include/numpy/numpyconfig.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,6 @@
3333
#define NPY_1_9_API_VERSION 0x00000008
3434
#define NPY_1_10_API_VERSION 0x00000008
3535
#define NPY_1_11_API_VERSION 0x00000008
36+
#define NPY_1_12_API_VERSION 0x00000008
3637

3738
#endif

numpy/core/setup_common.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
# 0x00000009 - 1.9.x
3838
# 0x0000000a - 1.10.x
3939
# 0x0000000a - 1.11.x
40+
# 0x0000000a - 1.12.x
4041
C_API_VERSION = 0x0000000a
4142

4243
class MismatchCAPIWarning(Warning):

0 commit comments

Comments
 (0)
0