Skip to content

Commit

Permalink
Merge branch 'main' into technosphere_mat_format
Browse files Browse the repository at this point in the history
  • Loading branch information
cmutel authored Jul 24, 2024
2 parents a89ede1 + 8942c42 commit b2ba342
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-test-pardiso.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
py-version: ["3.9", "3.12"]

steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4

# general Python setup
- name: Set up Python ${{ matrix.py-version }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-test-superlu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
py-version: ["3.12"]

steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4

# general Python setup
- name: Set up Python ${{ matrix.py-version }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-test-umfpack-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
py-version: ["3.11"]

steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4

# general Python setup
- name: Set up Python ${{ matrix.py-version }}
Expand Down
11 changes: 2 additions & 9 deletions bw2calc/multi_lca.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,15 +349,8 @@ def lci_calculation(self) -> None:
"""
count = len(self.dicts.activity)

if PYPARDISO and isinstance(self.technosphere_matrix, csc_matrix):
self.technosphere_matrix.tocsr()
elif not PYPARDISO and isinstance(self.technosphere_matrix, csr_matrix):
self.technosphere_matrix.tocsc()

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 b2ba342

Please sign in to comment.