Skip to content

Commit

Permalink
Add multifunctional compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
cmutel committed Jul 8, 2024
1 parent ce55895 commit 088e4d6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
13 changes: 12 additions & 1 deletion bw_simapro_csv/brightway.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import datetime
import itertools
from copy import deepcopy
from typing import Union
from uuid import uuid4

from loguru import logger
from multifunctional import allocation_before_writing

from .blocks import (
DatabaseCalculatedParameters,
Expand Down Expand Up @@ -206,4 +206,15 @@ def lci_to_brightway(spcsv: SimaProCSV, missing_string: str = "(unknown)") -> di

data["processes"].append(process_dataset)

if any(
sum(1 for exc in ds.get("exchanges") if exc.get("functional")) > 1
for ds in data["processes"]
):
formatted = {(spcsv.database_name, ds["code"]): ds for ds in data["processes"]}
as_dict = allocation_before_writing(formatted, "manual_allocation")
for (database, code), ds in as_dict.items():
ds["code"] = code
ds["database"] = database
data["processes"] = list(as_dict.values())

return data
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ classifiers = [
requires-python = ">=3.10"
dependencies = [
"bw2parameters",
"multifunctional>=0.4.3",
"ftfy",
"loguru",
"platformdirs",
Expand Down

0 comments on commit 088e4d6

Please sign in to comment.