spectrochempy.zeros_like
- zeros_like(dataset, dtype=None, **kwargs)[source]
Return a
NDDataset
of zeros.The returned
NDDataset
have the same shape and type as a given array. Units, coordset, … can be added in kwargs.- Parameters:
dataset (
NDDataset
or 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:
zeorslike – Array of
fill_value
with 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_like
Return an array with a fill value with shape and type of the input.
ones_like
Return an array of ones with shape and type of input.
empty_like
Return an empty array with shape and type of input.
zeros
Return a new array setting values to zero.
ones
Return a new array setting values to one.
empty
Return a new uninitialized array.
full
Fill a new array.
Examples
>>> x = np.arange(6) >>> x = x.reshape((2, 3)) >>> nd = scp.NDDataset(x, units='s') >>> nd NDDataset: [float64] s (shape: (y:2, x:3)) >>> nd.values <Quantity([[ 0 1 2] [ 3 4 5]], 'second')> >>> nd = scp.zeros_like(nd) >>> nd NDDataset: [float64] s (shape: (y:2, x:3)) >>> nd.values <Quantity([[ 0 0 0] [ 0 0 0]], 'second')>