nlcpy.ones_like
- nlcpy.ones_like(a, dtype=None, order='K', subok=False, shape=None)[source]
- Returns an array of ones 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. 
- 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 ones with the same shape and type as a. 
 
 - See also - empty_like
- Returns a new array 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_like
- Returns a full array with the same shape and type as a given array. 
- ones
- Returns a new array of given shape and type, filled with ones. 
 - Examples - >>> import nlcpy as vp >>> x = vp.arange(6) >>> x = x.reshape((2, 3)) >>> x array([[0, 1, 2], [3, 4, 5]]) >>> vp.ones_like(x) array([[1, 1, 1], [1, 1, 1]]) >>> y = vp.arange(3, dtype=float) >>> y array([0., 1., 2.]) >>> vp.ones_like(y) array([1., 1., 1.])