hestia-earth-models 0.65.11__py3-none-any.whl → 0.67.0__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/cache_sites.py +7 -9
- hestia_earth/models/cml2001Baseline/abioticResourceDepletionFossilFuels.py +23 -54
- hestia_earth/models/cml2001Baseline/resourceUseEnergyDepletionDuringCycle.py +152 -0
- hestia_earth/models/cml2001Baseline/resourceUseEnergyDepletionInputsProduction.py +40 -0
- hestia_earth/models/cml2001Baseline/resourceUseMineralsAndMetalsDuringCycle.py +80 -0
- hestia_earth/models/cml2001Baseline/resourceUseMineralsAndMetalsInputsProduction.py +40 -0
- hestia_earth/models/config/Cycle.json +34 -16
- hestia_earth/models/config/ImpactAssessment.json +1867 -1832
- hestia_earth/models/config/Site.json +4 -1
- hestia_earth/models/cycle/completeness/freshForage.py +10 -2
- hestia_earth/models/cycle/cropResidueManagement.py +3 -1
- hestia_earth/models/cycle/input/hestiaAggregatedData.py +13 -10
- hestia_earth/models/ecoinventV3/__init__.py +2 -1
- hestia_earth/models/{environmentalFootprintV3 → environmentalFootprintV3_1}/__init__.py +4 -3
- hestia_earth/models/environmentalFootprintV3_1/environmentalFootprintSingleOverallScore.py +135 -0
- hestia_earth/models/environmentalFootprintV3_1/marineEutrophicationPotential.py +36 -0
- hestia_earth/models/environmentalFootprintV3_1/scarcityWeightedWaterUse.py +40 -0
- hestia_earth/models/{environmentalFootprintV3 → environmentalFootprintV3_1}/soilQualityIndexLandTransformation.py +17 -6
- hestia_earth/models/geospatialDatabase/{aware.py → awareWaterBasinId.py} +1 -1
- hestia_earth/models/hestia/landCover.py +42 -34
- hestia_earth/models/hestia/residueRemoved.py +80 -0
- hestia_earth/models/hestia/resourceUse_utils.py +43 -29
- hestia_earth/models/impact_assessment/product/value.py +1 -1
- hestia_earth/models/ipcc2019/aboveGroundBiomass.py +34 -13
- hestia_earth/models/ipcc2019/belowGroundBiomass.py +33 -12
- hestia_earth/models/ipcc2019/ch4ToAirEntericFermentation.py +17 -8
- hestia_earth/models/ipcc2019/co2ToAirCarbonStockChange_utils.py +7 -4
- hestia_earth/models/ipcc2019/organicCarbonPerHa_tier_1_utils.py +2 -1
- hestia_earth/models/ipcc2019/organicCarbonPerHa_tier_2_utils.py +29 -18
- hestia_earth/models/ipcc2019/pastureGrass_utils.py +8 -1
- hestia_earth/models/log.py +1 -1
- hestia_earth/models/mocking/search-results.json +872 -872
- hestia_earth/models/site/defaultMethodClassification.py +9 -2
- hestia_earth/models/site/defaultMethodClassificationDescription.py +4 -2
- hestia_earth/models/site/management.py +48 -30
- hestia_earth/models/site/pre_checks/cache_geospatialDatabase.py +19 -14
- hestia_earth/models/utils/__init__.py +6 -0
- hestia_earth/models/utils/aggregated.py +13 -10
- hestia_earth/models/utils/array_builders.py +4 -3
- hestia_earth/models/utils/blank_node.py +23 -13
- hestia_earth/models/utils/lookup.py +4 -2
- hestia_earth/models/utils/property.py +5 -2
- hestia_earth/models/version.py +1 -1
- hestia_earth/orchestrator/log.py +11 -0
- hestia_earth/orchestrator/models/__init__.py +8 -3
- hestia_earth/orchestrator/strategies/merge/merge_list.py +17 -6
- {hestia_earth_models-0.65.11.dist-info → hestia_earth_models-0.67.0.dist-info}/METADATA +1 -1
- {hestia_earth_models-0.65.11.dist-info → hestia_earth_models-0.67.0.dist-info}/RECORD +86 -69
- tests/models/cml2001Baseline/test_abioticResourceDepletionFossilFuels.py +51 -87
- tests/models/cml2001Baseline/test_resourceUseEnergyDepletionDuringCycle.py +103 -0
- tests/models/cml2001Baseline/test_resourceUseEnergyDepletionInputsProduction.py +23 -0
- tests/models/cml2001Baseline/test_resourceUseMineralsAndMetalsDuringCycle.py +58 -0
- tests/models/cml2001Baseline/test_resourceUseMineralsAndMetalsInputsProduction.py +23 -0
- tests/models/environmentalFootprintV3_1/test_environmentalFootprintSingleOverallScore.py +93 -0
- tests/models/{environmentalFootprintV3 → environmentalFootprintV3_1}/test_freshwaterEcotoxicityPotentialCtue.py +6 -5
- tests/models/environmentalFootprintV3_1/test_marineEutrophicationPotential.py +27 -0
- tests/models/environmentalFootprintV3_1/test_scarcityWeightedWaterUse.py +32 -0
- tests/models/{environmentalFootprintV3 → environmentalFootprintV3_1}/test_soilQualityIndexLandOccupation.py +4 -3
- tests/models/{environmentalFootprintV3 → environmentalFootprintV3_1}/test_soilQualityIndexLandTransformation.py +8 -22
- tests/models/{environmentalFootprintV3 → environmentalFootprintV3_1}/test_soilQualityIndexTotalLandUseEffects.py +4 -4
- tests/models/faostat2018/product/test_price.py +1 -1
- tests/models/geospatialDatabase/{test_aware.py → test_awareWaterBasinId.py} +1 -1
- tests/models/hestia/test_landCover.py +2 -1
- tests/models/hestia/test_landTransformation20YearAverageDuringCycle.py +2 -1
- tests/models/hestia/test_residueRemoved.py +20 -0
- tests/models/impact_assessment/test_emissions.py +0 -1
- tests/models/ipcc2019/test_aboveGroundBiomass.py +3 -1
- tests/models/ipcc2019/test_belowGroundBiomass.py +4 -2
- tests/models/ipcc2019/test_organicCarbonPerHa.py +94 -1
- tests/models/site/pre_checks/test_cache_geospatialDatabase.py +22 -0
- tests/models/site/test_defaultMethodClassification.py +6 -0
- tests/models/site/test_defaultMethodClassificationDescription.py +6 -0
- tests/models/site/test_management.py +4 -4
- tests/models/test_cache_sites.py +2 -2
- tests/models/test_config.py +3 -3
- tests/models/test_ecoinventV3.py +0 -1
- tests/models/utils/test_array_builders.py +2 -2
- tests/orchestrator/strategies/merge/test_merge_list.py +11 -1
- /hestia_earth/models/{environmentalFootprintV3 → environmentalFootprintV3_1}/freshwaterEcotoxicityPotentialCtue.py +0 -0
- /hestia_earth/models/{environmentalFootprintV3 → environmentalFootprintV3_1}/soilQualityIndexLandOccupation.py +0 -0
- /hestia_earth/models/{environmentalFootprintV3 → environmentalFootprintV3_1}/soilQualityIndexTotalLandUseEffects.py +0 -0
- /hestia_earth/models/{environmentalFootprintV3 → environmentalFootprintV3_1}/utils.py +0 -0
- {hestia_earth_models-0.65.11.dist-info → hestia_earth_models-0.67.0.dist-info}/LICENSE +0 -0
- {hestia_earth_models-0.65.11.dist-info → hestia_earth_models-0.67.0.dist-info}/WHEEL +0 -0
- {hestia_earth_models-0.65.11.dist-info → hestia_earth_models-0.67.0.dist-info}/top_level.txt +0 -0
- /tests/models/{environmentalFootprintV3 → environmentalFootprintV3_1}/__init__.py +0 -0
@@ -3,13 +3,14 @@ from unittest.mock import Mock, patch
|
|
3
3
|
|
4
4
|
from pytest import mark
|
5
5
|
|
6
|
-
from hestia_earth.models.
|
6
|
+
from hestia_earth.models.environmentalFootprintV3_1 import MODEL_FOLDER
|
7
|
+
from hestia_earth.models.environmentalFootprintV3_1.soilQualityIndexLandTransformation import (
|
7
8
|
MODEL, TERM_ID, run, _should_run
|
8
9
|
)
|
9
10
|
from tests.utils import fixtures_path, fake_new_indicator
|
10
11
|
|
11
|
-
class_path = f"hestia_earth.models.{
|
12
|
-
fixtures_folder = f"{fixtures_path}/{
|
12
|
+
class_path = f"hestia_earth.models.{MODEL_FOLDER}.{TERM_ID}"
|
13
|
+
fixtures_folder = f"{fixtures_path}/{MODEL_FOLDER}/{TERM_ID}"
|
13
14
|
|
14
15
|
|
15
16
|
def fake_rounded_indicator(value: float):
|
@@ -79,8 +80,8 @@ good_during_cycle_indicator_from_forest_to_forest = {
|
|
79
80
|
@mark.parametrize(
|
80
81
|
"resources, expected, num_inputs",
|
81
82
|
[
|
82
|
-
([],
|
83
|
-
([wrong_indicator],
|
83
|
+
([], False, 0),
|
84
|
+
([wrong_indicator], False, 0),
|
84
85
|
([indicator_no_land_cover], False, 0),
|
85
86
|
([indicator_no_previous_land_cover], False, 0),
|
86
87
|
([indicator_bad_area_value], False, 0),
|
@@ -92,8 +93,8 @@ good_during_cycle_indicator_from_forest_to_forest = {
|
|
92
93
|
([good_inputs_production_indicator_from_forest_to_cropland,
|
93
94
|
good_during_cycle_indicator_from_forest_to_cropland], True, 2)
|
94
95
|
],
|
95
|
-
ids=["No emissionsResourceUse => run, 0 dict",
|
96
|
-
"Wrong indicator termid => run, 0 dict",
|
96
|
+
ids=["No emissionsResourceUse => no run, 0 dict",
|
97
|
+
"Wrong indicator termid => no run, 0 dict",
|
97
98
|
"Indicator no landcover terms => no run",
|
98
99
|
"Indicator no previousLandCover terms => no run",
|
99
100
|
"Bad m2 / year value => no run",
|
@@ -162,18 +163,3 @@ def test_run_with_country_fallback(mocked_indicator: Mock, added_data: dict):
|
|
162
163
|
|
163
164
|
value = run(impact)
|
164
165
|
assert value['value'] == 574.56
|
165
|
-
|
166
|
-
|
167
|
-
@patch(f"{class_path}._new_indicator", side_effect=fake_new_indicator)
|
168
|
-
def test_run_no_transformation(*args):
|
169
|
-
"""
|
170
|
-
Impact assessment with no transformations should return a indicator of 0
|
171
|
-
"""
|
172
|
-
with open(f"{fixtures_folder}/multipleTransformations/impact-assessment.jsonld", encoding='utf-8') as f:
|
173
|
-
impact = json.load(f)
|
174
|
-
|
175
|
-
impact['emissionsResourceUse'] = []
|
176
|
-
|
177
|
-
value = run(impact)
|
178
|
-
|
179
|
-
assert value['value'] == 0
|
@@ -3,12 +3,12 @@ from unittest.mock import patch
|
|
3
3
|
|
4
4
|
from pytest import mark
|
5
5
|
|
6
|
-
from hestia_earth.models.
|
7
|
-
|
6
|
+
from hestia_earth.models.environmentalFootprintV3_1 import MODEL_FOLDER
|
7
|
+
from hestia_earth.models.environmentalFootprintV3_1.soilQualityIndexTotalLandUseEffects import TERM_ID, run, _should_run
|
8
8
|
from tests.utils import fixtures_path, fake_new_indicator
|
9
9
|
|
10
|
-
class_path = f"hestia_earth.models.{
|
11
|
-
fixtures_folder = f"{fixtures_path}/{
|
10
|
+
class_path = f"hestia_earth.models.{MODEL_FOLDER}.{TERM_ID}"
|
11
|
+
fixtures_folder = f"{fixtures_path}/{MODEL_FOLDER}/{TERM_ID}"
|
12
12
|
|
13
13
|
transform_indicator = {'term': {'@id': 'soilQualityIndexLandTransformation'}, 'value': 10}
|
14
14
|
occupation_indicator = {'term': {'@id': 'soilQualityIndexLandOccupation'}, 'value': 10}
|
@@ -11,7 +11,7 @@ fixtures_folder = f"{fixtures_path}/{MODEL}/product/{MODEL_KEY}"
|
|
11
11
|
def test_lookup_data():
|
12
12
|
assert _lookup_data('cocoaSeedDehulled', 'Cocoa beans', 'GADM-GHA', 2000, term_type='crop') == 412.9
|
13
13
|
# average price per tonne as year value is missing
|
14
|
-
assert _lookup_data('cocoaSeedDehulled', 'Cocoa beans', 'GADM-GHA', 2012, term_type='crop') ==
|
14
|
+
assert _lookup_data('cocoaSeedDehulled', 'Cocoa beans', 'GADM-GHA', 2012, term_type='crop') == 844.0571428571428
|
15
15
|
|
16
16
|
|
17
17
|
@patch(f"{class_path}.download_hestia", return_value={})
|
@@ -2,7 +2,7 @@ from unittest.mock import patch
|
|
2
2
|
import json
|
3
3
|
from tests.utils import fixtures_path
|
4
4
|
|
5
|
-
from hestia_earth.models.geospatialDatabase.
|
5
|
+
from hestia_earth.models.geospatialDatabase.awareWaterBasinId import MODEL, MODEL_KEY, run, _should_run
|
6
6
|
|
7
7
|
class_path = f"hestia_earth.models.{MODEL}.{MODEL_KEY}"
|
8
8
|
fixtures_folder = f"{fixtures_path}/{MODEL}/{MODEL_KEY}"
|
@@ -58,7 +58,7 @@ def _download_fixture(filepath: str):
|
|
58
58
|
@patch(f"{FAOSTAT_CLASS_PATH}.download_lookup")
|
59
59
|
def test_get_changes(mock_lookup):
|
60
60
|
mock_lookup.return_value = _download_fixture(f"{faostat_fixtures_folder}/gadm-afg.csv")
|
61
|
-
result = get_changes(
|
61
|
+
result, missing_values = get_changes(
|
62
62
|
country_id="GADM-AFG",
|
63
63
|
end_year=2010
|
64
64
|
)
|
@@ -199,6 +199,7 @@ def test_get_sums_of_crop_expansion():
|
|
199
199
|
"prior_landCover",
|
200
200
|
"nigeria_cassava",
|
201
201
|
"cover_crops",
|
202
|
+
"missing_fao_date"
|
202
203
|
]
|
203
204
|
)
|
204
205
|
@patch(f"{CLASS_PATH}._new_management", side_effect=fake_new_management)
|
@@ -15,7 +15,8 @@ fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
|
|
15
15
|
"subfolder",
|
16
16
|
[
|
17
17
|
"maize_brazil",
|
18
|
-
"orange_iran"
|
18
|
+
"orange_iran",
|
19
|
+
"aggregated"
|
19
20
|
]
|
20
21
|
)
|
21
22
|
@patch("hestia_earth.models.hestia.resourceUse_utils._new_indicator", side_effect=fake_new_indicator)
|
@@ -0,0 +1,20 @@
|
|
1
|
+
from unittest.mock import patch
|
2
|
+
import json
|
3
|
+
|
4
|
+
from tests.utils import fixtures_path, fake_new_practice
|
5
|
+
from hestia_earth.models.hestia.residueRemoved import MODEL, TERM_ID, run
|
6
|
+
|
7
|
+
class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}"
|
8
|
+
fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
|
9
|
+
|
10
|
+
|
11
|
+
@patch(f"{class_path}._new_practice", side_effect=fake_new_practice)
|
12
|
+
def test_run(*args):
|
13
|
+
with open(f"{fixtures_folder}/cycle.jsonld", encoding='utf-8') as f:
|
14
|
+
cycle = json.load(f)
|
15
|
+
|
16
|
+
with open(f"{fixtures_folder}/result.jsonld", encoding='utf-8') as f:
|
17
|
+
expected = json.load(f)
|
18
|
+
|
19
|
+
value = run(cycle)
|
20
|
+
assert value == expected
|
@@ -53,7 +53,9 @@ PARAMS_SHOULD_RUN = [
|
|
53
53
|
("historical-argentina-pasture", True),
|
54
54
|
("historical-brazil-maize", True),
|
55
55
|
("perennial-to-grassland-with-pasture-condition", True),
|
56
|
-
("with-gapfilled-start-date-end-date", False) # Closes #972
|
56
|
+
("with-gapfilled-start-date-end-date", False), # Closes #972
|
57
|
+
("forest-to-cropland-with-missing-equilibrium-year-a", True), # Closes #1076
|
58
|
+
("forest-to-cropland-with-missing-equilibrium-year-b", True) # Closes #1076
|
57
59
|
]
|
58
60
|
IDS_SHOULD_RUN = [p[0] for p in PARAMS_SHOULD_RUN]
|
59
61
|
|
@@ -47,13 +47,15 @@ PARAMS_SHOULD_RUN = [
|
|
47
47
|
("forest-to-cropland-lcc-q4", True),
|
48
48
|
("forest-to-gohac", False),
|
49
49
|
("forest-to-orchard", True),
|
50
|
-
("forest-to-orchard-with-ground-cover", True),
|
50
|
+
("forest-to-orchard-with-ground-cover", True), # Closes 989
|
51
51
|
("forest-to-orchard-with-in-category-lcc", True),
|
52
52
|
("historical-land-cover-mix", True),
|
53
53
|
("historical-argentina-pasture", True),
|
54
54
|
("historical-brazil-maize", True),
|
55
55
|
("perennial-to-grassland-with-pasture-condition", True),
|
56
|
-
("with-gapfilled-start-date-end-date", False)
|
56
|
+
("with-gapfilled-start-date-end-date", False), # Closes #972
|
57
|
+
("forest-to-cropland-with-missing-equilibrium-year-a", True), # Closes #1076
|
58
|
+
("forest-to-cropland-with-missing-equilibrium-year-b", True) # Closes #1076
|
57
59
|
]
|
58
60
|
IDS_SHOULD_RUN = [p[0] for p in PARAMS_SHOULD_RUN]
|
59
61
|
|
@@ -71,6 +71,93 @@ DEFAULT_PROPERTIES = {
|
|
71
71
|
},
|
72
72
|
"ligninContent": {
|
73
73
|
"value": 9.67
|
74
|
+
},
|
75
|
+
"dryMatter": {
|
76
|
+
"value": 100
|
77
|
+
}
|
78
|
+
},
|
79
|
+
"cattleSolidManureDryKgMass": {
|
80
|
+
"carbonContent": {
|
81
|
+
"value": 46.4
|
82
|
+
},
|
83
|
+
"nitrogenContent": {
|
84
|
+
"value": 2.65
|
85
|
+
},
|
86
|
+
"ligninContent": {
|
87
|
+
"value": 11
|
88
|
+
},
|
89
|
+
"dryMatter": {
|
90
|
+
"value": 100
|
91
|
+
}
|
92
|
+
},
|
93
|
+
"cattleSolidManureFreshKgMass": {
|
94
|
+
"carbonContent": {
|
95
|
+
"value": 9.27
|
96
|
+
},
|
97
|
+
"nitrogenContent": {
|
98
|
+
"value": 0.53
|
99
|
+
},
|
100
|
+
"ligninContent": {
|
101
|
+
"value": 2.2
|
102
|
+
},
|
103
|
+
"dryMatter": {
|
104
|
+
"value": 20
|
105
|
+
}
|
106
|
+
},
|
107
|
+
"cattleLiquidManureKgMass": {
|
108
|
+
"carbonContent": {
|
109
|
+
"value": 4.3
|
110
|
+
},
|
111
|
+
"nitrogenContent": {
|
112
|
+
"value": 0.245
|
113
|
+
},
|
114
|
+
"ligninContent": {
|
115
|
+
"value": 1.02
|
116
|
+
},
|
117
|
+
"dryMatter": {
|
118
|
+
"value": 9.18
|
119
|
+
}
|
120
|
+
},
|
121
|
+
"cattleSolidManureDryKgN": {
|
122
|
+
"carbonContent": {
|
123
|
+
"value": 1750
|
124
|
+
},
|
125
|
+
"nitrogenContent": {
|
126
|
+
"value": 100
|
127
|
+
},
|
128
|
+
"ligninContent": {
|
129
|
+
"value": 415
|
130
|
+
},
|
131
|
+
"dryMatter": {
|
132
|
+
"value": 3773.585
|
133
|
+
}
|
134
|
+
},
|
135
|
+
"cattleSolidManureFreshKgN": {
|
136
|
+
"carbonContent": {
|
137
|
+
"value": 1750
|
138
|
+
},
|
139
|
+
"nitrogenContent": {
|
140
|
+
"value": 100
|
141
|
+
},
|
142
|
+
"ligninContent": {
|
143
|
+
"value": 415
|
144
|
+
},
|
145
|
+
"dryMatter": {
|
146
|
+
"value": 3775.611
|
147
|
+
}
|
148
|
+
},
|
149
|
+
"cattleLiquidManureKgN": {
|
150
|
+
"carbonContent": {
|
151
|
+
"value": 1750
|
152
|
+
},
|
153
|
+
"nitrogenContent": {
|
154
|
+
"value": 100
|
155
|
+
},
|
156
|
+
"ligninContent": {
|
157
|
+
"value": 415
|
158
|
+
},
|
159
|
+
"dryMatter": {
|
160
|
+
"value": 3738.968
|
74
161
|
}
|
75
162
|
}
|
76
163
|
}
|
@@ -111,6 +198,7 @@ PARAMS_SHOULD_RUN = [
|
|
111
198
|
("tier-1/with-gapfilled-start-date-end-date", False), # Closes issue 972
|
112
199
|
("tier-1/forest-to-orchard-with-ground-cover", True), # Closes 989
|
113
200
|
("tier-1/forest-to-other-with-ground-cover", True), # Closes 989
|
201
|
+
("tier-1/land-use-change-with-unknown-management", True), # Closes issue 1007
|
114
202
|
("tier-2/with-generalised-monthly-measurements", False), # Closes issue 600
|
115
203
|
("tier-2/with-incomplete-climate-data", False), # Closes issue 599
|
116
204
|
("tier-2/with-initial-soc", True),
|
@@ -123,7 +211,12 @@ PARAMS_SHOULD_RUN = [
|
|
123
211
|
("tier-2/with-paddy-rice", False), # Closes issue 718
|
124
212
|
("tier-2/with-sand-without-date", True), # Closes issue 739
|
125
213
|
("tier-2/with-irrigated-upland-rice", False), # Closes issue 718
|
126
|
-
("tier-
|
214
|
+
("tier-2/with-manure-dry-kg-mass", True), # Closes issue 763
|
215
|
+
("tier-2/with-manure-fresh-kg-mass", True), # Closes issue 763
|
216
|
+
("tier-2/with-manure-liquid-kg-mass", True), # Closes issue 763
|
217
|
+
("tier-2/with-manure-dry-kg-n", True), # Closes issue 763
|
218
|
+
("tier-2/with-manure-fresh-kg-n", True), # Closes issue 763
|
219
|
+
("tier-2/with-manure-liquid-kg-n", True) # Closes issue 763
|
127
220
|
]
|
128
221
|
IDS_SHOULD_RUN = [p[0] for p in PARAMS_SHOULD_RUN]
|
129
222
|
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import pytest
|
2
|
+
|
3
|
+
from hestia_earth.models.site.pre_checks.cache_geospatialDatabase import list_rasters, list_vectors
|
4
|
+
|
5
|
+
|
6
|
+
def test_list_rasters():
|
7
|
+
rasters = list_rasters(years=[2010])
|
8
|
+
assert len(rasters) == 72
|
9
|
+
|
10
|
+
|
11
|
+
@pytest.mark.parametrize(
|
12
|
+
'name,site,expected_len',
|
13
|
+
[
|
14
|
+
('without values', {}, 3),
|
15
|
+
('with region', {'region': 'region'}, 2),
|
16
|
+
('with ecoregion', {'ecoregion': 'ecoregion'}, 2),
|
17
|
+
('with awareWaterBasinId', {'awareWaterBasinId': 'awareWaterBasinId'}, 2),
|
18
|
+
]
|
19
|
+
)
|
20
|
+
def test_list_vectors(name: str, site: dict, expected_len: int):
|
21
|
+
vectors = list_vectors([site])
|
22
|
+
assert len(vectors) == expected_len, name
|
@@ -16,3 +16,9 @@ def test_run():
|
|
16
16
|
|
17
17
|
result = run(site)
|
18
18
|
assert result == expected
|
19
|
+
|
20
|
+
|
21
|
+
def test_run_no_value():
|
22
|
+
site = {'management': [{'@type': 'Management'}]}
|
23
|
+
result = run(site)
|
24
|
+
assert result == 'Data calculated by merging real land use histories and modelled land use histories for each Site.'
|
@@ -29,10 +29,10 @@ _folders = [d for d in os.listdir(fixtures_folder) if os.path.isdir(os.path.join
|
|
29
29
|
@patch(f"{class_path}._new_management", side_effect=fake_new_management)
|
30
30
|
@patch(f"{class_path}.related_cycles")
|
31
31
|
def test_run(
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
mock_related_cycles: Mock,
|
33
|
+
mock_new_management: Mock,
|
34
|
+
mock_land_cover_lookup: Mock,
|
35
|
+
folder: str
|
36
36
|
):
|
37
37
|
fixture_path = os.path.join(fixtures_folder, folder)
|
38
38
|
|
tests/models/test_cache_sites.py
CHANGED
@@ -30,7 +30,7 @@ def test_run(mock_run_query, *args):
|
|
30
30
|
[10] * len(rasters_years)
|
31
31
|
]
|
32
32
|
|
33
|
-
sites = run(sites=data.get('nodes', []), years=[2019, 2020]
|
33
|
+
sites = run(sites=data.get('nodes', []), years=[2019, 2020])
|
34
34
|
|
35
35
|
mock_run_query.assert_has_calls([
|
36
36
|
call({
|
@@ -72,7 +72,7 @@ def test_run_include_region(mock_run_query, *args):
|
|
72
72
|
[10] * len(rasters_years)
|
73
73
|
]
|
74
74
|
|
75
|
-
run(sites=data.get('nodes', []), years=[2019, 2020]
|
75
|
+
run(sites=data.get('nodes', []), years=[2019, 2020])
|
76
76
|
|
77
77
|
mock_run_query.assert_has_calls([
|
78
78
|
call({
|
tests/models/test_config.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
import pytest
|
2
1
|
import importlib
|
2
|
+
|
3
|
+
import pytest
|
3
4
|
from hestia_earth.utils.tools import flatten
|
4
5
|
|
5
6
|
from hestia_earth.models.config import (
|
@@ -7,7 +8,6 @@ from hestia_earth.models.config import (
|
|
7
8
|
get_max_stage
|
8
9
|
)
|
9
10
|
|
10
|
-
|
11
11
|
_aggregated_model = {
|
12
12
|
"value": "input.hestiaAggregatedData"
|
13
13
|
}
|
@@ -89,7 +89,7 @@ _ignore_values = [None, '', 'all']
|
|
89
89
|
|
90
90
|
|
91
91
|
def _model_path(model: dict):
|
92
|
-
name = model.get('model')
|
92
|
+
name = model.get('model').replace('-', '_')
|
93
93
|
value = model.get('value')
|
94
94
|
suffix = f"hestia_earth.models.{name}"
|
95
95
|
return f"{suffix}.{value}" if value not in _ignore_values else suffix
|
tests/models/test_ecoinventV3.py
CHANGED
@@ -242,8 +242,8 @@ def test_avg_run_in_rowwise():
|
|
242
242
|
|
243
243
|
def test_gen_seed():
|
244
244
|
NODE = {"@id": "site"}
|
245
|
-
EXPECTED =
|
246
|
-
result = gen_seed(NODE)
|
245
|
+
EXPECTED = 1209943397
|
246
|
+
result = gen_seed(NODE, "model", "term")
|
247
247
|
assert result == EXPECTED
|
248
248
|
|
249
249
|
|
@@ -1,12 +1,22 @@
|
|
1
1
|
from unittest.mock import patch
|
2
2
|
import pydash
|
3
3
|
|
4
|
-
from hestia_earth.orchestrator.strategies.merge.merge_list import merge
|
4
|
+
from hestia_earth.orchestrator.strategies.merge.merge_list import merge, _get_value
|
5
5
|
|
6
6
|
class_path = 'hestia_earth.orchestrator.strategies.merge.merge_list'
|
7
7
|
version = '1'
|
8
8
|
|
9
9
|
|
10
|
+
def test_get_value():
|
11
|
+
assert _get_value({'startDate': '2020-01-01'}, 'startDate', {}) == '2020-01-01'
|
12
|
+
assert _get_value({'startDate': '2020-01-01'}, 'startDate', {'matchDatesFormat': '%Y'}) == '2020'
|
13
|
+
assert _get_value({'startDate': '2020-01-01'}, 'startDate', {'matchDatesFormat': '%Y-%m'}) == '2020-01'
|
14
|
+
assert _get_value({'startDate': '2020-01-01'}, 'startDate', {'matchDatesFormat': '%Y-%m-%d'}) == '2020-01-01'
|
15
|
+
assert _get_value({'value': 500}, 'value') == 500
|
16
|
+
assert _get_value({'value': 500}, 'value', {'matchDatesFormat': '%Y-%m-%d'}) == 500
|
17
|
+
assert _get_value({'value': 'test'}, 'value') == 'test'
|
18
|
+
|
19
|
+
|
10
20
|
def _default_merge(a, b, *args): return pydash.objects.merge({}, a, b)
|
11
21
|
|
12
22
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{hestia_earth_models-0.65.11.dist-info → hestia_earth_models-0.67.0.dist-info}/top_level.txt
RENAMED
File without changes
|
File without changes
|