nlcpy.full_like

nlcpy.full_like(a, fill_value, dtype=None, order='K', subok=False, shape=None)[ソース]

Returns a full array with the same shape and type as a given array.

Parameters
aarray_like

The shape and dtype of a define these same attributes of the returned array.

fill_valuescalar

Fill value.

dtypedtype, optional

Overrides the data type of the result.

order{'C', 'F', 'A', or 'K'}, optional

Overrides the memory layout of the result. 'C' means C-order, 'F' means F-order, 'A' means 'F' if a is Fortran contiguous, 'C' otherwise. 'K' means match the layout of a as closely as possible.

subokbool, optional

Not implemented.

shapeint or sequence of ints, optional

Overrides the shape of the result. If order='K' and the number of dimensions is unchanged, will try to keep order, otherwise, order='C' is implied.

Returns
outndarray

Array of fill_value with the same shape and type as a.

参考

empty_like

Returns a new array with the same shape and type as a given array.

ones_like

Returns an array of ones with the same shape and type as a given array.

zeros_like

Returns an array of zeros with the same shape and type as a given array.

full

Returns a new array of given shape and type, filled with fill_value.

Examples

>>> import nlcpy as vp
>>> x = vp.arange(6, dtype=int)
>>> vp.full_like(x, 1)
array([1, 1, 1, 1, 1, 1])
>>> vp.full_like(x, 0.1)
array([0, 0, 0, 0, 0, 0])
>>> vp.full_like(x, 0.1, dtype=vp.double)
array([0.1, 0.1, 0.1, 0.1, 0.1, 0.1])
>>> vp.full_like(x, vp.nan, dtype=vp.double)
array([nan, nan, nan, nan, nan, nan])
>>> y = vp.arange(6, dtype=vp.double)
>>> vp.full_like(y, 0.1)
array([0.1, 0.1, 0.1, 0.1, 0.1, 0.1])