bw2calc.single_value_diagonal_matrix#
Classes#
A scipy sparse matrix handler which takes in |
Module Contents#
- class bw2calc.single_value_diagonal_matrix.SingleValueDiagonalMatrix(*, packages: Sequence[bw_processing.Datapackage], matrix: str, dimension: int, use_vectors: bool = True, use_arrays: bool = True, use_distributions: bool = False, seed_override: int | None = None, indexer_override: Any = None, custom_filter: Callable | None = None, **kwargs)[source]#
Bases:
matrix_utils.MappedMatrix
A scipy sparse matrix handler which takes in
bw_processing
data packages. Row and column ids are mapped to matrix indices, and a matrix is constructed.Use primarily in the weighting step of life cycle impact assessment.
indexer_override allows for custom indexer behaviour. Indexers should follow a simple API: they must support .__next__(), and have the attribute .index, which returns an integer.
custom_filter allows you to remove some data based on their indices. It is applied to all resource groups. If you need more fine-grained control, process the matrix after construction/iteration. custom_filter should take the indices array as an input, and return a Numpy boolean array with the same length as the indices array.
- Parameters:
packages (*) β A list of Ddatapackage objects.
matrix (*) β The string identifying the matrix to be built.
use_vectors (*) β Flag to use vector data from datapackages
use_arrays (*) β Flag to use array data from datapackages
use_distributions (*) β Flag to use stats_arrays distribution data from datapackages
row_mapper (*) β Optional instance of ArrayMapper. Used when matrices must align.
col_mapper (*) β Optional instance of ArrayMapper. Used when matrices must align.
seed_override (*) β Optional integer. Overrides the RNG seed given in the datapackage, if any.
indexer_override (*) β Parameter for custom indexers. See above.
diagonal (*) β If True, only use the row indices to build a diagonal matrix.
custom_filter (*) β Callable for function to filter data based on indices values. See above.
empty_ok (*) β If False, raise AllArraysEmpty if the matrix would be empty