Brightway2

Latest version: v2.4.6

Safety actively analyzes 629678 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 14 of 34

2.0.dev5

* Fix a bug in `switch_method` if given a `bw2data` method tuuple instead of a list of datapackages.

2.0.dev4

* Add `invert_technosphere_matrix` with algo from haasad
* Fix `switch_method`, `switch_normalization`, `switch_weighting`

Compatibility changes:

* `LCA.score` will return weighted or normalized score, if weighting or normalization has been performed
* `LCA.weighting` will now trigger a deprecation warning. Switch to `.weight` instead.
* `LCA.redo_lci` deprecated in favor of `LCA.lci(demand)`; `LCA.redo_lcia` deprecated in favor of `LCA.lcia(demand)`

2.0.dev3

* Fix for constructing characterization matrices with semi-regionalized impact categories

2.0.dev2

* More 2.5 work and fixes

2.0.dev1

Version 2.0 brings a number of large changes, while maintaining backwards compatibility (except for dropping Py2). The net result of these changes is to prepare for a future where data management is separated from calculations, and where working with large, complicated models is much easier.

Future DEV releases

Before 2.0 is released, the following features will be added:

* Presamples will be adapted to use `bw_processing`
* Logging will be taken seriously :)
* ~~LCA results to dataframes~~

Breaking changes

Simplification of user endpoints

The structure of this library has been simplified, as the `LCA` class can now perform static, stochastic (Monte Carlo), iterative (scenario-based), and single-matrix LCA calculations. Matrix building has been moved to the [matrix_utils](https://github.com/brightway-lca/matrix_utils) library.

Python 2 compatibility removed

Removing the Python 2 compatibility layer allows for much cleaner and more compact code, and the use of some components from the in-development Brightway version 3 libraries. Compatible with `bw2data` version 4.0.

Removal of classes and methods

* `LCA.rebuild_*_matrix` methods are removed. See the [TODO]() notebook for alternatives.
* `DirectSolvingMixin` and `DirectSolvingMonteCarloLCA` are removed, direct solving is now the default
* `ComparativeMonteCarlo` is removed, use `MultiLCA(use_distributions=True)` instead
* `SingleMatrixLCA` is remove, use `LCA` instead. It allows for empty biosphere matrices.

Simplified handling of mapping dictionaries

Mapping dictionaries map the database identifiers to row and column indices. In 2.5, these mapping dictionaries are only created on demand; avoiding their creation saves a bit of time and memory.

Added a new class (`DictionaryManager`) and made it simpler reverse, remap, and get the original dictionaries inside an `LCA`. Here is an example:

python
LCA.dicts.biosphere[x]
>> y
LCA.dicts.biosphere.original if remapped with activity keys
LCA.dicts.biosphere.reversed[y] (generated on demand)
>> x


The dictionaries in a conventional LCA are:

* LCA.dicts.product
* LCA.dicts.activity
* LCA.dicts.biosphere

~~`LCA.reverse_dict` is removed; all reversed dictionaries are available at `LCA.dicts.{name}.reversed`~~.

In 2.5, these mapping dictionaries are not automatically "remapped" to the `(database name, activity code)` keys. You will need to call `.remap_inventory_dicts()` after doing an inventory calculation to get mapping dictionaries in this format.

Weighting is a diagonal matrix instead of a single number

It is easier to have everything in the same mode of operation. This also allows for the use of arrays, distributions, interfaces, etc. in weighting. Implemented in new `SingleValueDiagonalMatrix` class.

Architectual changes

Use of `bw_processing`

We now use [bw_processing](https://github.com/brightway-lca/bw_processing) to load processed arrays. `bw_processing` has separate files for the technosphere and biosphere arrays, and explicit indication of . Therefore, the `TechnosphereBiosphereMatrixBuilder` is no longer necessary, and is removed.

No dependency on `bw2data`

`bw2data` is now an optional install, and even if available only a single utility function is used to prepare input data. `bw2calc` is primarily intended to be used as an independent library.

Changes in Monte Carlo


Smaller changes

New LCA input specification

The existing input specification is still there, but this release also adds the ability to specify input arguments compatible with Brightway version 3. Previously, we would write `LCA({some demand}, method=foo)` - this requires `bw2calc` to use `bw2data` to figure out the dependent databases of the functional unit in `some demand`, and then to get the file paths of all the necessary files for both the inventory and impact assessment. The new syntax is `LCA({some demand}, data_objs)`, where `some demand` is already integer IDs, and `data_objects` is a lists of data packages (either in memory or on the filesystem).

`bw2data` has a helper function to prepare arguments in the new syntax: `prepare_lca_inputs`.

This new input syntax, with consistent column labels for all structured arrays, removes the need for `IndependentLCAMixin`. This is deleted, and the methods `get_vector`, `get_vector_metadata`, and `set_vector` are added.

More robust matrix building

More tests were identified, and undefined behaviour is now specified. For example, the previous matrix builders assumed that the values in the provided row or column dictionaries were sequential integers starting from zero - this assumption is now relaxed, and we allow this dictionary values to start with an offset. There are also tests and documentation on what happens under various cases when `drop_missing` is `False`, but missing values are present.

1.8.0

* Replace `.todense` with `.toarray` to satisfy changes in Scipy API
* Add `atol` parameter to iterative solver to satisfy changes in Scipy API
* Fix regression in 1.7.7 which raises errors when no new `demand` was present ([PR 6](https://bitbucket.org/cmutel/brightway2-calc/pull-requests/6))

Page 14 of 34

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.