Closed BenPortner closed 2 years ago
I have been bitten by the same bug:
In [1]: import bw2data as bd
In [2]: bd.projects
Out[2]:
Brightway2 projects manager with 2 objects:
default
im_project
Use `projects.report()` to get a report on all projects.
In [3]: bd.projects.set_current('im_project')
In [4]: bd.databases
Out[4]:
Databases dictionary with 2 object(s):
biosphere3
imdb-cutoff
In [5]: db = bd.Database('imdb-cutoff')
In [6]: a = db.random()
In [7]: a_lca = a.lca()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Input In [7], in <cell line: 1>()
----> 1 a_lca = a.lca()
File /opt/conda/lib/python3.10/site-packages/bw2data/proxies.py:114, in ActivityProxyBase.lca(self, method, amount)
112 if method is not None:
113 lca.lcia()
--> 114 lca.fix_dictionaries()
115 return lca
AttributeError: 'LCA' object has no attribute 'fix_dictionaries'
In [8]: bd.version.version
Out[8]: (4, 0, 'DEV16')
In [9]: import bw2calc as bc
In [10]: bc.version.version
Out[10]: (2, 0, 'DEV7')
old fix_dictionaries
docstrings return part:
Doesn't require any arguments or return anything, but changes
self.activity_dict
,self.product_dict
andself.biosphere_dict
.
but newer LCA objects give access to such dictionaries at: self.dicts.activity|product|biosphere
.
from brightway2 import *
projects.set_current('im')
db = Database('imdb')
a = db.random()
a_lca = LCA({a:1})
a_lca.lci() # lci will call load_lci_data
# that will call fix_dictionaries [this is a bool argument to load_lci_data set to True as default
# a dictionary of the form :
# { ...
# ('imdb', '3bec80a23977b9a87692eef35d2f4696'): 996,
# ('imdb', 'f89b229b8988e5567c5763ac96f4058b'): 997,
# ('imdb', '7f412e5c53d9f1407fa8c6d9f040b710'): 998,
#('imdb', '5698628595cc6322ce8449a548a58114'): 999,
# ...}
# will be already available at:
a_lca.activity_dict
import bw2data as bd
import bw2calc as bc
bd.projects
bd.projects.set_current('im')
db = bd.Database('imdb')
a = db.random()
a_lca = LCA({a:1})
a_lca.lci()
a_lca.remap_inventory_dicts()
# a dictionary of the form:
# { ...
# ('imdb', 'f0253628810ae8e5e058b1b7a0228adb'): 996,
# ('imdb', '7713e1ce9fa532d09452a206e03f1fa0'): 997,
# ('imdb', '2596232e969a929c42ac37ffdb779837'): 998,
# ('imdb', '03e0389304cf39a6c80afa42f25e61a2'): 999,
# ...}
# will be available at:
lca.dicts.activity
Exchange.lca()
fails withAttributeError: 'LCA' object has no attribute 'fix_dictionaries'
. The error originates in this line. Apparently, the method does not exist anymore.Minimum Error Example: