-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow non-unitary production amounts
- Loading branch information
1 parent
a5cc56e
commit 2e26261
Showing
3 changed files
with
86 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
from datetime import datetime | ||
|
||
import bw2data as bd | ||
import pytest | ||
|
||
from bw_timex import TimexLCA | ||
|
||
|
||
# make sure the test db is loaded | ||
def test_nonunitary_db_fixture(nonunitary_db): | ||
assert len(bd.databases) == 3 | ||
|
||
|
||
@pytest.mark.usefixtures("nonunitary_db") | ||
class TestClass_EV: | ||
|
||
@pytest.fixture(autouse=True) | ||
def setup_method(self): | ||
self.node_a = bd.get_node(database="foreground", code="A") | ||
|
||
database_date_dict = { | ||
"db_2020": datetime.strptime("2020", "%Y"), | ||
"foreground": "dynamic", | ||
} | ||
|
||
self.tlca = TimexLCA( | ||
demand={self.node_a: 1}, | ||
method=("GWP", "example"), | ||
database_date_dict=database_date_dict, | ||
) | ||
|
||
self.tlca.build_timeline() | ||
self.tlca.lci() | ||
self.tlca.static_lcia() | ||
|
||
def test_timex_lca_score(self): | ||
|
||
expected_score = ( | ||
1 * 1.5 / 3 * 0.5 + 1 * 4 / 7 * 0.9 # A -> Nonunitary C in bd_2020 | ||
) # A -> B -> Nonunitary B in foreground | ||
|
||
false_score = ( | ||
1 * 1.5 / 3 * 0.5 + 1 * 4 * 0.9 # A -> Nonunitary C in bd_2020 | ||
) # A -> B -> Nonunitary B in foreground (not scaled by production amount!) | ||
|
||
print(false_score) | ||
|
||
assert self.tlca.score == expected_score |