spectrochempy.ones_like
- ones_like(dataset, dtype=None, **kwargs)[source]
Return
NDDatasetof ones.The returned
NDDatasethave the same shape and type as a given array. Units, coordset, … can be added in kwargs.- Parameters:
dataset (
NDDatasetor array-like) – Object from which to copy the array structure.dtype (data-type, optional) – Overrides the data type of the result.
**kwargs – Optional keyword parameters (see Other Parameters).
- Returns:
oneslike – Array of
1with the same shape and type asdataset.- Other Parameters:
units (str or ur instance) – Units of the returned object. If not provided, try to copy from the input object.
coordset (list or Coordset object) – Coordinates for the returned object. If not provided, try to copy from the input object.
See also
full_likeReturn an array with a given fill value with shape and type of the
input.zeros_likeReturn an array of zeros with shape and type of input.
empty_likeReturn an empty array with shape and type of input.
zerosReturn a new array setting values to zero.
onesReturn a new array setting values to one.
emptyReturn a new uninitialized array.
fullFill a new array.
Examples
>>> x = np.arange(6) >>> x = x.reshape((2, 3)) >>> x = scp.NDDataset(x, units='s') >>> x NDDataset: [float64] s (shape: (y:2, x:3)) >>> scp.ones_like(x, dtype=float, units='J') NDDataset: [float64] J (shape: (y:2, x:3))