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 22 forks source link

LCA dictionaries don't work with Activity Proxies after repeated calculations #31

Closed aleksandra-kim closed 8 years ago

aleksandra-kim commented 8 years ago

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


#!python

In [47]: lca = LCA({elec: 1})

In [48]: lca.lci(factorize=True)

In [49]: lca.lci(factorize=True)
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-49-81d0786914c4> in <module>()
----> 1 lca.lci(factorize=True)

/Users/cmutel/local35/bw3/lib/python3.5/site-packages/bw2calc/lca.py in lci(self, factorize, builder)
    254         """
    255         self.load_lci_data(builder)
--> 256         self.build_demand_array()
    257         if factorize:
    258             self.decompose_technosphere()

/Users/cmutel/local35/bw3/lib/python3.5/site-packages/bw2calc/lca.py in build_demand_array(self, demand)
     88         for key in demand:
     89             try:
---> 90                 self.demand_array[self.product_dict[key]] = demand[key]
     91             except KeyError:
     92                 if key in self.activity_dict:

KeyError: 'electricity, low voltage, production CH, at grid' (kilowatt hour, CH, ['electricity', 'production mix'])

Something about fixing dictionaries and then reloading them...

aleksandra-kim commented 8 years ago

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


Fixed in https://bitbucket.org/cmutel/brightway2-calc/commits/76e5231d44792cb53bd9531ada5d1b0fd139ec43