def full(shape, fill_value, dtype=None, order='C'):
"""
Return a new array of given shape and type, filled with `fill_value`.
返回具有给定形状和类型的新数组,并填充“ fill_value”。
Parameters
----------
shape : int or sequence of ints
Shape of the new array, e.g., ``(2, 3)`` or ``2``.
形状:整数或整数序列
新数组的形状,例如``(2,3)``或``2''。
fill_value : scalar
Fill value.
dtype : data-type, optional
The desired data-type for the array The default, `None`, means
`np.array(fill_value).dtype`.
order : {'C', 'F'}, optional
Whether to store multidimensional data in C- or Fortran-contiguous
(row- or column-wise) order in memory.
fill_value:标量(就是纯数值变量)
填充值。
dtype:数据类型,可选
数组所需的数据类型默认值为“ None”,表示
`np.array(fill_value).dtype`。
顺序:{'C','F'},可选
是否以C-或Fortran连续存储多维数据
(按行或按列)顺序在内存中。
Returns
-------
out : ndarray
Array of `fill_value` with the given shape, dtype, and order.
具有给定形状,dtype和顺序的“ fill_value”数组。
See Also
--------
full_like : Return a new array with shape of input filled with value.
empty : Return a new uninitialized array.
ones : Return a new array setting values to one.
zeros : Return a new array setting values to zero.
full_like:返回一个新数组,其输入形状填充有值。
空:返回一个新的未初始化的数组。
一:将新的数组设置值返回为一。
零:将新的数组设置值返回零。
Examples
--------
>>> np.full((2, 2), np.inf)
array([[ inf, inf],
[ inf, inf]])
>>> np.full((2, 2), 10)
array([[10, 10],
[10, 10]])
"""
if dtype is None:
dtype = array(fill_value).dtype
a = empty(shape, dtype, order)
multiarray.copyto(a, fill_value, casting='unsafe')
return a
python numpy np.full(shape, fill_value, dtype=None, order='C')函数 以指定数值填充指定形状的数组
最新推荐文章于 2023-10-05 20:54:24 发布