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.identity

identity(n, dtype=None, **kwargs)[source]

Return the identity NDDataset of a given shape.

The identity array is a square array with ones on the main diagonal.

Parameters
  • n (int) – Number of rows (and columns) in n x n output.

  • dtype (data-type, optional) – Data-type of the output. Defaults to float .

  • **kwargs – Other parameters to be passed to the object constructor (units, coordset, mask …).

Returns

identityn x n array with its main diagonal set to one, and all other elements 0.

See also

eye

Almost equivalent function.

diag

Diagonal 2-D array from a 1-D array specified by the user.

Examples

>>> scp.identity(3).data
array([[       1,        0,        0],
       [       0,        1,        0],
       [       0,        0,        1]])