Skip to content

Commit

Permalink
#78 fix only that dynamic_biomatrix elements are added only once per …
Browse files Browse the repository at this point in the history
…time_mapped_producer
  • Loading branch information
muelleram committed Aug 1, 2024
1 parent 33527bd commit 7c0a01e
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions bw_timex/dynamic_biosphere_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ def __init__(
self.rows = []
self.cols = []
self.values = []
self.unique_rows_cols = set() # To keep track of (row, col) pairs

def build_dynamic_biosphere_matrix(
self,
Expand Down Expand Up @@ -260,6 +261,7 @@ def demand_from_technosphere(self, idx, process_col_index):
def add_matrix_entry_for_biosphere_flows(self, row, col, amount):
"""
Adds an entry to the lists of row, col and values, which are then used to construct the dynamic biosphere matrix.
Only unqiue entries are added, i.e. if the same row and col index already exists, the value is not added again.
Parameters
----------
Expand All @@ -275,6 +277,12 @@ def add_matrix_entry_for_biosphere_flows(self, row, col, amount):
None, but the lists of row, col and values are updated
"""
self.rows.append(row)
self.cols.append(col)
self.values.append(amount)

if (row, col) not in self.unique_rows_cols:
self.rows.append(row)
self.cols.append(col)
self.values.append(amount)

self.unique_rows_cols.add((row, col))


0 comments on commit 7c0a01e

Please sign in to comment.