Warning

You are reading the documentation related to the development version. Go here if you are looking for the documentation of the stable release.

spectrochempy.zeros

zeros(shape, dtype=None, **kwargs)[source]

Return a new NDDataset of given shape and type, filled with zeros.

Parameters
  • shape (int or sequence of ints) – Shape of the new array, e.g., (2, 3) or 2 .

  • dtype (data-type, optional) – The desired data-type for the array, e.g., numpy.int8 . Default is numpy.float64 .

  • **kwargs – Optional keyword parameters (see Other Parameters).

Returns

zeros – Array of zeros.

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

zeros_like

Return an array of zeros with shape and type of 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.

full_like

Fill an array with shape and type of input.

ones

Return a new array setting values to 1.

empty

Return a new uninitialized array.

full

Fill a new array.

Examples

>>> nd = scp.NDDataset.zeros(6)
>>> nd
NDDataset: [float64] unitless (size: 6)
>>> nd = scp.zeros((5, ))
>>> nd
NDDataset: [float64] unitless (size: 5)
>>> nd.values
array([       0,        0,        0,        0,        0])
>>> nd = scp.zeros((5, 10), dtype=np.int, units='absorbance')
>>> nd
NDDataset: [int64] a.u. (shape: (y:5, x:10))