除了常见的bug修复之外,这个NumPy版本还清理并记录了新的随机C-API,终止了大量旧的不赞成意见,并改进了文档的外观。支持的Python版本是3.5-3.8。这是最后一个支持python3.5的NumPy发行版系列。
下游开发人员应该使用Cython>=0.29.14来支持python3.8和OpenBLAS>=3.7,以避免在Skylake架构上出现问题。
的C-API numpy.random 已定义并记录。
numpy.random
用于链接64位BLAS和LAPACK库的基本基础设施。
许多文档改进。
方法 multivariate_hypergeometric has been added to the class numpy.random.Generator. This method generates random variates from the multivariate hypergeometric probability distribution. (gh-13794 )
multivariate_hypergeometric
numpy.random.Generator
np.fromfile
np.fromstring
在未来的numpy版本中,函数 np.fromfile and np.fromstring will throw an error when parsing bad data. This will now give a DeprecationWarning where previously partial or even invalid data was silently returned. This deprecation also affects the C defined functions PyArray_FromString and PyArray_FromFile (gh-13605 )
DeprecationWarning
PyArray_FromString
PyArray_FromFile
ma.fill_value
设置一个 MaskedArray.fill_value to a non-scalar array is deprecated since the logic to broadcast the fill value to the array is fragile, especially when slicing. (gh-13698 )
MaskedArray.fill_value
PyArray_As1D
PyArray_As2D
PyArray_As1D, PyArray_As2D are deprecated, use PyArray_AsCArray instead (gh-14036 )
PyArray_AsCArray
np.alen
np.alen was deprecated. Use len instead. (gh-14181 )
len
按照 NEP-32, the financial functions fv ipmt, irr, mirr, nper, npv, pmt, ppmt, pv and rate are deprecated, and will be removed from NumPy 1.20.The replacement for these functions is the Python package numpy-financial. (gh-14720 )
fv
ipmt
irr
mirr
nper
npv
pmt
ppmt
pv
rate
axis
numpy.ma.mask_cols
numpy.ma.mask_row
这个论点总是被忽视。 (gh-14996 ()
PyArray_As1D and PyArray_As2D have been removed in favor of PyArray_AsCArray (gh-14036 )
np.rank has been removed. This was deprecated in NumPy 1.10 and has been replaced by np.ndim. (gh-14039 )
np.rank
np.ndim
反对 expand_dims out-of-range axes in 1.13.0 has expired. (gh-14051 )
expand_dims
PyArray_FromDimsAndDataAndDescr and PyArray_FromDims have been removed (they will always raise an error). Use PyArray_NewFromDescr and PyArray_SimpleNew instead. (gh-14100 )
PyArray_FromDimsAndDataAndDescr
PyArray_FromDims
PyArray_NewFromDescr
PyArray_SimpleNew
numeric.loads, numeric.load, np.ma.dump, np.ma.dumps, np.ma.load, np.ma.loads are removed, use pickle methods instead (gh-14256 )
numeric.loads
numeric.load
np.ma.dump
np.ma.dumps
np.ma.load
np.ma.loads
pickle
arrayprint.FloatFormat , arrayprint.LongFloatFormat 已删除,请使用 FloatingFormat 相反
arrayprint.FloatFormat
arrayprint.LongFloatFormat
FloatingFormat
arrayprint.ComplexFormat , arrayprint.LongComplexFormat 已删除,请使用 ComplexFloatingFormat 相反
arrayprint.ComplexFormat
arrayprint.LongComplexFormat
ComplexFloatingFormat
arrayprint.StructureFormat has been removed, use StructureVoidFormat instead (gh-14259 )
arrayprint.StructureFormat
StructureVoidFormat
np.testing.rand has been removed. This was deprecated in NumPy 1.11 and has been replaced by np.random.rand. (gh-14325 )
np.testing.rand
np.random.rand
等级 SafeEval in numpy/lib/utils.py has been removed. This was deprecated in NumPy 1.10. Use np.safe_eval instead. (gh-14335 )
SafeEval
numpy/lib/utils.py
np.safe_eval
删除中不推荐使用的对布尔值和空条件列表的支持 np.select (gh-14583 )
np.select
数组顺序只接受“C”、“F”、“A”和“K”。NUMPY1.11中否决了更多的允许选项。 (gh-14596 ()
np.L空间参数 num must be an integer. Deprecated in NumPy 1.12. (gh-14620 )
num
具有多个输出的UFuncs必须为 out kwarg. This finishes a deprecation started in NumPy 1.10. (gh-14682 )
out
档案 numpy/testing/decorators.py, numpy/testing/noseclasses.py and numpy/testing/nosetester.py have been removed. They were never meant to be public (all relevant objects are present in the numpy.testing namespace), and importing them has given a deprecation warning since NumPy 1.15.0 (gh-14567 )
numpy/testing/decorators.py
numpy/testing/noseclasses.py
numpy/testing/nosetester.py
numpy.testing
numpy.lib.recfunctions.drop_fields
如果 drop_fields 用于删除所有字段,以前该数组将被完全丢弃且不返回任何字段。现在它返回一个与输入形状相同的数组,但没有字段。旧的行为可以保留为:
drop_fields
dropped_arr = drop_fields(arr, ['a', 'b']) if dropped_arr.dtype.names == (): dropped_arr = None
将空重新排列转换为无 (gh-14510 ()
numpy.argmin/argmax/min/max
NaT
numpy.argmin, numpy.argmax, numpy.min, and numpy.max will return NaT if it exists in the array. (gh-14717 )
numpy.argmin
numpy.argmax
numpy.min
numpy.max
np.can_cast(np.uint64, np.timedelta64, casting='safe')
False
以前这是 True -然而,这与 uint64 不能安全地浇铸到 int64 ,并导致奇怪的类型分辨率。
True
uint64
int64
如果这影响了你的代码,请强制转换 uint64 to int64 first. (gh-14718 )
numpy.random.Generator.integers
里面有个窃听器 numpy.random.Generator.integers that caused biased sampling of 8 and 16 bit integer types. Fixing that bug has changed the output stream from what it was in previous releases. (gh-14777 )
datetime64
timedelta64
np.datetime('NaT') should behave more like float('Nan'). Add needed infrastructure so np.isinf(a) and np.isnan(a) will run on datetime64 and timedelta64 dtypes. Also added specific loops for numpy.fmin and numpy.fmax that mask NaT. This may require adjustment to user- facing code. Specifically, code that either disallowed the calls to numpy.isinf or numpy.isnan or checked that they raised an exception will require adaptation, and code that mistakenly called numpy.fmax and numpy.fmin instead of numpy.maximum or numpy.minimum respectively will require adjustment. This also affects numpy.nanmax and numpy.nanmin. (gh-14841 )
np.datetime('NaT')
float('Nan')
np.isinf(a)
np.isnan(a)
numpy.fmin
numpy.fmax
numpy.isinf
numpy.isnan
numpy.maximum
numpy.minimum
numpy.nanmax
numpy.nanmin
作为API清理的一部分,中的子模块 numpy.random bit_generator, philox, pcg64, sfc64, ``common, generator, and bounded_integers were moved to _bit_generator, _philox, _pcg64, _sfc64, ``_common, _generator, and _bounded_integers respectively to indicate that they are not part of the public interface. (gh-14608 )
bit_generator
philox
pcg64
sfc64, ``common
generator
bounded_integers
_bit_generator
_philox
_pcg64
_sfc64, ``_common
_generator
_bounded_integers
PyDataType_ISUNSIZED(descr)
以前,对于itemsize为0的任何数据类型,它都返回True,但现在对于itemsize为0的非灵活数据类型,它返回false, np.dtype([]). (gh-14393 )
np.dtype([])
*.pxd
增加了一个 numpy/__init__.pxd file. It will be used for cimport numpy (gh-12284 )
numpy/__init__.pxd
cimport numpy
这个 numpy.expand_dims axis keyword can now accept a tuple of axes. Previously, axis was required to be an integer. (gh-14051 )
numpy.expand_dims
增加了对64位(ILP64)OpenBLAS的支持。看到了吗 site.cfg.example for details. (gh-15012 )
site.cfg.example
--f2cmap
允许指定要从中加载Fortran-to-C类型映射自定义项的文件。 (gh-15113 ()
在任何给定的平台上 np.intc , np.int_ 和 np.longlong 以前通过他们的 repr ,尽管 dtype 具有不同的特性。类似的问题也存在于这些类型的无符号对应项上,在某些平台上也存在 np.double 和 np.longdouble
np.intc
np.int_
np.longlong
repr
dtype
np.double
np.longdouble
这些类型现在总是打印一个独特的 __name__. (gh-10151 )
__name__
argwhere
在N-d阵列上, numpy.argwhere now always produces an array of shape (n_non_zero, arr.ndim), even when arr.ndim == 0. Previously, the last axis would have a dimension of 1 in this case. (gh-13610 )
numpy.argwhere
(n_non_zero, arr.ndim)
arr.ndim == 0
random.permutation
random.shuffle
以前 random.permutation and random.shuffle functions can only shuffle an array along the first axis; they now have a new argument axis which allows shuffle along a specified axis. (gh-13829 )
method
np.random.multivariate_normal
A method keyword argument is now available for np.random.multivariate_normal with possible values {{'svd', 'eigh', 'cholesky'}}. To use it, write np.random.multivariate_normal(..., method=<method>). (gh-14197 )
{{'svd', 'eigh', 'cholesky'}}
np.random.multivariate_normal(..., method=<method>)
numpy.fromstring
现在 numpy.fromstring can read complex numbers. (gh-14227 )
numpy.unique
使用 moveaxis instead of swapaxes in numpy.unique, so that the ordering of axes except the axis in arguments will not be broken. (gh-14255 )
moveaxis
swapaxes
numpy.matmul
调用 numpy.matmul where the output is a boolean array would fill the array with uint8 equivalents of the result, rather than 0/1. Now it forces the output to 0 or 1 (NPY_TRUE or NPY_FALSE). (gh-14464 )
NPY_TRUE
NPY_FALSE
numpy.random.randint
2**32
在1.17.0中引入的实现在确定是否使用32位路径或完整的64位路径时进行了错误的检查,该路径错误地重定向了随机整数生成的高低范围 2**32 to the 64-bit generator. (gh-14501 )
numpy.fromfile
现在 numpy.fromfile can read complex numbers. (gh-14730 )
std=c99
gcc
GCC版本5之前需要 -std=c99 command line argument. Newer compilers automatically turn on C99 mode. The compiler setup code will automatically add the code if the compiler name has gcc in it. (gh-14771 )
-std=c99
NaT is now effectively treated as the largest integer for sorting purposes, so that it sorts to the end of arrays. This change is for consistency with NaN sorting behavior. (gh-12658 ) (gh-15068 ()
NaN
threshold
np.set_printoptions
TypeError
ValueError
以前的错误 threshold raised ValueError; it now raises TypeError for non-numeric types and ValueError for nan values. (gh-13899 )
nan
A UserWarning will be emitted when saving an array via numpy.save with metadata. Saving such an array may not preserve metadata, and if metadata is preserved, loading it will cause a ValueError. This shortcoming in save and load will be addressed in a future release. (gh-14142 )
UserWarning
numpy.save
metadata
numpy.distutils
numpy.distutils has always overridden rather than appended to LDFLAGS and other similar such environment variables for compiling Fortran extensions. Now the default behavior has changed to appending - which is the expected behavior in most situations. To preserve the old (overwriting) behavior, set the NPY_DISTUTILS_APPEND_FLAGS environment variable to 0. This applies to: LDFLAGS, F77FLAGS, F90FLAGS, FREEFLAGS, FOPT, FDEBUG, and FFLAGS. NumPy 1.16 and 1.17 gave build warnings in situations where this change in behavior would have affected the compile flags used. (gh-14248 )
LDFLAGS
NPY_DISTUTILS_APPEND_FLAGS
F77FLAGS
F90FLAGS
FREEFLAGS
FOPT
FDEBUG
FFLAGS
numpy.random.entropy
numpy.random.entropy was added to the numpy.random namespace in 1.17.0. It was meant to be a private c-extension module, but was exposed as public. It has been replaced by numpy.random.SeedSequence so the module was completely removed. (gh-14498 )
numpy.random.SeedSequence
-Werror
添加了两个新的配置选项。在 build_src 子命令,作为配置NumPy的一部分 _numpyconfig.h 和 config.h 是通过探测对各种运行时函数和例程的支持而创建的。以前,在这个阶段非常详细的编译器输出会模糊更重要的信息。默认情况下,输出是静音的。跑步 runtests.py --debug-info 将添加 --verbose-cfg 到 build_src 子命令将恢复以前的行为。
build_src
_numpyconfig.h
config.h
runtests.py --debug-info
--verbose-cfg
添加 CFLAGS=-Werror 将警告变为错误会在配置过程中触发错误。现在 runtests.py --warn-error 将添加 --warn-error 到 build 子命令,它将渗透到 build_ext 和 build_lib 子命令。这将向这些阶段添加编译器标志,并在实际构建NumPy本身时将编译器警告变成错误,从而避免 build_src 子命令编译器调用。
CFLAGS=-Werror
runtests.py --warn-error
--warn-error
build
build_ext
build_lib
(gh-14527 () (gh-14518 ()