1
1
NumPy 1.12.0 Release Notes
2
2
**************************
3
3
4
- This release supports Python 2.7 and 3.4 - 3.5 .
4
+ This release supports Python 2.7 and 3.4 - 3.6 .
5
5
6
6
Highlights
7
7
==========
8
8
9
9
* Order of operations in ``np.einsum `` now can be optimized for large speed improvements.
10
10
* New ``signature `` argument to ``np.vectorize `` for vectorizing with core dimensions.
11
+ * The ``keepdims `` argument was added to many functions.
11
12
12
13
Dropped Support
13
14
===============
@@ -43,8 +44,9 @@ corresponding to intervening fields in the original array, unlike the copy in
43
44
1.12, which will affect code such as ``arr[['f1', 'f3']].view(newdtype) ``.
44
45
45
46
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::
48
50
49
51
>>> a = np.array([(1,2),(3,4)], dtype=[('x', 'i4'), ('y', 'i4')])
50
52
>>> 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:
53
55
array([(0, 2, 1), (0, 4, 3)],
54
56
dtype=[('z', '<i4'), ('y', '<i4'), ('x', '<i4')])
55
57
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']] ``.
60
63
61
64
62
65
Compatibility notes
@@ -74,6 +77,14 @@ DeprecationWarning to error
74
77
* Non-integers used as index values raise ``TypeError ``,
75
78
e.g., in ``reshape ``, ``take ``, and specifying reduce axis.
76
79
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
+
77
88
``power `` and ``** `` raise errors for integer to negative integer powers
78
89
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
79
90
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
98
109
exceptions for the integer units. If you need negative powers, use an inexact
99
110
type.
100
111
101
-
102
-
103
112
Relaxed stride checking is the default
104
113
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
105
114
This will have some impact on code that assumed that ``F_CONTIGUOUS `` and
106
115
``C_CONTIGUOUS `` were mutually exclusive and could be set to determine the
107
116
default order for arrays that are now both.
108
117
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
112
121
the two coincide. Previous behavior of 'lower' + 0.5 is fixed.
113
122
114
-
115
123
``keepdims `` kwarg is passed through to user-class methods
116
124
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
117
125
numpy functions that take a ``keepdims `` kwarg now pass the value
@@ -127,7 +135,6 @@ the following behavior:
127
135
This will raise in the case where the method does not support a
128
136
``keepdims `` kwarg and the user explicitly passes in ``keepdims ``.
129
137
130
-
131
138
The following functions are changed: ``sum ``, ``product ``,
132
139
``sometrue ``, ``alltrue ``, ``any ``, ``all ``, ``amax ``, ``amin ``,
133
140
``prod ``, ``mean ``, ``std ``, ``var ``, ``nanmin ``, ``nanmax ``,
@@ -139,18 +146,10 @@ The following functions are changed: ``sum``, ``product``,
139
146
The previous identity was 1, it is now -1. See entry in `Improvements `_ for
140
147
more explanation.
141
148
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
-
150
149
Greater consistancy in ``assert_almost_equal ``
151
150
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
152
151
The precision check for scalars has been changed to match that for arrays. It
153
- is now
152
+ is now::
154
153
155
154
abs(actual - desired) < 1.5 * 10**(-decimal)
156
155
@@ -178,9 +177,9 @@ may mean that warnings that were incorrectly ignored will now be shown
178
177
or raised. See also the new ``suppress_warnings `` context manager.
179
178
The same is true for the ``deprecated `` decorator.
180
179
181
-
182
180
C API
183
181
~~~~~
182
+ No changes.
184
183
185
184
186
185
New Features
@@ -193,7 +192,6 @@ keyword argument. It can be set to False when no write operation
193
192
to the returned array is expected to avoid accidental
194
193
unpredictable writes.
195
194
196
-
197
195
``axes `` keyword argument for ``rot90 ``
198
196
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
199
197
The ``axes `` keyword argument in ``rot90 `` determines the plane in which the
@@ -217,7 +215,6 @@ the numpy repo or source distribution).
217
215
218
216
Hook in ``numpy/__init__.py `` to run distribution-specific checks
219
217
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
220
-
221
218
Binary distributions of numpy may need to run specific hardware checks or load
222
219
specific libraries during numpy initialization. For example, if we are
223
220
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.
230
227
231
228
New nanfunctions ``nancumsum `` and ``nancumprod `` added
232
229
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
233
- Nanfunctions ``nancumsum `` and ``nancumprod `` have been added to
230
+ Nan-functions ``nancumsum `` and ``nancumprod `` have been added to
234
231
compute ``cumsum `` and ``cumprod `` by ignoring nans.
235
232
236
233
``np.interp `` can now interpolate complex values
@@ -254,7 +251,6 @@ to ``logspace``, but with start and stop specified directly:
254
251
255
252
New context manager for testing warnings
256
253
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
257
-
258
254
A new context manager ``suppress_warnings `` has been added to the testing
259
255
utils. This context manager is designed to help reliably test warnings.
260
256
Specifically to reliably filter/ignore warnings. Ignoring warnings
@@ -284,10 +280,6 @@ integer powers and a popular proposal was that the ``__pow__`` operator should
284
280
always return results of at least float64 precision. The ``float_power ``
285
281
function implements that option. Note that it does not support object arrays.
286
282
287
-
288
- Improvements
289
- ============
290
-
291
283
``np.loadtxt `` now supports a single integer as ``usecol `` argument
292
284
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
293
285
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``
300
292
argument. Added support for range-restricted histograms with automated
301
293
bin estimation.
302
294
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
316
296
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
317
297
The ``shift `` and ``axis `` arguments to ``roll `` are now broadcast against each
318
298
other, and each specified axis is shifted accordingly.
319
299
320
- The * __complex__ * method has been implemented on the ndarray object
321
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
300
+ The `` __complex__ `` method has been implemented for the ndarrays
301
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
322
302
Calling ``complex() `` on a size 1 array will now cast to a python
323
303
complex.
324
304
@@ -328,11 +308,59 @@ The standard ``np.load``, ``np.save``, ``np.loadtxt``, ``np.savez``, and similar
328
308
functions can now take ``pathlib.Path `` objects as an argument instead of a
329
309
filename or open file object.
330
310
331
- Add ``bits `` attribute to ``np.finfo ``
332
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
311
+ New ``bits `` attribute for ``np.finfo ``
312
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
333
313
This makes ``np.finfo `` consistent with ``np.iinfo `` which already has that
334
314
attribute.
335
315
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
+
336
364
Caches in `np.fft ` are now bounded in total size and item count
337
365
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
338
366
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
364
392
been applied to the general einsum summation notation. See ``np.einsum_path ``
365
393
for more details.
366
394
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)) ``.
376
401
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
390
402
391
403
Changes
392
404
=======
@@ -410,28 +422,16 @@ from these operations.
410
422
Also, reduction of a memmap (e.g. ``.sum(axis=None ``) now returns a numpy
411
423
scalar instead of a 0d memmap.
412
424
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
-
425
425
stacklevel of warnings increased
426
426
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
427
427
The stacklevel for python based warnings was increased so that most warnings
428
428
will report the offending line of the user code instead of the line the
429
429
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.
431
431
432
432
This causes warnings with the "default" or "module" filter to be shown once
433
433
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
435
435
ignored before, which may be surprising especially in test suits.
436
436
437
437
0 commit comments