Almost Human reports
edit ： Chen Ping 、 Du Wei
NumPy 1.20.0 Version Online , The latest highlights include NumPy Function Comments 、 Provide sliding window view for array, etc .
As Python An extended library of language ,NumPy Support a large number of dimension arrays and matrix operations , It also provides a large number of mathematical function libraries for array operations . Since the first version came online ,NumPy Has become a Python The expansion package of Scientific Computing . Now , In computing multidimensional arrays and large arrays , It's the most widely used . Besides , It also provides multiple functions , It's very efficient to operate arrays , It can also be used to implement advanced mathematical operations .
In recent days, ,NumPy There's an update .NumPy Official expression ,NumPy v1.20 It's the largest version update yet , total 184 Three developers contributed about 684 strip PR, New type comment 、 Sliding window view and other functions .
New version support Python 3.7-3.9, But does not support Python 3.6. The main highlights are as follows ：
Newly released NumPy 1.20.0 Version includes the following three new functions ：
（1）random.Generator Class has a new function permuted. New functions and shuffle and permutation Different , The subarray of the given axis index is converted . for example , Now you can convert the rows or columns of a two-dimensional array ;
（2）sliding_window_view by numpy Array provides a sliding window view .numpy.lib.stride_tricks.sliding_window_view stay numpy Construct views on arrays , Provides sliding or moving window access to arrays . This makes running means And other algorithms can be easily implemented .
>>> x = np.arange(6) *>>>* ** x.shape (6,) *>>>* ** v = sliding_window_view(x, 3) *>>>* ** v.shape (4, 3) *>>>* ** v array([[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5]])
（3） A user oriented （user-facing） New functions for numpy.broadcast_shapes. This function can be passed through a given number one group broadcasting Get shape , among broadcasting The function of the mechanism is to facilitate different shape Of array Do math .
*>>>* np.broadcast_shapes((1, 2), (3, 1)) (3, 2) *>>>* np.broadcast_shapes(2, (3, 1)) (3, 2) *>>>* np.broadcast_shapes((6, 7), (5, 6, 1), (7,), (5, 1, 7)) (5, 6, 7)
image np.int These built-in types （builtin type） The alias for has been discarded . For a long time ,np.int yes int Another name for , But it's often a problem for beginners , This is mainly due to historical reasons .
The following table shows a complete list of discarded aliases , The third column is spare NumPy name .
Besides , take shape=None Pass to with non optional parameters shape Function of has been discarded ,mode and searchside Inexact matching of 、numpy.dual Modules are also discarded .
For more updates, please refer to ：https://numpy.org/doc/1.20/release/1.20.0-notes.html#deprecations
2021 year 2 The first week of the month , The heart of machine will join hands with more than 20 people AI Online live broadcast of famous guests , Through round table discussion 、 trend Talk, Report interpretation and case sharing , To pay attention to the development trend of artificial intelligence industry AI Human interpretation of the evolution trend of Technology , To explore the context of industrial development together . Seven days in a row , It's wonderful .
This article is from WeChat official account. - Almost Human （almosthuman2014）
The source and reprint of the original text are detailed in the text , If there is any infringement , Please contact the email@example.com Delete .
Original publication time ： 2021-02-04
Participation of this paper Tencent cloud media sharing plan , You are welcome to join us , share .