NumPy v1.19.0.rc1 Release Notes
Release Date: 2020-05-18 // almost 4 years ago-
๐ 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.6-3.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.5 (including Python 2)
was dropped from both the python and C code. The shims in
๐ฆnumpy.compat
will remain to support third-party packages, but they
๐ may be deprecated in a future release.(gh-15233)
๐ Expired deprecations
numpy.insert
andnumpy.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,
theaxis
andobj
argument and indices would be completely ignored.
In these cases,insert(arr, "nonsense", 42, axis=0)
would actually
overwrite the entire array, whiledelete(arr, "nonsense", axis=0)
would bearr.copy()
Now passing
axis
on a 0d array raises~numpy.AxisError
.(gh-15802)
numpy.delete
no longer ignores out-of-bounds indices๐ This concludes deprecations from 1.8 and 1.9, where
np.delete
would
ignore both negative and out-of-bounds items in a sequence of indices.
This was at odds with its behavior when passed a single index.Now out-of-bounds items throw
IndexError
, and negative items index
from the end.(gh-15804)
numpy.insert
andnumpy.delete
no longer accept non-integral indices๐ This concludes a deprecation from 1.9, where sequences of non-integers
indices were allowed and cast to integers. Now passing sequences of
non-integral indices raisesIndexError
, just like it does when passing
a single non-integral scalar.(gh-15805)
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.(gh-15815)
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 whenmax(alpha) < 0.1
. Because of the change, the stream of
variates generated bydirichlet
in this case will be different from
๐ previous releases.(gh-14924)
Scalar promotion in
PyArray_ConvertToCommonType
The promotion of mixed scalars and arrays in
PyArray_ConvertToCommonType
has been changed to adhere to those used
bynp.result_type
. This means that input such as
(1000, np.array([1], dtype=np.uint8)))
will now returnuint16
dtypes. In most cases the behaviour is unchanged. Note that the use of
๐ this C-API function is generally discouraged. This also fixes
np.choose
to behave the same way as the rest of NumPy in this respect.(gh-14933)
๐ 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.(gh-14942)
np.ediff1d
casting behaviour withto_end
andto_begin
np.ediff1d
now uses the"same_kind"
casting rule for its additional
to_end
andto_begin
arguments. This ensures type safety except when
the input array has a smaller integer type thanto_begin
orto_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.(gh-14981)
Converting of empty array-like objects to NumPy arrays
Objects with
len(obj) == 0
which implement an "array-like"
interface, meaning an object implementingobj. __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).(gh-14995)
โ 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.(gh-15229)
๐
numpy.distutils.compat
has been removedThis 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,
๐ป fromexcept Exception, e:
toexcept Exception as e:
, meaning it was
๐ only necessary for codebases supporting Python 2.5 and older.(gh-15255)
issubdtype
no longer interpretsfloat
asnp.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 likeint
orfloat
) 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.(gh-15773)
๐ Change output of
round
on scalars to be consistent with PythonOutput of the
__round__
dunder method and consequently the Python
built-inround
has been changed to be a Pythonint
to be consistent
with calling it on Pythonfloat
objects when called with no arguments.
Previously, it would return a scalar of thenp.dtype
that was passed
in.(gh-15840)
The
numpy.ndarray
constructor no longer interpretsstrides=()
asstrides=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.(gh-15882)
C-Level string to datetime casts changed
๐ The C-level casts from strings were simplified. This changed also fixes
string to datetime and timedelta casts to behave correctly (i.e. like
Python casts usingstring_arr.astype("M8")
while previously the cast
would behave likestring_arr.astype(np.int_).astype("M8")
. This only
affects code using low-level C-API 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.(gh-16068)
๐ Deprecations
๐ Deprecate automatic
dtype=object
for ragged input๐ Calling
np.array([[1, [1, 2, 3]])
will issue aDeprecationWarning
as
per NEP 34. Users should
โ explicitly usedtype=object
to avoid the warning.(gh-15119)
๐ Passing
shape=0
to factory functions innumpy.rec
is deprecated0
is treated as a special case and is aliased toNone
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.(gh-15217)
๐ Deprecation of probably unused C-API functions
The following C-API 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, whilePyUFunc_GenericFunction
can be replaced
๐ withPyObject_Call
(see documentation for details).(gh-15427)
๐ Converting certain types to dtypes is Deprecated
The super classes of scalar types, such as
np.integer
,np.generic
,
๐ ornp.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 tonp.int_
, while it would be expected to
represent any integer (e.g. alsoint8
,int16
, etc. For example,
dtype=np.floating
is currently identical todtype=np.float64
, even
though alsonp.float32
is a subclass ofnp.floating
.(gh-15534)
๐ Deprecation of
round
fornp.complexfloating
scalarsOutput of the
__round__
dunder method and consequently the Python
๐ built-inround
has been deprecated on complex scalars. This does not
affectnp.round
.(gh-15840)
๐
numpy.ndarray.tostring()
is deprecated in favor oftobytes()
๐
~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 builtinarray.array
methods of the same name.(gh-15867)
C API changes
๐ Better support for
const
dimensions in API functionsThe 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 const-ness to call
these functions.(gh-15251)
Const qualify UFunc inner loops
UFuncGenericFunction
now expects pointers to constdimension
and
strides
as arguments. This means inner loops may no longer modify
eitherdimension
orstrides
. This change leads to an
โincompatible-pointer-types
warning forcing users to either ignore the
โ compiler warnings or to const qualify their own loop signatures.(gh-15355)
๐ New Features
numpy.frompyfunc
now accepts an identity argumentThis allows the `
numpy.ufunc.identity
{.interpreted-text
role="attr"}[ attribute to be set on the resulting ufunc, meaning it can
be used for empty and multi-dimensional calls to
:meth:]{.title-ref}[numpy.ufunc.reduce]{.title-ref}`.(gh-8255)
๐
np.str_
scalars now support the buffer protocolnp.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.(gh-15385)
subok
option fornumpy.copy
A new kwarg,
subok
, was added tonumpy.copy
to allow users to toggle
the behavior ofnumpy.copy
with respect to array subclasses. The
0๏ธโฃ default value isFalse
which is consistent with the behavior of
numpy.copy
for previous numpy versions. To create a copy that
preserves an array subclass withnumpy.copy
, call
๐np.copy(arr, subok=True)
. This addition better documents that the
0๏ธโฃ default behavior ofnumpy.copy
differs from thenumpy.ndarray.copy
0๏ธโฃ method which respects array subclasses by default.(gh-15685)
numpy.linalg.multi_dot
now accepts anout
argumentout
can be used to avoid creating unnecessary copies of the final
product computed bynumpy.linalg.multidot
.(gh-15715)
keepdims
parameter fornumpy.count_nonzero
The parameter
keepdims
was added tonumpy.count_nonzero
. The
parameter has the same meaning as it does in reduction functions such as
numpy.sum
ornumpy.mean
.(gh-15870)
equal_nan
parameter fornumpy.array_equal
The keyword argument
equal_nan
was added tonumpy.array_equal
.
equal_nan
is a boolean value that toggles whether or notnan
values
0๏ธโฃ are considered equal in comparison (default isFalse
). This matches
API used in related functions such asnumpy.isclose
and
numpy.allclose
.(gh-16128)
๐ Improvements
๐ Improve detection of CPU features
Replace
npy_cpu_supports
which was a gcc specific mechanism to test
support of AVX with more general functionsnpy_cpu_init
and
npy_cpu_have
, and expose the results via aNPY_CPU_HAVE
c-macro as
well as a python-level__cpu_features__
dictionary.(gh-13421)
๐ Use 64-bit integer size on 64-bit platforms in fallback lapack_lite
๐ Use 64-bit integer size on 64-bit 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.(gh-15218)
๐ Use AVX512 intrinsic to implement
np.exp
when input isnp.float64
๐ Use AVX512 intrinsic to implement
np.exp
when input isnp.float64
,
๐ which can improve the performance ofnp.exp
withnp.float64
input
5-7x faster than before. The_multiarray_umath.so
module has grown
๐ง about 63 KB on linux64.(gh-15648)
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
0๏ธโฃ Kernel versions this led to peformance regressions, thus by default the
๐ support has been disabled on kernels before version 4.6. To override the
0๏ธโฃ 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.(gh-15769)
numpy.einsum
accepts NumPyint64
type in subscript listThere is no longer a type error thrown when
numpy.einsum
is passed a
NumPyint64
array as its subscript list.(gh-16080)
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
.(gh-16102)
๐ Changes
Remove handling of extra argument to
__array__
โ A code path and test have been in the code since NumPy 0.4 for a
two-argument variant of__array__ (dtype=None, context=None)
. It was
activated when callingufunc(op)
orufunc.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.(gh-15118)
numpy.random._bit_generator
moved tonumpy.random.bit_generator
In order to expose
numpy.random.BitGenerator
and
๐numpy.random.SeedSequence
to Cython, the_bitgenerator
module is now
public asnumpy.random.bit_generator
Cython access to the random distributions is provided via a
pxd
filec_distributions.pxd
provides access to the c functions behind many of
the random distributions from Cython, making it convenient to use and
extend them.(gh-15463)
๐ Fixed
eigh
andcholesky
methods innumpy.random.multivariate_normal
Previously, when passing
method='eigh'
ormethod='cholesky'
,
numpy.random.multivariate_normal
produced samples from the wrong
๐ distribution. This is now fixed.(gh-15872)
๐ Fixed the jumping implementation in
MT19937.jumped
This fix changes the stream produced from jumped MT19937 generators. It
does not affect the stream produced usingRandomState
orMT19937
๐ 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.(gh-16153)
Checksums
MD5
dac784fdc5f86f6b4daabb8a3edb59ef numpy-1.19.0rc1-cp36-cp36m-macosx_10_9_x86_64.whl 40df9787a18b84fbb7ab06de9e557abd numpy-1.19.0rc1-cp36-cp36m-manylinux1_i686.whl f54d2c826b31469e1bddf271e8ebbbfa numpy-1.19.0rc1-cp36-cp36m-manylinux1_x86_64.whl 11da401f740d8fed948ab84f92b52490 numpy-1.19.0rc1-cp36-cp36m-manylinux2010_i686.whl 3a49ddd9cc062896b352d9914213d6c8 numpy-1.19.0rc1-cp36-cp36m-manylinux2010_x86_64.whl 426c0c9859f7384781be7fbfa1fbca28 numpy-1.19.0rc1-cp36-cp36m-manylinux2014_aarch64.whl 5e7c8d718b3e867a8c063bd18addde3f numpy-1.19.0rc1-cp36-cp36m-win32.whl 5dfdf8b5dea6ac218a93038dc1eb5b8b numpy-1.19.0rc1-cp36-cp36m-win_amd64.whl 10575aa075e31e1f190a802e8c784bd5 numpy-1.19.0rc1-cp37-cp37m-macosx_10_9_x86_64.whl 1cf8fa399117e8d95ef9ca8847451362 numpy-1.19.0rc1-cp37-cp37m-manylinux1_i686.whl c832ede9b1272d32cb282ca7f951b084 numpy-1.19.0rc1-cp37-cp37m-manylinux1_x86_64.whl 3798e81e08e02c9683b03245ef181fe0 numpy-1.19.0rc1-cp37-cp37m-manylinux2010_i686.whl fea16821dabc6563ff1475eadf18ecbb numpy-1.19.0rc1-cp37-cp37m-manylinux2010_x86_64.whl 040b481a6ba7c613f246dac8ebc5c44c numpy-1.19.0rc1-cp37-cp37m-manylinux2014_aarch64.whl 96698d2aa93adcc16296fa40f094bbc1 numpy-1.19.0rc1-cp37-cp37m-win32.whl f930010f054f835d3818a2929ba66746 numpy-1.19.0rc1-cp37-cp37m-win_amd64.whl 1dc7545c2c53a95ea2523d98e6b7047e numpy-1.19.0rc1-cp38-cp38-macosx_10_9_x86_64.whl d9f9d3653f4a5f58c0b4fa391bbeabbe numpy-1.19.0rc1-cp38-cp38-manylinux1_i686.whl a89277714025de276a6c2916df470372 numpy-1.19.0rc1-cp38-cp38-manylinux1_x86_64.whl 894196d9ce2e1620a8fbc5ed95543580 numpy-1.19.0rc1-cp38-cp38-manylinux2010_i686.whl 071173ca8afca1b3fbcfc926a56ffd7f numpy-1.19.0rc1-cp38-cp38-manylinux2010_x86_64.whl 4180d5cda1e44242e8ed5b3c8b379d88 numpy-1.19.0rc1-cp38-cp38-manylinux2014_aarch64.whl 17c1867c83b2f07621d064145a255fc1 numpy-1.19.0rc1-cp38-cp38-win32.whl b32c7bfc056895eb78b6129045f49523 numpy-1.19.0rc1-cp38-cp38-win_amd64.whl 704bc03983673b18017e6b461d55a8c8 numpy-1.19.0rc1-pp36-pypy36_pp73-manylinux2010_x86_64.whl fd6765ceb2074658eb40641de9ad596f numpy-1.19.0rc1.tar.gz cc786052918361cb08f885e3e8c257fe numpy-1.19.0rc1.zip
SHA256
361c84cdf8e10a27d1ce7bb0404284eed2f704fb10ebbdb714fe5a51ef4f2765 numpy-1.19.0rc1-cp36-cp36m-macosx_10_9_x86_64.whl de874f2537e4e604c1db5905c4728b6b715c66a85bc71b5bc1b236973dc7610a numpy-1.19.0rc1-cp36-cp36m-manylinux1_i686.whl 8c4be83b9f253701ff865b6a9de26bbb67a3104486123347a3629101d3268a43 numpy-1.19.0rc1-cp36-cp36m-manylinux1_x86_64.whl f6fe5dd6526fa6c0083fb5218a903dc9d9ea02df66996cd3be8c44c3b97894d5 numpy-1.19.0rc1-cp36-cp36m-manylinux2010_i686.whl 96578b9000e8ca35b83e96237d617345c4ac7bf8816cb950ddf76235b3b7306c numpy-1.19.0rc1-cp36-cp36m-manylinux2010_x86_64.whl 8ac99d78e3ebc41b0dccf024a8dd36057abfa4dfcf3875259abf09da28e89fd2 numpy-1.19.0rc1-cp36-cp36m-manylinux2014_aarch64.whl fbd9dbb96fa22ee2f2cfad5311563a9df4528d3ac70f7635a9da0c7424ba4459 numpy-1.19.0rc1-cp36-cp36m-win32.whl c995c832ddf4ce88b6383ce8c9160e86d614141412c0c874b6df87f680783528 numpy-1.19.0rc1-cp36-cp36m-win_amd64.whl 1ae709f648755ce757ef896fb110c52cbc76bc787a1243ad9b1262be3cc01e64 numpy-1.19.0rc1-cp37-cp37m-macosx_10_9_x86_64.whl 0028da01578ddb0d7372ccd168d7e7e3b04f25881db7f520bff6c50456aa7b02 numpy-1.19.0rc1-cp37-cp37m-manylinux1_i686.whl 82a905f8d920aa1dc2d642a1e76ed54f2baa3eb23e2216bc6cd41ae2b274dded numpy-1.19.0rc1-cp37-cp37m-manylinux1_x86_64.whl 09e0e60d6ed6417516a08f9767665ae459507dd1df63942e0c0bb69d93f05c0e numpy-1.19.0rc1-cp37-cp37m-manylinux2010_i686.whl 164d8d2a0de07c3aba089e7db0873930ac05252d985c8825f247bd79ddf3bd9d numpy-1.19.0rc1-cp37-cp37m-manylinux2010_x86_64.whl 1041dd124664263f1b9cde98028dd2d0f164a94b13a06183f27a7b7dd14767ad numpy-1.19.0rc1-cp37-cp37m-manylinux2014_aarch64.whl d5833cb9cce627e960c87b75eb1878498cdf430155062f9423cee5617032284f numpy-1.19.0rc1-cp37-cp37m-win32.whl 59b4ace51c26d6f6698ebaee442a37d2f34415ad2d9c683e18bb462f50768697 numpy-1.19.0rc1-cp37-cp37m-win_amd64.whl 1d84d42be12fc7d3e9afc2e381136e6a4a0aa509183166b99079fd87afb8a6a6 numpy-1.19.0rc1-cp38-cp38-macosx_10_9_x86_64.whl f45938abfa864e342f6719f05150f6458e018e22793a6fdf60e0ea4d4d15f53c numpy-1.19.0rc1-cp38-cp38-manylinux1_i686.whl 876a0d72f16e60c34678ff52535d0ccdfb5718ed0ebac4ed50187bd6e06c1bac numpy-1.19.0rc1-cp38-cp38-manylinux1_x86_64.whl 0bffe7f20aa96e3b16a99c5a38a6e3ebeeff9203c8000723f040c72746808c5b numpy-1.19.0rc1-cp38-cp38-manylinux2010_i686.whl c39e84169f93899a15dbb7cbd3e68bd6bb31f56800658d966f89a2186eb4f929 numpy-1.19.0rc1-cp38-cp38-manylinux2010_x86_64.whl 5c1db3b05428c6c8397c2457063b16a03688f1d0531dac96afa46a0362a5f237 numpy-1.19.0rc1-cp38-cp38-manylinux2014_aarch64.whl c58eedde4999735da1d95a4af266a43ba1c32fbc2021941bb5149ad58da1312d numpy-1.19.0rc1-cp38-cp38-win32.whl 705551bb2fb68a3ee1c5868a24d9e57670324a2c25530e3846b58f111ca3bada numpy-1.19.0rc1-cp38-cp38-win_amd64.whl 72a8744aa28d2f85629810aa13fe45b13992ca9566eade5fecb0e916d7df6c80 numpy-1.19.0rc1-pp36-pypy36_pp73-manylinux2010_x86_64.whl c42b898277e1c2fdefa4361c6435e57311ad547f584039cbd935625701572d8e numpy-1.19.0rc1.tar.gz 1ae657a2390cbc1553df60cb2a5f69742761d0ad5957b0113c9c00bb06276a78 numpy-1.19.0rc1.zip