brightway-lca / brightway2-data

Tools for the management of inventory databases and impact assessment methods. Part of the Brightway LCA framework.
https://docs.brightway.dev/
BSD 3-Clause "New" or "Revised" License
8 stars 21 forks source link

`parameters.add_exchanges_to_group` - can't add multiple activities with only Database parameters #56

Closed aleksandra-kim closed 6 years ago

aleksandra-kim commented 6 years ago

Original report by James Joyce (Bitbucket: pjamesjoyce, GitHub: pjamesjoyce).


Adding multiple activities with formulas containing only database parameters to a group (e.g. "all") causes an error because the dummy parameters created at activity level are not unique.

For example:

for activity in database:
    for exchange in activity.exchanges():
        if exchange.get('formula'):
            bw2.parameters.add_exchanges_to_group("all", activity)
            break

Because there are no activity level parameters specified, parameters.add_exchanges_to_group adds one called "__dummy__", then adds the exchanges to the ParameterizedExchange table.

This works first time around, but then fails for the second activity because "__dummy__" already exists in the group "all".

aleksandra-kim commented 6 years ago

Original comment by Chris Mutel (Bitbucket: cmutel, GitHub: cmutel).


3.4.2. Fixes #56

aleksandra-kim commented 6 years ago

Original comment by Chris Mutel (Bitbucket: cmutel, GitHub: cmutel).


3.4.2 released on pypi and conda.