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

diag(dataset, offset=0, **kwargs)[source]

Extract a diagonal or construct a diagonal array.

See the more detailed documentation for numpy.diagonal if you use this function to extract a diagonal and wish to write to the resulting array; whether it returns a copy or a view depends on what version of numpy you are using.

Parameters
  • dataset (array_like) – If dataset is a 2-D array, return a copy of its k-th diagonal. If dataset is a 1-D array, return a 2-D array with v on the k-th. diagonal.

  • offset (int, optional) – Diagonal in question. The default is 0. Use offset>0 for diagonals above the main diagonal, and offset<0 for diagonals below the main diagonal.

Returns

diag – The extracted diagonal or constructed diagonal array.