pg_utils.numerics.matrices.LabeledBlockMatrix

class pg_utils.numerics.matrices.LabeledBlockMatrix(matrix: ndarray, row_names: List[str], row_ranges: List[int], col_names: List[str], col_ranges: List[int])[source]

Bases: object

Block matrix with labels assigned to row & col blocks

Unlike functions e.g. numpy.block, LabeledBlockMatrix assumes the matrix are segmented into block separated by fixed grid lines, i.e:

AAA BB
AAA BB
CCC DD

but not in the forms of:

AAA BB
AAA BB
CC DDD

or:

AAA BB
CCC BB
CCC DD

and so each block can be determined by one row and one column idx.

Variables:
  • _row_idx (dict) – key=label(str) -> value=row indices of the block (slice)

  • _col_idx (dict) – key=label(str) -> value=col indices of the block (slice)

  • _matrix (np.ndarray) – the underlying matrix

__init__(matrix: ndarray, row_names: List[str], row_ranges: List[int], col_names: List[str], col_ranges: List[int]) None[source]

Initialization

Parameters:
  • row_names (array-like) – names of the row blocks

  • row_ranges – array of integers, the size of each block in number of rows.

  • col_names (array-like) – names of the col blocks

  • col_ranges – array of integers, the size of each block in number of cols.

Methods

__init__(matrix, row_names, row_ranges, ...)

Initialization