pint.pint_matrix.CorrelationMatrix

class pint.pint_matrix.CorrelationMatrix(matrix, labels)[source]

Bases: CovarianceMatrix

A class for symmetric correlation matrix.

Methods

append_along_axis(pint_matrix, axis)

Append one pint matrix on a given axis.

diag([k])

Extract a diagonal.

get_axis_labels(axis)

Get the axis labels for the specified axis

get_label(label[, axis])

Get the label entry and its dimension.

get_label_along_axis(axis, label_name)

Get the request label from on axis.

get_label_matrix(labels)

Get a sub-matrix data according to the given labels.

get_label_names([axis])

Return only the names of the labels along the specified axis if requested.

get_label_size(label[, axis])

Get the size of the a label for all axes, or just the specified axis.

get_label_slice(labels)

Return the given label slices.

get_unique_label_names()

Return all unique label names (there may be duplications between axes).

map_labels()

match_labels_along_axis(pint_matrix, axis)

Match one axis' labels index between the current matrix and input pint matrix.

prettyprint([prec, coordinatefirst, offset, ...])

Return a version of the array formatted for printing (with labels etc).

to_correlation_matrix()

Convert a covariance matrix to a correlation matrix.

Attributes

label_units

labels

matrix_type

ndim

shape

append_along_axis(pint_matrix, axis)

Append one pint matrix on a given axis.

diag(k=0)

Extract a diagonal.

Parameters:

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

Returns:

out – The extracted diagonal.

Return type:

ndarray

get_axis_labels(axis)

Get the axis labels for the specified axis

Parameters:

axis (int) – axis for the label lookup

Returns:

labels

Return type:

list of (name, (start,stop,unit) for the given axis

get_label(label, axis=None)

Get the label entry and its dimension. If axis is specified, will only be along that axis

Parameters:
  • label (str) – label to lookup

  • axis (int, optional) – axis for the label lookup

Returns:

labels

Return type:

list of (name, axis, start,stop,unit) for the given label

get_label_along_axis(axis, label_name)

Get the request label from on axis.

DEPRECATED - use get_label(…, axis=axis)

get_label_matrix(labels)

Get a sub-matrix data according to the given labels.

Parameters:

labels (list of str) – labels to lookup

Returns:

PintMatrix

Return type:

new matrix with only the specified labels (or relevant subclass)

get_label_names(axis=None)

Return only the names of the labels along the specified axis if requested.

Parameters:

axis (int (optional)) – axis for the label lookup

Returns:

labels

Return type:

list of label names for all dimensions, or just along the specified axis

get_label_size(label, axis=None)

Get the size of the a label for all axes, or just the specified axis.

Parameters:
  • label (str) – Name of the label.

  • axis (int (optional)) – axis for the label lookup

Returns:

sizes

Return type:

list of (start,stop) indices for the given label across each dimension

get_label_slice(labels)

Return the given label slices.

Parameters:

labels (list of str) – labels to lookup

Returns:

slice, labels

Return type:

slice into original matrix and labels of new (sliced) matrix

get_unique_label_names()

Return all unique label names (there may be duplications between axes).

Returns:

  • labels (set of unique label names across all dimensions)

  • TODO (preserve order?)

match_labels_along_axis(pint_matrix, axis)

Match one axis’ labels index between the current matrix and input pint matrix.

The labels will be matched along axes, not cross the axes.

Parameters:
  • pint_matrix (PintMatrix object or its sub-classes.) – The input pint matrix for label matching.

  • axis (int) – The matching axis.

Returns:

  • Index map between the current labels and input matrix labels along

  • axis.

prettyprint(prec=3, coordinatefirst=False, offset=False, usecolor=True)

Return a version of the array formatted for printing (with labels etc).

Parameters:
  • prec (int, optional) – precision of floating-point output

  • coordinatefirst (bool, optional) – whether or not the output should be re-ordered to put the coordinates first (after the Offset, if present)

  • offset (bool, optional) – whether the implicit phase offset (i.e. “Offset”) should be shown

  • usecolor (bool, optional) – use color for “problem” CorrelationMatrix params

Returns:

str

Return type:

matrix formatted for printing

to_correlation_matrix()

Convert a covariance matrix to a correlation matrix. Extract the diagonal elements to use as the uncertainties, and divide through by those values.

Returns:

correlation

Return type:

CorrelationMatrix