Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
# Conflicts:
#	pathways/lca.py
  • Loading branch information
romainsacchi authored and romainsacchi committed Mar 28, 2024
2 parents 1b1fe6a + 568462f commit 2c3ca0d
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pathways/lca.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def get_lca_matrices(
indices_array=a_indices,
data_array=a_data,
flip_array=a_sign,
distributions_array= a_distributions,
distributions_array=a_distributions,
)

dp.add_persistent_vector(
Expand Down Expand Up @@ -193,7 +193,10 @@ def fill_characterization_factors_matrices(

return matrix

def remove_double_counting(characterized_inventory: csr_matrix, vars_info: dict, activity_idx: int) -> csr_matrix:

def remove_double_counting(
characterized_inventory: csr_matrix, vars_info: dict, activity_idx: int
) -> csr_matrix:
"""
Remove double counting from a characterized inventory matrix for all activities except
the activity being evaluated, across all methods.
Expand All @@ -208,7 +211,9 @@ def remove_double_counting(characterized_inventory: csr_matrix, vars_info: dict,
if isinstance(characterized_inventory, np.ndarray):
characterized_inventory = csr_matrix(characterized_inventory)
elif not isinstance(characterized_inventory, csr_matrix):
raise TypeError("characterized_inventory must be a csr_matrix or a numpy array.")
raise TypeError(
"characterized_inventory must be a csr_matrix or a numpy array."
)

# Gather all indices for which we want to avoid double counting, except the evaluated activity
list_of_idx_to_remove = []
Expand All @@ -226,4 +231,3 @@ def remove_double_counting(characterized_inventory: csr_matrix, vars_info: dict,
characterized_inventory[:, idx] = 0

return characterized_inventory.tocsr()

0 comments on commit 2c3ca0d

Please sign in to comment.