Numpy - np.empty function

x1 = np.empty(5).fill(2)

x1 is None
True
x1 = np.empty(5)
x1.fill(2)
x1
array([2., 2., 2., 2., 2.])

np.empty function, which generates an array with uninitialized values, of the given size. This function should only be used when the initialization of all elements can be guaranteed by other means, such as an explicit loop over the array elements or another explicit assignment.

上一篇:Java使用数组实现ArrayList的动态扩容


下一篇:Codeforces Round #648 (Div. 2)