Despite apparently accepting demand=None, LCA.redo_lci() and LCA.redo_lcia() will fail if no demand argument is provided.
>>> import brightway2 as bw
>>> lca = bw.LCA({('some', 'act'):1})
>>> lca.lci()
>>> lca.redo_lci()
Traceback (most recent call last):
File "C:\mypy\anaconda\envs\bw2020\lib\site-packages\IPython\core\interactiveshell.py", line 3331, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-25-82c6d21a2d04>", line 1, in <module>
lca.redo_lci()
File "C:\mypy\anaconda\envs\bw2020\lib\site-packages\bw2calc\lca.py", line 516, in redo_lci
self.logger.info("Redoing LCI", extra={'demand': wrap_functional_unit(demand or self.demand)})
File "C:\mypy\anaconda\envs\bw2020\lib\site-packages\bw2calc\utils.py", line 219, in wrap_functional_unit
for key, amount in dct.items():
AttributeError: 'NoneType' object has no attribute 'items'
The problem is here (): and here. The line self.demand = demand should be in the if block.
Original report by Pascal Lesage (Bitbucket: MPa, ).
Despite apparently accepting
demand=None
,LCA.redo_lci()
andLCA.redo_lcia()
will fail if no demand argument is provided.The problem is here (): and here. The line
self.demand = demand
should be in the if block.I will provide a PR if there is no objection.