fips.MatrixBlock#
- class fips.MatrixBlock(data, row_block=None, col_block=None, name=None, index=None, columns=None, dtype=None, copy=False, sparse=False)[source]#
Bases:
SingleBlockMixin,Structure2DSingle 2D data block with row and column block names.
A MatrixBlock wraps a pandas DataFrame and can be initialized from an existing DataFrame or from raw values.
MatrixBlocks are the fundamental 2D building units of fips, used to compose larger Matrix objects. MatrixBlocks represent the relationships between specific row and column blocks (e.g., state-to-observation mappings in forward operators, or covariance submatrices between specific state components). By organizing data into MatrixBlocks, users can create modular and interpretable representations of complex inverse problems, with clear semantics for how different components interact.
- Parameters:
data (np.ndarray or pd.DataFrame or MatrixBlock or scalar) – 2D data representing the block. If MatrixBlock, creates a copy.
row_block (str, optional) – Name of the row block (e.g., “state”, “obs”). Required if data is not a MatrixBlock.
col_block (str, optional) – Name of the column block (e.g., “state”, “obs”). Required if data is not a MatrixBlock.
name (str, optional) – Name for the block. If None, defaults to “{row_block}_{col_block}”.
index (pd.Index, optional) – Index for the rows of the DataFrame.
columns (pd.Index, optional) – Index for the columns of the DataFrame. If None, uses the same as index.
dtype (data type, optional) – Data type to force.
copy (bool, optional) – Whether to copy the data.
sparse (bool, default False) – If True, store the block in pandas sparse format. Sparsification is applied after initialization. Use threshold zeroing in your builder before passing data here for best results.
Attributes
Name of the column block (e.g., 'state', 'obs'). |
|
Name of the row block (e.g., 'state', 'obs'). |
Methods
|
Convert to DataFrame with optional block level. |
Inherited
From Structure2D: columns, data, is_sparse, name, to_dense, to_sparse, values
From Structure: copy, index, reindex, round_index, shape, to_numpy, xs
From Pickleable: from_file, to_file