bw_processing.matrix_entry ========================== .. py:module:: bw_processing.matrix_entry Classes ------- .. autoapisummary:: bw_processing.matrix_entry.MatrixEntry bw_processing.matrix_entry.MatrixName Functions --------- .. autoapisummary:: bw_processing.matrix_entry.create_datapackage_from_entries Module Contents --------------- .. py:class:: MatrixEntry A single entry destined for a matrix cell. Multiple instances with the same (row, col) are summed during matrix construction, so this is not necessarily the final cell value. Field names and defaults match those expected by bw_processing's ``dictionary_formatter``. Convert to a plain dict with ``as_dict()`` before passing to bw_processing internals. :param row: Integer row index in the target matrix. :param col: Integer column index in the target matrix. :param amount: The numeric value to place at (row, col). :param flip: If True, multiply the value by -1 when building the matrix. :param uncertainty_type: Probability distribution type (0 = no uncertainty, 2 = lognormal, 3 = normal, etc. — see stats_arrays for full list). :param loc: Distribution location parameter. For lognormal this is the log of the median; defaults to NaN (no uncertainty). :param scale: Distribution scale parameter (e.g. standard deviation). :param shape: Distribution shape parameter. :param minimum: Lower bound for distribution sampling. :param maximum: Upper bound for distribution sampling. :param negative: Whether the underlying value is negative. .. py:method:: as_dict() -> dict .. py:attribute:: amount :type: float .. py:attribute:: col :type: int .. py:attribute:: flip :type: bool :value: False .. py:attribute:: loc :type: float :value: nan .. py:attribute:: maximum :type: float :value: nan .. py:attribute:: minimum :type: float :value: nan .. py:attribute:: negative :type: bool :value: False .. py:attribute:: row :type: int .. py:attribute:: scale :type: float :value: nan .. py:attribute:: shape :type: float :value: nan .. py:attribute:: uncertainty_type :type: int :value: 0 .. py:class:: MatrixName Bases: :py:obj:`str`, :py:obj:`enum.Enum` Standard matrix names used in Brightway. Because this is a ``str`` enum, members can be used anywhere a plain string is accepted — no ``.value`` needed:: MatrixEntry(row=1, col=4, amount=2.5) # inside a dict keyed by MatrixName dp.add_entries(matrix=MatrixName.technosphere, entries=[...]) Derived libraries may define additional matrices as plain strings; these three cover the core Brightway LCA workflow. Initialize self. See help(type(self)) for accurate signature. .. py:attribute:: biosphere :value: 'biosphere_matrix' .. py:attribute:: characterization :value: 'characterization_matrix' .. py:attribute:: technosphere :value: 'technosphere_matrix' .. py:function:: create_datapackage_from_entries(data: dict, fs=None, **metadata) Create a datapackage from a dictionary of :class:`MatrixEntry` lists. This is the recommended high-level entry point for building datapackages without working directly with NumPy arrays. :param data: Dictionary mapping matrix names to lists of :class:`MatrixEntry` objects. Use :class:`MatrixName` members as keys for the standard Brightway matrices; derived libraries may use plain strings for additional matrices:: { MatrixName.technosphere: [ MatrixEntry(row=1, col=4, amount=2.5), MatrixEntry(row=2, col=5, amount=7.0, flip=True), ], MatrixName.biosphere: [ MatrixEntry(row=10, col=4, amount=0.3), ], } :param fs: Optional filesystem. Defaults to an in-memory filesystem. :param \*\*metadata: Additional keyword arguments passed to :func:`create_datapackage` (e.g. ``name``, ``id_``). :returns: A :class:`Datapackage` instance.