1) bw2io.strategies.generic.overwrite_exchange_field_values: The new ExchangeLinker class introduced in f5c9d28 allows "soft-matches", i.e. an exchange field exchange["categories"] = "(air,)" will be identified as matching an activity activity["categories"] = ("air",). However, this means that the exchange data in the database contains a string instead of a tuple. This might be undesirable in some use cases. The new strategy fixes this by going through all exchanges and overwriting their fields with values from the linked activities.
2) bw2io.strategies.generic.assign_default_location: Brightway allows defining activities without a location field. However, tools like the Activity Browser Sankey Diagram expect a location field and will break if there isn't any. This strategy goes through all activities and applies a default_loc where locations are missing.
This PR adds two new generic strategies:
1)
bw2io.strategies.generic.overwrite_exchange_field_values
: The newExchangeLinker
class introduced in f5c9d28 allows "soft-matches", i.e. an exchange fieldexchange["categories"] = "(air,)"
will be identified as matching an activityactivity["categories"] = ("air",)
. However, this means that the exchange data in the database contains a string instead of a tuple. This might be undesirable in some use cases. The new strategy fixes this by going through all exchanges and overwriting their fields with values from the linked activities.2)
bw2io.strategies.generic.assign_default_location
: Brightway allows defining activities without a location field. However, tools like the Activity Browser Sankey Diagram expect a location field and will break if there isn't any. This strategy goes through all activities and applies adefault_loc
where locations are missing.