hestia-earth-models 0.65.8__py3-none-any.whl → 0.65.10__py3-none-any.whl
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.
- hestia_earth/models/cml2001Baseline/abioticResourceDepletionFossilFuels.py +3 -5
- hestia_earth/models/cml2001Baseline/abioticResourceDepletionMineralsAndMetals.py +1 -1
- hestia_earth/models/config/Cycle.json +368 -388
- hestia_earth/models/config/Site.json +18 -0
- hestia_earth/models/config/__init__.py +6 -0
- hestia_earth/models/config/run-calculations.json +5 -5
- hestia_earth/models/config/trigger-calculations.json +1 -1
- hestia_earth/models/cycle/materialAndSubstrate.py +1 -1
- hestia_earth/models/cycle/milkYield.py +9 -6
- hestia_earth/models/cycle/product/economicValueShare.py +8 -4
- hestia_earth/models/cycle/product/revenue.py +11 -7
- hestia_earth/models/environmentalFootprintV3/soilQualityIndexLandTransformation.py +12 -4
- hestia_earth/models/faostat2018/product/price.py +1 -1
- hestia_earth/models/geospatialDatabase/utils.py +22 -17
- hestia_earth/models/hestia/landCover.py +2 -2
- hestia_earth/models/mocking/search-results.json +843 -843
- hestia_earth/models/site/defaultMethodClassification.py +35 -0
- hestia_earth/models/site/defaultMethodClassificationDescription.py +39 -0
- hestia_earth/models/site/management.py +34 -23
- hestia_earth/models/utils/impact_assessment.py +5 -3
- hestia_earth/models/utils/lookup.py +3 -3
- hestia_earth/models/version.py +1 -1
- {hestia_earth_models-0.65.8.dist-info → hestia_earth_models-0.65.10.dist-info}/METADATA +2 -2
- {hestia_earth_models-0.65.8.dist-info → hestia_earth_models-0.65.10.dist-info}/RECORD +39 -35
- tests/models/cml2001Baseline/test_abioticResourceDepletionFossilFuels.py +2 -16
- tests/models/cml2001Baseline/test_abioticResourceDepletionMineralsAndMetals.py +2 -16
- tests/models/edip2003/test_ozoneDepletionPotential.py +0 -13
- tests/models/environmentalFootprintV3/test_soilQualityIndexLandTransformation.py +8 -15
- tests/models/hestia/test_landCover.py +2 -1
- tests/models/ipcc2021/test_gwp100.py +0 -9
- tests/models/poschEtAl2008/test_terrestrialAcidificationPotentialAccumulatedExceedance.py +0 -14
- tests/models/poschEtAl2008/test_terrestrialEutrophicationPotentialAccumulatedExceedance.py +0 -14
- tests/models/site/test_defaultMethodClassification.py +18 -0
- tests/models/site/test_defaultMethodClassificationDescription.py +18 -0
- tests/models/site/test_management.py +2 -1
- tests/models/test_config.py +11 -2
- {hestia_earth_models-0.65.8.dist-info → hestia_earth_models-0.65.10.dist-info}/LICENSE +0 -0
- {hestia_earth_models-0.65.8.dist-info → hestia_earth_models-0.65.10.dist-info}/WHEEL +0 -0
- {hestia_earth_models-0.65.8.dist-info → hestia_earth_models-0.65.10.dist-info}/top_level.txt +0 -0
@@ -18,7 +18,6 @@ def fake_rounded_indicator(value: float):
|
|
18
18
|
return indicator
|
19
19
|
|
20
20
|
|
21
|
-
land_cover_terms = ['cropland', 'seaOrOcean', 'forest']
|
22
21
|
crop_land = {"@id": "cropland", "termType": "landCover"}
|
23
22
|
sea_land_cover = {"@id": "seaOrOcean", "termType": "landCover"}
|
24
23
|
forest = {"@id": "forest", "termType": "landCover"}
|
@@ -27,26 +26,18 @@ indicator = {
|
|
27
26
|
"termType": "resourceUse",
|
28
27
|
"units": "m2 / year"
|
29
28
|
}
|
30
|
-
|
31
29
|
wrong_indicator = {"term": {"@id": "NOT_VALID_INDICATOR_ID", "termType": "resourceUse", "units": "m2 / year"},
|
32
|
-
"value": 0.5, "landCover": crop_land}
|
30
|
+
"value": 0.5, "landCover": crop_land, "previousLandCover": forest}
|
33
31
|
|
34
32
|
indicator_no_land_cover = {
|
35
33
|
"term": indicator,
|
36
34
|
"previousLandCover": forest,
|
37
35
|
"value": 0.5}
|
38
36
|
|
39
|
-
|
40
|
-
"term": indicator,
|
41
|
-
"previousLandCover": forest,
|
42
|
-
"value": 0.5,
|
43
|
-
"landCover": crop_land}
|
44
|
-
|
45
|
-
indicator_wrong_unit = {
|
37
|
+
indicator_no_previous_land_cover = {
|
46
38
|
"term": indicator,
|
47
|
-
"
|
48
|
-
"
|
49
|
-
"landCover": crop_land}
|
39
|
+
"landCover": crop_land,
|
40
|
+
"value": 0.5}
|
50
41
|
|
51
42
|
indicator_bad_area_value = {
|
52
43
|
"term": indicator,
|
@@ -73,13 +64,13 @@ good_inputs_production_indicator_from_forest_to_forest = {
|
|
73
64
|
"landCover": forest}
|
74
65
|
|
75
66
|
good_during_cycle_indicator_from_forest_to_cropland = {
|
76
|
-
"term": indicator,
|
67
|
+
"term": indicator | {'@id': 'landTransformation20YearAverageDuringCycle'},
|
77
68
|
"value": 0.5,
|
78
69
|
"previousLandCover": forest,
|
79
70
|
"landCover": crop_land}
|
80
71
|
|
81
72
|
good_during_cycle_indicator_from_forest_to_forest = {
|
82
|
-
"term": indicator,
|
73
|
+
"term": indicator | {'@id': 'landTransformation20YearAverageDuringCycle'},
|
83
74
|
"value": 0.5,
|
84
75
|
"previousLandCover": forest,
|
85
76
|
"landCover": forest}
|
@@ -91,6 +82,7 @@ good_during_cycle_indicator_from_forest_to_forest = {
|
|
91
82
|
([], True, 0),
|
92
83
|
([wrong_indicator], True, 0),
|
93
84
|
([indicator_no_land_cover], False, 0),
|
85
|
+
([indicator_no_previous_land_cover], False, 0),
|
94
86
|
([indicator_bad_area_value], False, 0),
|
95
87
|
([good_during_cycle_indicator_from_forest_to_cropland], True, 1),
|
96
88
|
([good_during_cycle_indicator_from_forest_to_forest], True, 1),
|
@@ -103,6 +95,7 @@ good_during_cycle_indicator_from_forest_to_forest = {
|
|
103
95
|
ids=["No emissionsResourceUse => run, 0 dict",
|
104
96
|
"Wrong indicator termid => run, 0 dict",
|
105
97
|
"Indicator no landcover terms => no run",
|
98
|
+
"Indicator no previousLandCover terms => no run",
|
106
99
|
"Bad m2 / year value => no run",
|
107
100
|
"One good during cycle transformation => run, 1 dict",
|
108
101
|
"One 0 during cycle transformation => run, 1 dict",
|
@@ -196,7 +196,8 @@ def test_get_sums_of_crop_expansion():
|
|
196
196
|
"brazil_empty_example",
|
197
197
|
"gbr_example",
|
198
198
|
"malaysia",
|
199
|
-
"prior_landCover"
|
199
|
+
"prior_landCover",
|
200
|
+
"nigeria_cassava"
|
200
201
|
]
|
201
202
|
)
|
202
203
|
@patch(f"{CLASS_PATH}._new_management", side_effect=fake_new_management)
|
@@ -8,15 +8,6 @@ class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}"
|
|
8
8
|
fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
|
9
9
|
|
10
10
|
|
11
|
-
def test_run_no_emissions():
|
12
|
-
with open(f"{fixtures_path}/impact_assessment/emissions/impact-assessment.jsonld", encoding='utf-8') as f:
|
13
|
-
impact = json.load(f)
|
14
|
-
|
15
|
-
impact['emissionsResourceUse'] = []
|
16
|
-
indicator = run(impact)
|
17
|
-
assert indicator.get('value') == 0
|
18
|
-
|
19
|
-
|
20
11
|
@patch(f"{class_path}._new_indicator", side_effect=fake_new_indicator)
|
21
12
|
def test_run(*args):
|
22
13
|
with open(f"{fixtures_path}/impact_assessment/emissions/impact-assessment.jsonld", encoding='utf-8') as f:
|
@@ -42,17 +42,3 @@ def test_lookup_to_bad_country(*args):
|
|
42
42
|
|
43
43
|
value = run(impactassessment)
|
44
44
|
assert value == expected
|
45
|
-
|
46
|
-
|
47
|
-
@patch(f"{class_path}._new_indicator", side_effect=fake_new_indicator)
|
48
|
-
def test_run_no_emissions(*args):
|
49
|
-
"""
|
50
|
-
Impact assessment with no emissions should return a indicator of 0
|
51
|
-
"""
|
52
|
-
with open(f"{fixtures_folder}/impact-assessment.jsonld", encoding='utf-8') as f:
|
53
|
-
impactassessment = json.load(f)
|
54
|
-
|
55
|
-
del impactassessment['emissionsResourceUse']
|
56
|
-
|
57
|
-
value = run(impactassessment)
|
58
|
-
assert value['value'] == 0
|
@@ -42,17 +42,3 @@ def test_lookup_to_bad_country(*args):
|
|
42
42
|
|
43
43
|
value = run(impactassessment)
|
44
44
|
assert value == expected
|
45
|
-
|
46
|
-
|
47
|
-
@patch(f"{class_path}._new_indicator", side_effect=fake_new_indicator)
|
48
|
-
def test_run_no_emissions(*args):
|
49
|
-
"""
|
50
|
-
Impact assessment with no emissions should return a indicator of 0
|
51
|
-
"""
|
52
|
-
with open(f"{fixtures_folder}/impact-assessment.jsonld", encoding='utf-8') as f:
|
53
|
-
impactassessment = json.load(f)
|
54
|
-
|
55
|
-
del impactassessment['emissionsResourceUse']
|
56
|
-
|
57
|
-
value = run(impactassessment)
|
58
|
-
assert value['value'] == 0
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import json
|
2
|
+
from tests.utils import fixtures_path
|
3
|
+
|
4
|
+
from hestia_earth.models.site.defaultMethodClassification import MODEL, MODEL_KEY, run
|
5
|
+
|
6
|
+
class_path = f"hestia_earth.models.{MODEL}.{MODEL_KEY}"
|
7
|
+
fixtures_folder = f"{fixtures_path}/{MODEL}/{MODEL_KEY}"
|
8
|
+
|
9
|
+
|
10
|
+
def test_run():
|
11
|
+
with open(f"{fixtures_folder}/site.jsonld", encoding='utf-8') as f:
|
12
|
+
site = json.load(f)
|
13
|
+
|
14
|
+
with open(f"{fixtures_folder}/result.txt", encoding='utf-8') as f:
|
15
|
+
expected = f.read().strip()
|
16
|
+
|
17
|
+
result = run(site)
|
18
|
+
assert result == expected
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import json
|
2
|
+
from tests.utils import fixtures_path
|
3
|
+
|
4
|
+
from hestia_earth.models.site.defaultMethodClassificationDescription import MODEL, MODEL_KEY, run
|
5
|
+
|
6
|
+
class_path = f"hestia_earth.models.{MODEL}.{MODEL_KEY}"
|
7
|
+
fixtures_folder = f"{fixtures_path}/{MODEL}/{MODEL_KEY}"
|
8
|
+
|
9
|
+
|
10
|
+
def test_run():
|
11
|
+
with open(f"{fixtures_folder}/site.jsonld", encoding='utf-8') as f:
|
12
|
+
site = json.load(f)
|
13
|
+
|
14
|
+
with open(f"{fixtures_folder}/result.txt", encoding='utf-8') as f:
|
15
|
+
expected = f.read().strip()
|
16
|
+
|
17
|
+
result = run(site)
|
18
|
+
assert result == expected
|
@@ -12,7 +12,8 @@ fixtures_folder = os.path.join(fixtures_path, MODEL, MODEL_KEY)
|
|
12
12
|
|
13
13
|
_LAND_COVER_TERM_BY_SITE_TYPE = {
|
14
14
|
SiteSiteType.ANIMAL_HOUSING.value: "animalHousing",
|
15
|
-
SiteSiteType.CROPLAND.value: "cropland"
|
15
|
+
SiteSiteType.CROPLAND.value: "cropland",
|
16
|
+
SiteSiteType.AGRI_FOOD_PROCESSOR.value: "agriFoodProcessor"
|
16
17
|
}
|
17
18
|
_folders = [d for d in os.listdir(fixtures_folder) if os.path.isdir(os.path.join(fixtures_folder, d))]
|
18
19
|
|
tests/models/test_config.py
CHANGED
@@ -3,7 +3,8 @@ import importlib
|
|
3
3
|
from hestia_earth.utils.tools import flatten
|
4
4
|
|
5
5
|
from hestia_earth.models.config import (
|
6
|
-
load_config, config_max_stage, _is_aggregated_model, _remove_aggregated, load_run_config, load_trigger_config
|
6
|
+
load_config, config_max_stage, _is_aggregated_model, _remove_aggregated, load_run_config, load_trigger_config,
|
7
|
+
get_max_stage
|
7
8
|
)
|
8
9
|
|
9
10
|
|
@@ -107,9 +108,17 @@ def _get_models_paths(node_type: str):
|
|
107
108
|
'node_type',
|
108
109
|
['Cycle', 'Site', 'ImpactAssessment']
|
109
110
|
)
|
110
|
-
def test_load_config_cycle(node_type):
|
111
|
+
def test_load_config_cycle(node_type: str):
|
111
112
|
paths = _get_models_paths(node_type)
|
112
113
|
|
113
114
|
for path in paths:
|
114
115
|
run = importlib.import_module(path).run
|
115
116
|
assert run is not None, path
|
117
|
+
|
118
|
+
|
119
|
+
@pytest.mark.parametrize(
|
120
|
+
'node_type, max_stage',
|
121
|
+
[('Cycle', 2), ('Site', 2), ('ImpactAssessment', 1)]
|
122
|
+
)
|
123
|
+
def test_get_max_stage(node_type: str, max_stage: int):
|
124
|
+
assert get_max_stage(node_type) == max_stage, node_type
|
File without changes
|
File without changes
|
{hestia_earth_models-0.65.8.dist-info → hestia_earth_models-0.65.10.dist-info}/top_level.txt
RENAMED
File without changes
|