pint.pint_matrix.PintMatrix
- class pint.pint_matrix.PintMatrix(matrix, axis_labels)[source]
Bases:
object
PINT matrix is a base class for PINT fitters matrix.
- Parameters:
data (numpy.ndarray) – Matrix data.
axis_labels (list of dictionary) – The labels of the axes. Each list element contains the names and indices of the labels for the dimension. [{dim0_label0: (start, end, unit), dim0_label1:(start, end, unit)}, {dim1_label0:…}] The start and end follows the python slice convention (i.e., end = size + 1).
Note
TODO: 1. add index to label mapping
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.
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.
Attributes
label_units
labels
ndim
shape
- diag(k=0)[source]
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_label_names(axis=None)[source]
Return only the names of the labels along the specified axis if requested.
- get_unique_label_names()[source]
Return all unique label names (there may be duplications between axes).
- Returns:
labels (set of unique label names across all dimensions)
TODO (preserve order?)
- get_label_size(label, axis=None)[source]
Get the size of the a label for all axes, or just the specified axis.
- get_label(label, axis=None)[source]
Get the label entry and its dimension. If axis is specified, will only be along that axis
- get_label_along_axis(axis, label_name)[source]
Get the request label from on axis.
DEPRECATED - use get_label(…, axis=axis)
- match_labels_along_axis(pint_matrix, axis)[source]
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.