NumPy 1.19.0 Release Notes
This NumPy release is marked by the removal of much technical debt:
support for Python 2 has been removed, many deprecations have been
expired, and documentation has been improved. The polishing of the
random module continues apace with bug fixes and better usability from
Cython.
The Python versions supported for this release are 3.63.8. Downstream
developers should use Cython >= 0.29.16 for Python 3.8 support and
OpenBLAS >= 3.7 to avoid problems on the Skylake architecture.
Highlights

Code compatibility with Python versions < 3.6 (including Python 2)
was dropped from both the python and C code. The shims in
numpy.compat
will remain to support thirdparty packages, but they
may be deprecated in a future release. Note that 1.19.x will not
compile with earlier versions of Python due to the use of fstrings.(gh15233)
Expired deprecations
numpy.insert
and numpy.delete
can no longer be passed an axis on 0d arrays
This concludes a deprecation from 1.9, where when an axis
argument was
passed to a call to ~numpy.insert
and ~numpy.delete
on a 0d array,
the axis
and obj
argument and indices would be completely ignored.
In these cases, insert(arr, "nonsense", 42, axis=0)
would actually
overwrite the entire array, while delete(arr, "nonsense", axis=0)
would be arr.copy()
Now passing axis
on a 0d array raises ~numpy.AxisError
.
(gh15802)
numpy.delete
no longer ignores outofbounds indices
This concludes deprecations from 1.8 and 1.9, where np.delete
would
ignore both negative and outofbounds items in a sequence of indices.
This was at odds with its behavior when passed a single index.
Now outofbounds items throw IndexError
, and negative items index
from the end.
(gh15804)
numpy.insert
and numpy.delete
no longer accept nonintegral indices
This concludes a deprecation from 1.9, where sequences of nonintegers
indices were allowed and cast to integers. Now passing sequences of
nonintegral indices raises IndexError
, just like it does when passing
a single nonintegral scalar.
(gh15805)
numpy.delete
no longer casts boolean indices to integers
This concludes a deprecation from 1.8, where np.delete
would cast
boolean arrays and scalars passed as an index argument into integer
indices. The behavior now is to treat boolean arrays as a mask, and to
raise an error on boolean scalars.
(gh15815)
Compatibility notes
Changed random variate stream from numpy.random.Generator.dirichlet
A bug in the generation of random variates for the Dirichlet
distribution with small 'alpha' values was fixed by using a different
algorithm when max(alpha) < 0.1
. Because of the change, the stream of
variates generated by dirichlet
in this case will be different from
previous releases.
(gh14924)
Scalar promotion in PyArray_ConvertToCommonType
The promotion of mixed scalars and arrays in
PyArray_ConvertToCommonType
has been changed to adhere to those used
by np.result_type
. This means that input such as
(1000, np.array([1], dtype=np.uint8)))
will now return uint16
dtypes. In most cases the behaviour is unchanged. Note that the use of
this CAPI function is generally discouraged. This also fixes
np.choose
to behave the same way as the rest of NumPy in this respect.
(gh14933)
Fasttake and fastputmask slots are deprecated and NULL'ed
The fasttake and fastputmask slots are now never used and must always be
set to NULL. This will result in no change in behaviour. However, if a
user dtype should set one of these a DeprecationWarning will be given.
(gh14942)
np.ediff1d
casting behaviour with to_end
and to_begin
np.ediff1d
now uses the "same_kind"
casting rule for its additional
to_end
and to_begin
arguments. This ensures type safety except when
the input array has a smaller integer type than to_begin
or to_end
.
In rare cases, the behaviour will be more strict than it was previously
in 1.16 and 1.17. This is necessary to solve issues with floating point
NaN.
(gh14981)
Converting of empty arraylike objects to NumPy arrays
Objects with len(obj) == 0
which implement an "arraylike"
interface, meaning an object implementing obj.__array__()
,
obj.__array_interface__
, obj.__array_struct__
, or the python buffer
interface and which are also sequences (i.e. Pandas objects) will now
always retain there shape correctly when converted to an array. If such
an object has a shape of (0, 1)
previously, it could be converted into
an array of shape (0,)
(losing all dimensions after the first 0).
(gh14995)
Removed multiarray.int_asbuffer
As part of the continued removal of Python 2 compatibility,
multiarray.int_asbuffer
was removed. On Python 3, it threw a
NotImplementedError
and was unused internally. It is expected that
there are no downstream use cases for this method with Python 3.
(gh15229)
numpy.distutils.compat
has been removed
This module contained only the function get_exception()
, which was
used as:
try:
...
except Exception:
e = get_exception()
Its purpose was to handle the change in syntax introduced in Python 2.6,
from except Exception, e:
to except Exception as e:
, meaning it was
only necessary for codebases supporting Python 2.5 and older.
(gh15255)
issubdtype
no longer interprets float
as np.floating
numpy.issubdtype
had a FutureWarning since NumPy 1.14 which has
expired now. This means that certain input where the second argument was
neither a datatype nor a NumPy scalar type (such as a string or a python
type like int
or float
) will now be consistent with passing in
np.dtype(arg2).type
. This makes the result consistent with
expectations and leads to a false result in some cases which previously
returned true.
(gh15773)
Change output of round
on scalars to be consistent with Python
Output of the __round__
dunder method and consequently the Python
builtin round
has been changed to be a Python int
to be consistent
with calling it on Python float
objects when called with no arguments.
Previously, it would return a scalar of the np.dtype
that was passed
in.
(gh15840)
The numpy.ndarray
constructor no longer interprets strides=()
as strides=None
The former has changed to have the expected meaning of setting
numpy.ndarray.strides
to ()
, while the latter continues to result in
strides being chosen automatically.
(gh15882)
CLevel string to datetime casts changed
The Clevel casts from strings were simplified. This changed also fixes
string to datetime and timedelta casts to behave correctly (i.e. like
Python casts using string_arr.astype("M8")
while previously the cast
would behave like string_arr.astype(np.int_).astype("M8")
. This only
affects code using lowlevel CAPI to do manual casts (not full array
casts) of single scalar values or using e.g. PyArray_GetCastFunc
, and
should thus not affect the vast majority of users.
(gh16068)
SeedSequence
with small seeds no longer conflicts with spawning
Small seeds (less than 2**96
) were previously implicitly 0padded out
to 128 bits, the size of the internal entropy pool. When spawned, the
spawn key was concatenated before the 0padding. Since the first spawn
key is (0,)
, small seeds before the spawn created the same states as
the first spawned SeedSequence
. Now, the seed is explicitly 0padded
out to the internal pool size before concatenating the spawn key.
Spawned SeedSequences
will produce different results than in the
previous release. Unspawned SeedSequences
will still produce the same
results.
(gh16551)
Deprecations
Deprecate automatic dtype=object
for ragged input
Calling np.array([[1, [1, 2, 3]])
will issue a DeprecationWarning
as
per NEP 34. Users should
explicitly use dtype=object
to avoid the warning.
(gh15119)
Passing shape=0
to factory functions in numpy.rec
is deprecated
0
is treated as a special case and is aliased to None
in the
functions:
numpy.core.records.fromarrays
numpy.core.records.fromrecords
numpy.core.records.fromstring
numpy.core.records.fromfile
In future, 0
will not be special cased, and will be treated as an
array length like any other integer.
(gh15217)
Deprecation of probably unused CAPI functions
The following CAPI functions are probably unused and have been
deprecated:
PyArray_GetArrayParamsFromObject
PyUFunc_GenericFunction
PyUFunc_SetUsesArraysAsData
In most cases PyArray_GetArrayParamsFromObject
should be replaced by
converting to an array, while PyUFunc_GenericFunction
can be replaced
with PyObject_Call
(see documentation for details).
(gh15427)
Converting certain types to dtypes is Deprecated
The super classes of scalar types, such as np.integer
, np.generic
,
or np.inexact
will now give a deprecation warning when converted to a
dtype (or used in a dtype keyword argument). The reason for this is that
np.integer
is converted to np.int_
, while it would be expected to
represent any integer (e.g. also int8
, int16
, etc. For example,
dtype=np.floating
is currently identical to dtype=np.float64
, even
though also np.float32
is a subclass of np.floating
.
(gh15534)
Deprecation of round
for np.complexfloating
scalars
Output of the __round__
dunder method and consequently the Python
builtin round
has been deprecated on complex scalars. This does not
affect np.round
.
(gh15840)
numpy.ndarray.tostring()
is deprecated in favor of tobytes()
~numpy.ndarray.tobytes
has existed since the 1.9 release, but until
this release ~numpy.ndarray.tostring
emitted no warning. The change to
emit a warning brings NumPy in line with the builtin array.array
methods of the same name.
(gh15867)
C API changes
Better support for const
dimensions in API functions
The following functions now accept a constant array of npy_intp
:
PyArray_BroadcastToShape
PyArray_IntTupleFromIntp
PyArray_OverflowMultiplyList
Previously the caller would have to cast away the constness to call
these functions.
(gh15251)
Const qualify UFunc inner loops
UFuncGenericFunction
now expects pointers to const dimension
and
strides
as arguments. This means inner loops may no longer modify
either dimension
or strides
. This change leads to an
incompatiblepointertypes
warning forcing users to either ignore the
compiler warnings or to const qualify their own loop signatures.
(gh15355)
New Features
numpy.frompyfunc
now accepts an identity argument
This allows the `numpy.ufunc.identity
{.interpretedtext
role="attr"}[ attribute to be set on the resulting ufunc, meaning it can
be used for empty and multidimensional calls to
:meth:]{.titleref}[numpy.ufunc.reduce]{.titleref}`.
(gh8255)
np.str_
scalars now support the buffer protocol
np.str_
arrays are always stored as UCS4, so the corresponding scalars
now expose this through the buffer interface, meaning
memoryview(np.str_('test'))
now works.
(gh15385)
subok
option for numpy.copy
A new kwarg, subok
, was added to numpy.copy
to allow users to toggle
the behavior of numpy.copy
with respect to array subclasses. The
default value is False
which is consistent with the behavior of
numpy.copy
for previous numpy versions. To create a copy that
preserves an array subclass with numpy.copy
, call
np.copy(arr, subok=True)
. This addition better documents that the
default behavior of numpy.copy
differs from the numpy.ndarray.copy
method which respects array subclasses by default.
(gh15685)
numpy.linalg.multi_dot
now accepts an out
argument
out
can be used to avoid creating unnecessary copies of the final
product computed by numpy.linalg.multidot
.
(gh15715)
keepdims
parameter for numpy.count_nonzero
The parameter keepdims
was added to numpy.count_nonzero
. The
parameter has the same meaning as it does in reduction functions such as
numpy.sum
or numpy.mean
.
(gh15870)
equal_nan
parameter for numpy.array_equal
The keyword argument equal_nan
was added to numpy.array_equal
.
equal_nan
is a boolean value that toggles whether or not nan
values
are considered equal in comparison (default is False
). This matches
API used in related functions such as numpy.isclose
and
numpy.allclose
.
(gh16128)
Improvements
Improve detection of CPU features
Replace npy_cpu_supports
which was a gcc specific mechanism to test
support of AVX with more general functions npy_cpu_init
and
npy_cpu_have
, and expose the results via a NPY_CPU_HAVE
cmacro as
well as a pythonlevel __cpu_features__
dictionary.
(gh13421)
Use 64bit integer size on 64bit platforms in fallback lapack_lite
Use 64bit integer size on 64bit platforms in the fallback LAPACK
library, which is used when the system has no LAPACK installed, allowing
it to deal with linear algebra for large arrays.
(gh15218)
Use AVX512 intrinsic to implement np.exp
when input is np.float64
Use AVX512 intrinsic to implement np.exp
when input is np.float64
,
which can improve the performance of np.exp
with np.float64
input
57x faster than before. The _multiarray_umath.so
module has grown
about 63 KB on linux64.
(gh15648)
Ability to disable madvise hugepages
On Linux NumPy has previously added support for madavise hugepages which
can improve performance for very large arrays. Unfortunately, on older
Kernel versions this led to peformance regressions, thus by default the
support has been disabled on kernels before version 4.6. To override the
default, you can use the environment variable:
NUMPY_MADVISE_HUGEPAGE=0
or set it to 1 to force enabling support. Note that this only makes a
difference if the operating system is set up to use madvise transparent
hugepage.
(gh15769)
numpy.einsum
accepts NumPy int64
type in subscript list
There is no longer a type error thrown when numpy.einsum
is passed a
NumPy int64
array as its subscript list.
(gh16080)
np.logaddexp2.identity
changed to inf
The ufunc ~numpy.logaddexp2
now has an identity of inf
, allowing it
to be called on empty sequences. This matches the identity of
~numpy.logaddexp
.
(gh16102)
Changes
Remove handling of extra argument to __array__
A code path and test have been in the code since NumPy 0.4 for a
twoargument variant of __array__(dtype=None, context=None)
. It was
activated when calling ufunc(op)
or ufunc.reduce(op)
if
op.__array__
existed. However that variant is not documented, and it
is not clear what the intention was for its use. It has been removed.
(gh15118)
numpy.random._bit_generator
moved to numpy.random.bit_generator
In order to expose numpy.random.BitGenerator
and
numpy.random.SeedSequence
to Cython, the _bitgenerator
module is now
public as numpy.random.bit_generator
Cython access to the random distributions is provided via a pxd
file
c_distributions.pxd
provides access to the c functions behind many of
the random distributions from Cython, making it convenient to use and
extend them.
(gh15463)
Fixed eigh
and cholesky
methods in numpy.random.multivariate_normal
Previously, when passing method='eigh'
or method='cholesky'
,
numpy.random.multivariate_normal
produced samples from the wrong
distribution. This is now fixed.
(gh15872)
Fixed the jumping implementation in MT19937.jumped
This fix changes the stream produced from jumped MT19937 generators. It
does not affect the stream produced using RandomState
or MT19937
that are directly seeded.
The translation of the jumping code for the MT19937 contained a reversed
loop ordering. MT19937.jumped
matches the Makoto Matsumoto's original
implementation of the Horner and Sliding Window jump methods.
(gh16153)
Checksums
MD5
17e9b15e5b54f6963da30e9de93437b8 numpy1.19.0cp36cp36mmacosx_10_9_x86_64.whl
2117953099e3343e6ac642de66c7127f numpy1.19.0cp36cp36mmanylinux1_i686.whl
fe0d7f18fd5af93cb027fe0e2462b3bc numpy1.19.0cp36cp36mmanylinux1_x86_64.whl
23a76cbf0cec80d59d48f2342de13cb2 numpy1.19.0cp36cp36mmanylinux2010_i686.whl
3b35908cd21ce6558ec61806bbc9efee numpy1.19.0cp36cp36mmanylinux2010_x86_64.whl
b35af24ffa550054aadb620f6afb7d67 numpy1.19.0cp36cp36mmanylinux2014_aarch64.whl
5d2a0e9c23383abed01c2795c6e9f2c1 numpy1.19.0cp36cp36mwin32.whl
e0548c4ec436abb249d2e59ed5fd727f numpy1.19.0cp36cp36mwin_amd64.whl
3f939fa2f3b2f881862f7e02a0116970 numpy1.19.0cp37cp37mmacosx_10_9_x86_64.whl
012026c54f196b8f342e4b49cb4b9294 numpy1.19.0cp37cp37mmanylinux1_i686.whl
27227fdd6329f098fc9a85e9d40b1916 numpy1.19.0cp37cp37mmanylinux1_x86_64.whl
a471c34d7a07468c09696165eae0cd57 numpy1.19.0cp37cp37mmanylinux2010_i686.whl
27af6195869cd518f5d2a71885f21806 numpy1.19.0cp37cp37mmanylinux2010_x86_64.whl
62dbe6623e9aebd2bb1aef6d1e0f815d numpy1.19.0cp37cp37mmanylinux2014_aarch64.whl
760e6b5681eea93cf6c85bcd1a739068 numpy1.19.0cp37cp37mwin32.whl
d75a6104a6cce3c669e2363470d567bc numpy1.19.0cp37cp37mwin_amd64.whl
09f870d54906d964bd0f93b22695f9ae numpy1.19.0cp38cp38macosx_10_9_x86_64.whl
ea9f4248d9ba0c647e07427cb542c2bf numpy1.19.0cp38cp38manylinux1_i686.whl
11b7a5b055bb1417c8935d267b7d88de numpy1.19.0cp38cp38manylinux1_x86_64.whl
6f6dec62163fa21259b7157516cc9e84 numpy1.19.0cp38cp38manylinux2010_i686.whl
ca83ee74cbdac0ffe3ec2c8c79294d67 numpy1.19.0cp38cp38manylinux2010_x86_64.whl
560567c2b3017ed146c3d08b0a58cadb numpy1.19.0cp38cp38manylinux2014_aarch64.whl
d160b64e914c5f2e4807943c83dae54a numpy1.19.0cp38cp38win32.whl
4e563e6434af5b90f1f99d9b916b2525 numpy1.19.0cp38cp38win_amd64.whl
a26c769ffe249f02cb73e6fbec7ff9ca numpy1.19.0pp36pypy36_pp73manylinux2010_x86_64.whl
d59aadf47354bd10c7b9996032ba4da0 numpy1.19.0.tar.gz
3f5ce88a859302f0a1aceb5f75b563fc numpy1.19.0.zip
SHA256
63d971bb211ad3ca37b2adecdd5365f40f3b741a455beecba70fd0dde8b2a4cb numpy1.19.0cp36cp36mmacosx_10_9_x86_64.whl
b6aaeadf1e4866ca0fdf7bb4eed25e521ae21a7947c59f78154b24fc7abbe1dd numpy1.19.0cp36cp36mmanylinux1_i686.whl
13af0184177469192d80db9bd02619f6fa8b922f9f327e077d6f2a6acb1ce1c0 numpy1.19.0cp36cp36mmanylinux1_x86_64.whl
356f96c9fbec59974a592452ab6a036cd6f180822a60b529a975c9467fcd5f23 numpy1.19.0cp36cp36mmanylinux2010_i686.whl
fa1fe75b4a9e18b66ae7f0b122543c42debcf800aaafa0212aaff3ad273c2596 numpy1.19.0cp36cp36mmanylinux2010_x86_64.whl
cbe326f6d364375a8e5a8ccb7e9cd73f4b2f6dc3b2ed205633a0db8243e2a96a numpy1.19.0cp36cp36mmanylinux2014_aarch64.whl
a2e3a39f43f0ce95204beb8fe0831199542ccab1e0c6e486a0b4947256215632 numpy1.19.0cp36cp36mwin32.whl
7b852817800eb02e109ae4a9cef2beda8dd50d98b76b6cfb7b5c0099d27b52d4 numpy1.19.0cp36cp36mwin_amd64.whl
d97a86937cf9970453c3b62abb55a6475f173347b4cde7f8dcdb48c8e1b9952d numpy1.19.0cp37cp37mmacosx_10_9_x86_64.whl
a86c962e211f37edd61d6e11bb4df7eddc4a519a38a856e20a6498c319efa6b0 numpy1.19.0cp37cp37mmanylinux1_i686.whl
d34fbb98ad0d6b563b95de852a284074514331e6b9da0a9fc894fb1cdae7a79e numpy1.19.0cp37cp37mmanylinux1_x86_64.whl
658624a11f6e1c252b2cd170d94bf28c8f9410acab9f2fd4369e11e1cd4e1aaf numpy1.19.0cp37cp37mmanylinux2010_i686.whl
4d054f013a1983551254e2379385e359884e5af105e3efe00418977d02f634a7 numpy1.19.0cp37cp37mmanylinux2010_x86_64.whl
26a45798ca2a4e168d00de75d4a524abf5907949231512f372b217ede3429e98 numpy1.19.0cp37cp37mmanylinux2014_aarch64.whl
3c40c827d36c6d1c3cf413694d7dc843d50997ebffbc7c87d888a203ed6403a7 numpy1.19.0cp37cp37mwin32.whl
be62aeff8f2f054eff7725f502f6228298891fd648dc2630e03e44bf63e8cee0 numpy1.19.0cp37cp37mwin_amd64.whl
dd53d7c4a69e766e4900f29db5872f5824a06827d594427cf1a4aa542818b796 numpy1.19.0cp38cp38macosx_10_9_x86_64.whl
30a59fb41bb6b8c465ab50d60a1b298d1cd7b85274e71f38af5a75d6c475d2d2 numpy1.19.0cp38cp38manylinux1_i686.whl
df1889701e2dfd8ba4dc9b1a010f0a60950077fb5242bb92c8b5c7f1a6f2668a numpy1.19.0cp38cp38manylinux1_x86_64.whl
33c623ef9ca5e19e05991f127c1be5aeb1ab5cdf30cb1c5cf3960752e58b599b numpy1.19.0cp38cp38manylinux2010_i686.whl
26f509450db547e4dfa3ec739419b31edad646d21fb8d0ed0734188b35ff6b27 numpy1.19.0cp38cp38manylinux2010_x86_64.whl
7b57f26e5e6ee2f14f960db46bd58ffdca25ca06dd997729b1b179fddd35f5a3 numpy1.19.0cp38cp38manylinux2014_aarch64.whl
a8705c5073fe3fcc297fb8e0b31aa794e05af6a329e81b7ca4ffecab7f2b95ef numpy1.19.0cp38cp38win32.whl
c2edbb783c841e36ca0fa159f0ae97a88ce8137fb3a6cd82eae77349ba4b607b numpy1.19.0cp38cp38win_amd64.whl
8cde829f14bd38f6da7b2954be0f2837043e8b8d7a9110ec5e318ae6bf706610 numpy1.19.0pp36pypy36_pp73manylinux2010_x86_64.whl
153cf8b0176e57a611931981acfe093d2f7fef623b48f91176efa199798a6b90 numpy1.19.0.tar.gz
76766cc80d6128750075378d3bb7812cf146415bd29b588616f72c943c00d598 numpy1.19.0.zip