bw2calc.single_value_diagonal_matrix
#
Module Contents#
Classes#
A scipy sparse matrix handler which takes in |
- 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: Union[int, None] = None, indexer_override: Any = None, custom_filter: Union[Callable, None] = None)[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.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.
Args:
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