Skip to content

Commit 859060e

Browse files
committed
Sensitivity analysis syntax fix
1 parent 9181026 commit 859060e

2 files changed

Lines changed: 11 additions & 9 deletions

File tree

activity_browser/bwutils/sensitivity_analysis.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,23 @@ def get_lca(fu, method):
4646
return lca
4747

4848

49-
def filter_technosphere_exchanges(fu, method, cutoff=0.05, max_calc=1000):
49+
def filter_technosphere_exchanges(lca, cutoff=0.05, max_calc=1000):
5050
"""Use brightway's GraphTraversal to identify the relevant
5151
technosphere exchanges in a non-stochastic LCA."""
5252
start = time()
53-
res = NewNodeEachVisitGraphTraversal.calculate(fu, method, cutoff=cutoff, max_calc=int(max_calc))
53+
res = NewNodeEachVisitGraphTraversal.calculate(lca, cutoff=cutoff, max_calc=int(max_calc))
5454

5555
# get all edges
5656
technosphere_exchange_indices = []
5757
for e in res["edges"]:
58-
if e["to"] != -1: # filter out head introduced in graph traversal
59-
technosphere_exchange_indices.append((e["from"], e["to"]))
58+
if e.consumer_index != -1: # filter out head introduced in graph traversal
59+
technosphere_exchange_indices.append((e.producer_index, e.consumer_index))
6060
log.info(
6161
"TECHNOSPHERE {} filtering resulted in {} of {} exchanges and took {} iterations in {} seconds.".format(
62-
res["lca"].technosphere_matrix.shape,
62+
lca.technosphere_matrix.shape,
6363
len(technosphere_exchange_indices),
64-
res["lca"].technosphere_matrix.getnnz(),
65-
res["counter"],
64+
lca.technosphere_matrix.getnnz(),
65+
res["calculation_count"],
6666
np.round(time() - start, 2),
6767
)
6868
)
@@ -348,7 +348,7 @@ def perform_GSA(
348348
# technosphere
349349
if self.mc.include_technosphere:
350350
self.t_indices = filter_technosphere_exchanges(
351-
self.fu, self.method, cutoff=cutoff_technosphere, max_calc=1e4
351+
self.lca, cutoff=cutoff_technosphere, max_calc=1e4
352352
)
353353
self.t_exchanges, self.t_indices = get_exchanges(self.lca, self.t_indices)
354354
self.dft = get_exchanges_dataframe(self.t_exchanges, self.t_indices)

activity_browser/layouts/pages/lca_results/LCA_results.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2164,7 +2164,9 @@ def calculate_gsa(self):
21642164
cutoff_biosphere=cutoff_biosphere,
21652165
)
21662166
# self.update_mc()
2167-
except Exception as e: # Catch any error...
2167+
except Exception as e:
2168+
import traceback
2169+
traceback.print_tb(e.__traceback__)
21682170
log.error(e)
21692171
message = str(e)
21702172
message_addition = ""

0 commit comments

Comments
 (0)