Skip to content

Commit

Permalink
Merge pull request #104 from TimoDiepers/main
Browse files Browse the repository at this point in the history
Explicitly set array-size in MultiLCA's lci_calculation()
  • Loading branch information
cmutel authored Jul 24, 2024
2 parents ef9bac1 + e6a83c0 commit 834f3da
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 2 additions & 3 deletions bw2calc/multi_lca.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,8 @@ def lci_calculation(self) -> None:
"""
count = len(self.dicts.activity)
solutions = spsolve(
self.technosphere_matrix, np.vstack([arr for arr in self.demand_arrays.values()]).T
)
demand_matrix = np.vstack([arr for arr in self.demand_arrays.values()]).T
solutions = spsolve(self.technosphere_matrix, demand_matrix).reshape(count, -1)
self.supply_arrays = {name: arr for name, arr in zip(self.demands, solutions.T)}
# Turn 1-d array into diagonal matrix
self.inventories = mu.SparseMatrixDict(
Expand Down
10 changes: 10 additions & 0 deletions tests/multi_lca.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,16 @@ def test_inventory_matrix_construction(dps, config, func_units):
assert mlca.scores[(("first", "category"), "γ")] == 8 + 3


def test_single_demand(dps, config):
single_func_unit = {"γ": {100: 1}}
mlca = MultiLCA(demands=single_func_unit, method_config=config, data_objs=dps)
mlca.lci()
mlca.lcia()

assert mlca.scores[(("first", "category"), "γ")] == 8 + 3
assert mlca.scores[(("second", "category"), "γ")] == 3 * 10


def test_normalization(dps, func_units):
config = {
"impact_categories": [
Expand Down

0 comments on commit 834f3da

Please sign in to comment.