bw-functional 0b80__tar.gz → 0b83__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {bw_functional-0b80/bw_functional.egg-info → bw_functional-0b83}/PKG-INFO +1 -1
- {bw_functional-0b80 → bw_functional-0b83}/bw_functional/__init__.py +3 -0
- {bw_functional-0b80 → bw_functional-0b83}/bw_functional/allocation.py +1 -1
- {bw_functional-0b80 → bw_functional-0b83}/bw_functional/convert.py +9 -20
- {bw_functional-0b80 → bw_functional-0b83}/bw_functional/node_classes.py +1 -1
- {bw_functional-0b80 → bw_functional-0b83/bw_functional.egg-info}/PKG-INFO +1 -1
- {bw_functional-0b80 → bw_functional-0b83}/LICENSE +0 -0
- {bw_functional-0b80 → bw_functional-0b83}/MANIFEST.in +0 -0
- {bw_functional-0b80 → bw_functional-0b83}/README.md +0 -0
- {bw_functional-0b80 → bw_functional-0b83}/bw_functional/database.py +0 -0
- {bw_functional-0b80 → bw_functional-0b83}/bw_functional/edge_classes.py +0 -0
- {bw_functional-0b80 → bw_functional-0b83}/bw_functional.egg-info/SOURCES.txt +0 -0
- {bw_functional-0b80 → bw_functional-0b83}/bw_functional.egg-info/dependency_links.txt +0 -0
- {bw_functional-0b80 → bw_functional-0b83}/bw_functional.egg-info/requires.txt +0 -0
- {bw_functional-0b80 → bw_functional-0b83}/bw_functional.egg-info/top_level.txt +0 -0
- {bw_functional-0b80 → bw_functional-0b83}/pyproject.toml +0 -0
- {bw_functional-0b80 → bw_functional-0b83}/setup.cfg +0 -0
- {bw_functional-0b80 → bw_functional-0b83}/setup.py +0 -0
- {bw_functional-0b80 → bw_functional-0b83}/tests/test_allocation.py +0 -0
- {bw_functional-0b80 → bw_functional-0b83}/tests/test_database.py +0 -0
- {bw_functional-0b80 → bw_functional-0b83}/tests/test_mf_node.py +0 -0
- {bw_functional-0b80 → bw_functional-0b83}/tests/test_process_node.py +0 -0
- {bw_functional-0b80 → bw_functional-0b83}/tests/test_product_node.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: bw-functional
|
|
3
|
-
Version:
|
|
3
|
+
Version: 0b83
|
|
4
4
|
Summary: Code for handling multifunctional activities in Brightway
|
|
5
5
|
Author-email: Chris Mutel <cmutel@gmail.com>, Marin Visscher <m.r.visscher@cml.leidenuniv.nl>
|
|
6
6
|
Maintainer-email: Marin Visscher <m.r.visscher@cml.leidenuniv.nl>
|
|
@@ -8,6 +8,8 @@ __all__ = (
|
|
|
8
8
|
"MFExchanges",
|
|
9
9
|
"FunctionalSQLiteDatabase",
|
|
10
10
|
"property_allocation",
|
|
11
|
+
"convert_sqlite_to_functional_sqlite",
|
|
12
|
+
"convert_functional_sqlite_to_sqlite"
|
|
11
13
|
)
|
|
12
14
|
# import os
|
|
13
15
|
__version__ = "0.0.2"
|
|
@@ -21,6 +23,7 @@ from .allocation import allocation_strategies, generic_allocation, property_allo
|
|
|
21
23
|
from .database import FunctionalSQLiteDatabase
|
|
22
24
|
from .node_classes import Process, Product
|
|
23
25
|
from .edge_classes import MFExchange, MFExchanges
|
|
26
|
+
from .convert import convert_sqlite_to_functional_sqlite, convert_functional_sqlite_to_sqlite
|
|
24
27
|
|
|
25
28
|
log = getLogger(__name__)
|
|
26
29
|
|
|
@@ -101,7 +101,7 @@ def get_property_value(
|
|
|
101
101
|
|
|
102
102
|
props = product.get("properties")
|
|
103
103
|
|
|
104
|
-
if not props:
|
|
104
|
+
if not props or not isinstance(props, dict):
|
|
105
105
|
raise KeyError(f"Product {product} from process {product.processor} doesn't have properties")
|
|
106
106
|
|
|
107
107
|
prop = props.get(property_label)
|
|
@@ -9,21 +9,16 @@ from .database import FunctionalSQLiteDatabase
|
|
|
9
9
|
log = getLogger(__name__)
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
def convert_sqlite_to_functional_sqlite(
|
|
13
|
-
return SQLiteToFunctionalSQLite.convert(
|
|
12
|
+
def convert_sqlite_to_functional_sqlite(database_dict: dict) -> dict:
|
|
13
|
+
return SQLiteToFunctionalSQLite.convert(database_dict)
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
class SQLiteToFunctionalSQLite:
|
|
17
17
|
@classmethod
|
|
18
|
-
def convert(cls,
|
|
19
|
-
db = bd.Database(database_name)
|
|
20
|
-
|
|
21
|
-
if not isinstance(db, SQLiteBackend):
|
|
22
|
-
raise TypeError("Database is not of type SQLite.")
|
|
23
|
-
|
|
18
|
+
def convert(cls, database_dict: dict):
|
|
24
19
|
converted = {}
|
|
25
20
|
|
|
26
|
-
for key, ds in tqdm.tqdm(
|
|
21
|
+
for key, ds in tqdm.tqdm(database_dict.items()):
|
|
27
22
|
if ds["type"] in ["process", "processwithreferenceproduct"]:
|
|
28
23
|
converted.update(cls.convert_process(key, ds))
|
|
29
24
|
|
|
@@ -87,24 +82,18 @@ class SQLiteToFunctionalSQLite:
|
|
|
87
82
|
exc["input"] = (database, exc["input"][1] + "_function")
|
|
88
83
|
|
|
89
84
|
|
|
90
|
-
def convert_functional_sqlite_to_sqlite(
|
|
91
|
-
return FunctionalSQLiteToSQLite.convert(
|
|
85
|
+
def convert_functional_sqlite_to_sqlite(database_dict: dict):
|
|
86
|
+
return FunctionalSQLiteToSQLite.convert(database_dict)
|
|
92
87
|
|
|
93
88
|
|
|
94
89
|
class FunctionalSQLiteToSQLite:
|
|
95
90
|
@classmethod
|
|
96
|
-
def convert(cls,
|
|
97
|
-
db = bd.Database(database_name)
|
|
98
|
-
|
|
99
|
-
if not isinstance(db, FunctionalSQLiteDatabase):
|
|
100
|
-
raise TypeError("Database is not of type functional_sqlite.")
|
|
101
|
-
|
|
102
|
-
raw = db.load()
|
|
91
|
+
def convert(cls, database_dict: dict):
|
|
103
92
|
converted = {}
|
|
104
93
|
|
|
105
|
-
for key, ds in tqdm.tqdm(
|
|
94
|
+
for key, ds in tqdm.tqdm(database_dict.items()):
|
|
106
95
|
if ds["type"] in ["product", "waste"]:
|
|
107
|
-
processor =
|
|
96
|
+
processor = database_dict[ds["processor"]]
|
|
108
97
|
converted[key] = cls.convert_function(key, ds, processor)
|
|
109
98
|
|
|
110
99
|
return converted
|
|
@@ -257,7 +257,7 @@ class Process(MFActivity):
|
|
|
257
257
|
Returns:
|
|
258
258
|
set[str]: A list of property names available in the process.
|
|
259
259
|
"""
|
|
260
|
-
properties = [prod
|
|
260
|
+
properties = [prod.get("properties", {}) for prod in self.products()]
|
|
261
261
|
property_names = [set(prop.keys()) for prop in properties]
|
|
262
262
|
common_properties = set.intersection(*property_names) if property_names else set()
|
|
263
263
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: bw-functional
|
|
3
|
-
Version:
|
|
3
|
+
Version: 0b83
|
|
4
4
|
Summary: Code for handling multifunctional activities in Brightway
|
|
5
5
|
Author-email: Chris Mutel <cmutel@gmail.com>, Marin Visscher <m.r.visscher@cml.leidenuniv.nl>
|
|
6
6
|
Maintainer-email: Marin Visscher <m.r.visscher@cml.leidenuniv.nl>
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|