chore(deps): update dependency numpy to v1.19.0 #4137
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
==1.18.5
->==1.19.0
Release Notes
numpy/numpy
v1.19.0
Compare Source
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.6 (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 theymay be deprecated in a future release. Note that 1.19.x will not
compile with earlier versions of Python due to the use of f-strings.
(gh-15233)
Expired deprecations
numpy.insert
andnumpy.delete
can no longer be passed an axis on 0d arraysThis concludes a deprecation from 1.9, where when an
axis
argument waspassed to a call to
~numpy.insert
and~numpy.delete
on a 0d array,the
axis
andobj
argument and indices would be completely ignored.In these cases,
insert(arr, "nonsense", 42, axis=0)
would actuallyoverwrite the entire array, while
delete(arr, "nonsense", axis=0)
would be
arr.copy()
Now passing
axis
on a 0d array raises~numpy.AxisError
.(gh-15802)
numpy.delete
no longer ignores out-of-bounds indicesThis concludes deprecations from 1.8 and 1.9, where
np.delete
wouldignore 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 indexfrom the end.
(gh-15804)
numpy.insert
andnumpy.delete
no longer accept non-integral indicesThis 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 raises
IndexError
, just like it does when passinga single non-integral scalar.
(gh-15805)
numpy.delete
no longer casts boolean indices to integersThis concludes a deprecation from 1.8, where
np.delete
would castboolean 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 when
max(alpha) < 0.1
. Because of the change, the stream ofvariates generated by
dirichlet
in this case will be different fromprevious 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 usedby
np.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 additionalto_end
andto_begin
arguments. This ensures type safety except whenthe input array has a smaller integer type than
to_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 implementing
obj.__array__()
,obj.__array_interface__
,obj.__array_struct__
, or the python bufferinterface 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 intoan 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 aNotImplementedError
and was unused internally. It is expected thatthere 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 wasused as:
Its purpose was to handle the change in syntax introduced in Python 2.6,
from
except Exception, e:
toexcept Exception as e:
, meaning it wasonly 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 hasexpired 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
orfloat
) will now be consistent with passing innp.dtype(arg2).type
. This makes the result consistent withexpectations 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 Pythonbuilt-in
round
has been changed to be a Pythonint
to be consistentwith calling it on Python
float
objects when called with no arguments.Previously, it would return a scalar of the
np.dtype
that was passedin.
(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 instrides 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 using
string_arr.astype("M8")
while previously the castwould behave like
string_arr.astype(np.int_).astype("M8")
. This onlyaffects code using low-level C-API to do manual casts (not full array
casts) of single scalar values or using e.g.
PyArray_GetCastFunc
, andshould thus not affect the vast majority of users.
(gh-16068)
SeedSequence
with small seeds no longer conflicts with spawningSmall seeds (less than
2**96
) were previously implicitly 0-padded outto 128 bits, the size of the internal entropy pool. When spawned, the
spawn key was concatenated before the 0-padding. Since the first spawn
key is
(0,)
, small seeds before the spawn created the same states asthe first spawned
SeedSequence
. Now, the seed is explicitly 0-paddedout to the internal pool size before concatenating the spawn key.
Spawned
SeedSequences
will produce different results than in theprevious release. Unspawned
SeedSequences
will still produce the sameresults.
(gh-16551)
Deprecations
Deprecate automatic
dtype=object
for ragged inputCalling
np.array([[1, [1, 2, 3]])
will issue aDeprecationWarning
asper NEP 34. Users should
explicitly use
dtype=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 thefunctions:
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 anarray 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 byconverting to an array, while
PyUFunc_GenericFunction
can be replacedwith
PyObject_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
,or
np.inexact
will now give a deprecation warning when converted to adtype (or used in a dtype keyword argument). The reason for this is that
np.integer
is converted tonp.int_
, while it would be expected torepresent any integer (e.g. also
int8
,int16
, etc. For example,dtype=np.floating
is currently identical todtype=np.float64
, eventhough also
np.float32
is a subclass ofnp.floating
.(gh-15534)
Deprecation of
round
fornp.complexfloating
scalarsOutput of the
__round__
dunder method and consequently the Pythonbuilt-in
round
has been deprecated on complex scalars. This does notaffect
np.round
.(gh-15840)
numpy.ndarray.tostring()
is deprecated in favor oftobytes()
~numpy.ndarray.tobytes
has existed since the 1.9 release, but untilthis release
~numpy.ndarray.tostring
emitted no warning. The change toemit a warning brings NumPy in line with the builtin
array.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
andstrides
as arguments. This means inner loops may no longer modifyeither
dimension
orstrides
. This change leads to anincompatible-pointer-types
warning forcing users to either ignore thecompiler 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-textrole="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 scalarsnow 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 togglethe behavior of
numpy.copy
with respect to array subclasses. Thedefault value is
False
which is consistent with the behavior ofnumpy.copy
for previous numpy versions. To create a copy thatpreserves an array subclass with
numpy.copy
, callnp.copy(arr, subok=True)
. This addition better documents that thedefault behavior of
numpy.copy
differs from thenumpy.ndarray.copy
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 finalproduct computed by
numpy.linalg.multidot
.(gh-15715)
keepdims
parameter fornumpy.count_nonzero
The parameter
keepdims
was added tonumpy.count_nonzero
. Theparameter 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
valuesare considered equal in comparison (default is
False
). This matchesAPI used in related functions such as
numpy.isclose
andnumpy.allclose
.(gh-16128)
Improvements
Improve detection of CPU features
Replace
npy_cpu_supports
which was a gcc specific mechanism to testsupport of AVX with more general functions
npy_cpu_init
andnpy_cpu_have
, and expose the results via aNPY_CPU_HAVE
c-macro aswell 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 of
np.exp
withnp.float64
input5-7x faster than before. The
_multiarray_umath.so
module has grownabout 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
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:
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 aNumPy
int64
array as its subscript list.(gh-16080)
np.logaddexp2.identity
changed to-inf
The ufunc
~numpy.logaddexp2
now has an identity of-inf
, allowing itto 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 wasactivated when calling
ufunc(op)
orufunc.reduce(op)
ifop.__array__
existed. However that variant is not documented, and itis 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
andnumpy.random.SeedSequence
to Cython, the_bitgenerator
module is nowpublic as
numpy.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 ofthe 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 wrongdistribution. 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 using
RandomState
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 originalimplementation of the Horner and Sliding Window jump methods.
(gh-16153)
Checksums
MD5
SHA256
Renovate configuration
📅 Schedule: At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻️ Rebasing: Never, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by WhiteSource Renovate. View repository job log here.