hestia-earth-models 0.64.8__py3-none-any.whl → 0.64.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.
Potentially problematic release.
This version of hestia-earth-models might be problematic. Click here for more details.
- hestia_earth/models/cml2001Baseline/abioticResourceDepletionFossilFuels.py +175 -0
- hestia_earth/models/cml2001Baseline/abioticResourceDepletionMineralsAndMetals.py +136 -0
- hestia_earth/models/cycle/siteArea.py +2 -1
- hestia_earth/models/environmentalFootprintV3/soilQualityIndexLandOccupation.py +73 -82
- hestia_earth/models/environmentalFootprintV3/soilQualityIndexLandTransformation.py +102 -116
- hestia_earth/models/environmentalFootprintV3/soilQualityIndexTotalLandUseEffects.py +27 -16
- hestia_earth/models/faostat2018/landTransformationFromCropland100YearAverage.py +3 -2
- hestia_earth/models/faostat2018/landTransformationFromCropland20YearAverage.py +3 -2
- hestia_earth/models/frischknechtEtAl2000/ionisingRadiationKbqU235Eq.py +69 -37
- hestia_earth/models/ipcc2019/aboveGroundBiomass.py +31 -243
- hestia_earth/models/ipcc2019/animal/fatContent.py +38 -0
- hestia_earth/models/ipcc2019/animal/liveweightGain.py +3 -54
- hestia_earth/models/ipcc2019/animal/liveweightPerHead.py +3 -54
- hestia_earth/models/ipcc2019/animal/pregnancyRateTotal.py +38 -0
- hestia_earth/models/ipcc2019/animal/trueProteinContent.py +38 -0
- hestia_earth/models/ipcc2019/animal/utils.py +87 -3
- hestia_earth/models/ipcc2019/animal/weightAtMaturity.py +4 -10
- hestia_earth/models/ipcc2019/belowGroundBiomass.py +529 -0
- hestia_earth/models/ipcc2019/biomass_utils.py +406 -0
- hestia_earth/models/ipcc2019/{co2ToAirAboveGroundBiomassStockChangeLandUseChange.py → co2ToAirAboveGroundBiomassStockChange.py} +19 -7
- hestia_earth/models/ipcc2019/{co2ToAirBelowGroundBiomassStockChangeLandUseChange.py → co2ToAirBelowGroundBiomassStockChange.py} +19 -7
- hestia_earth/models/ipcc2019/co2ToAirCarbonStockChange_utils.py +402 -73
- hestia_earth/models/ipcc2019/{co2ToAirSoilOrganicCarbonStockChangeManagementChange.py → co2ToAirSoilOrganicCarbonStockChange.py} +20 -8
- hestia_earth/models/ipcc2019/organicCarbonPerHa.py +3 -1
- hestia_earth/models/ipcc2019/pastureGrass_utils.py +6 -7
- hestia_earth/models/lcImpactAllEffects100Years/damageToFreshwaterEcosystemsFreshwaterEutrophication.py +2 -2
- hestia_earth/models/lcImpactAllEffects100Years/damageToFreshwaterEcosystemsWaterStress.py +2 -2
- hestia_earth/models/lcImpactAllEffects100Years/damageToHumanHealthParticulateMatterFormation.py +2 -2
- hestia_earth/models/lcImpactAllEffects100Years/damageToHumanHealthPhotochemicalOzoneFormation.py +2 -2
- hestia_earth/models/lcImpactAllEffects100Years/damageToHumanHealthWaterStress.py +2 -2
- hestia_earth/models/lcImpactAllEffects100Years/damageToMarineEcosystemsMarineEutrophication.py +2 -2
- hestia_earth/models/lcImpactAllEffects100Years/damageToTerrestrialEcosystemsPhotochemicalOzoneFormation.py +2 -2
- hestia_earth/models/lcImpactAllEffects100Years/damageToTerrestrialEcosystemsTerrestrialAcidification.py +2 -2
- hestia_earth/models/lcImpactAllEffectsInfinite/damageToFreshwaterEcosystemsFreshwaterEutrophication.py +2 -2
- hestia_earth/models/lcImpactAllEffectsInfinite/damageToFreshwaterEcosystemsWaterStress.py +2 -2
- hestia_earth/models/lcImpactAllEffectsInfinite/damageToHumanHealthParticulateMatterFormation.py +2 -2
- hestia_earth/models/lcImpactAllEffectsInfinite/damageToHumanHealthPhotochemicalOzoneFormation.py +2 -2
- hestia_earth/models/lcImpactAllEffectsInfinite/damageToHumanHealthWaterStress.py +2 -2
- hestia_earth/models/lcImpactAllEffectsInfinite/damageToMarineEcosystemsMarineEutrophication.py +2 -2
- hestia_earth/models/lcImpactAllEffectsInfinite/damageToTerrestrialEcosystemsPhotochemicalOzoneFormation.py +2 -2
- hestia_earth/models/lcImpactAllEffectsInfinite/damageToTerrestrialEcosystemsTerrestrialAcidification.py +2 -2
- hestia_earth/models/lcImpactCertainEffects100Years/damageToFreshwaterEcosystemsFreshwaterEutrophication.py +2 -2
- hestia_earth/models/lcImpactCertainEffects100Years/damageToFreshwaterEcosystemsWaterStress.py +2 -2
- hestia_earth/models/lcImpactCertainEffects100Years/damageToHumanHealthParticulateMatterFormation.py +2 -2
- hestia_earth/models/lcImpactCertainEffects100Years/damageToHumanHealthPhotochemicalOzoneFormation.py +2 -2
- hestia_earth/models/lcImpactCertainEffects100Years/damageToHumanHealthWaterStress.py +2 -2
- hestia_earth/models/lcImpactCertainEffects100Years/damageToMarineEcosystemsMarineEutrophication.py +2 -2
- hestia_earth/models/lcImpactCertainEffects100Years/damageToTerrestrialEcosystemsPhotochemicalOzoneFormation.py +2 -2
- hestia_earth/models/lcImpactCertainEffects100Years/damageToTerrestrialEcosystemsTerrestrialAcidification.py +2 -2
- hestia_earth/models/lcImpactCertainEffectsInfinite/damageToFreshwaterEcosystemsFreshwaterEutrophication.py +2 -2
- hestia_earth/models/lcImpactCertainEffectsInfinite/damageToFreshwaterEcosystemsWaterStress.py +2 -2
- hestia_earth/models/lcImpactCertainEffectsInfinite/damageToHumanHealthParticulateMatterFormation.py +2 -2
- hestia_earth/models/lcImpactCertainEffectsInfinite/damageToHumanHealthPhotochemicalOzoneFormation.py +2 -2
- hestia_earth/models/lcImpactCertainEffectsInfinite/damageToHumanHealthWaterStress.py +2 -2
- hestia_earth/models/lcImpactCertainEffectsInfinite/damageToMarineEcosystemsMarineEutrophication.py +2 -2
- hestia_earth/models/lcImpactCertainEffectsInfinite/damageToTerrestrialEcosystemsPhotochemicalOzoneFormation.py +2 -2
- hestia_earth/models/lcImpactCertainEffectsInfinite/damageToTerrestrialEcosystemsTerrestrialAcidification.py +2 -2
- hestia_earth/models/mocking/build_mock_search.py +44 -0
- hestia_earth/models/mocking/mock_search.py +8 -49
- hestia_earth/models/mocking/search-results.json +3078 -575
- hestia_earth/models/poschEtAl2008/terrestrialAcidificationPotentialAccumulatedExceedance.py +6 -3
- hestia_earth/models/poschEtAl2008/terrestrialEutrophicationPotentialAccumulatedExceedance.py +6 -3
- hestia_earth/models/preload_requests.py +1 -1
- hestia_earth/models/schmidt2007/utils.py +13 -4
- hestia_earth/models/utils/__init__.py +5 -4
- hestia_earth/models/utils/blank_node.py +73 -3
- hestia_earth/models/utils/constant.py +8 -1
- hestia_earth/models/utils/cycle.py +10 -13
- hestia_earth/models/utils/fuel.py +1 -1
- hestia_earth/models/utils/impact_assessment.py +39 -15
- hestia_earth/models/utils/lookup.py +36 -7
- hestia_earth/models/utils/pesticideAI.py +1 -1
- hestia_earth/models/utils/property.py +11 -4
- hestia_earth/models/utils/term.py +15 -8
- hestia_earth/models/version.py +1 -1
- {hestia_earth_models-0.64.8.dist-info → hestia_earth_models-0.64.10.dist-info}/METADATA +2 -2
- {hestia_earth_models-0.64.8.dist-info → hestia_earth_models-0.64.10.dist-info}/RECORD +103 -90
- {hestia_earth_models-0.64.8.dist-info → hestia_earth_models-0.64.10.dist-info}/WHEEL +1 -1
- tests/models/cml2001Baseline/test_abioticResourceDepletionFossilFuels.py +196 -0
- tests/models/cml2001Baseline/test_abioticResourceDepletionMineralsAndMetals.py +124 -0
- tests/models/edip2003/test_ozoneDepletionPotential.py +1 -13
- tests/models/environmentalFootprintV3/test_soilQualityIndexLandOccupation.py +97 -66
- tests/models/environmentalFootprintV3/test_soilQualityIndexLandTransformation.py +136 -74
- tests/models/environmentalFootprintV3/test_soilQualityIndexTotalLandUseEffects.py +15 -10
- tests/models/frischknechtEtAl2000/test_ionisingRadiationKbqU235Eq.py +67 -44
- tests/models/impact_assessment/test_emissions.py +1 -0
- tests/models/ipcc2019/animal/test_fatContent.py +22 -0
- tests/models/ipcc2019/animal/test_liveweightGain.py +4 -2
- tests/models/ipcc2019/animal/test_liveweightPerHead.py +4 -2
- tests/models/ipcc2019/animal/test_pregnancyRateTotal.py +22 -0
- tests/models/ipcc2019/animal/test_trueProteinContent.py +22 -0
- tests/models/ipcc2019/animal/test_weightAtMaturity.py +2 -1
- tests/models/ipcc2019/test_aboveGroundBiomass.py +27 -63
- tests/models/ipcc2019/test_belowGroundBiomass.py +146 -0
- tests/models/ipcc2019/test_biomass_utils.py +115 -0
- tests/models/ipcc2019/{test_co2ToAirAboveGroundBiomassStockChangeLandUseChange.py → test_co2ToAirAboveGroundBiomassStockChange.py} +5 -5
- tests/models/ipcc2019/{test_co2ToAirBelowGroundBiomassStockChangeLandUseChange.py → test_co2ToAirBelowGroundBiomassStockChange.py} +5 -5
- tests/models/ipcc2019/{test_co2ToAirSoilOrganicCarbonStockChangeManagementChange.py → test_co2ToAirSoilOrganicCarbonStockChange.py} +5 -5
- tests/models/ipcc2021/test_gwp100.py +2 -2
- tests/models/poschEtAl2008/test_terrestrialAcidificationPotentialAccumulatedExceedance.py +30 -17
- tests/models/poschEtAl2008/test_terrestrialEutrophicationPotentialAccumulatedExceedance.py +28 -14
- hestia_earth/models/ipcc2019/aboveGroundBiomass_utils.py +0 -180
- tests/models/ipcc2019/test_aboveGroundBiomass_utils.py +0 -92
- {hestia_earth_models-0.64.8.dist-info → hestia_earth_models-0.64.10.dist-info}/LICENSE +0 -0
- {hestia_earth_models-0.64.8.dist-info → hestia_earth_models-0.64.10.dist-info}/top_level.txt +0 -0
|
@@ -4,15 +4,13 @@ from os.path import isfile
|
|
|
4
4
|
from pytest import mark
|
|
5
5
|
from unittest.mock import MagicMock, patch
|
|
6
6
|
|
|
7
|
-
from hestia_earth.models.ipcc2019.aboveGroundBiomass import
|
|
8
|
-
|
|
9
|
-
)
|
|
10
|
-
from hestia_earth.models.ipcc2019.aboveGroundBiomass_utils import BiomassCategory, sample_constant
|
|
7
|
+
from hestia_earth.models.ipcc2019.aboveGroundBiomass import _build_col_name, _should_run, MODEL, run, TERM_ID
|
|
8
|
+
from hestia_earth.models.ipcc2019.biomass_utils import BiomassCategory, sample_constant
|
|
11
9
|
|
|
12
10
|
from tests.utils import fake_new_measurement, fixtures_path
|
|
13
11
|
|
|
14
12
|
class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}"
|
|
15
|
-
utils_path = f"hestia_earth.models.{MODEL}.
|
|
13
|
+
utils_path = f"hestia_earth.models.{MODEL}.biomass_utils"
|
|
16
14
|
term_path = "hestia_earth.models.utils.term"
|
|
17
15
|
property_path = "hestia_earth.models.utils.property"
|
|
18
16
|
|
|
@@ -40,6 +38,7 @@ PARAMS_SHOULD_RUN = [
|
|
|
40
38
|
("forest-to-cropland-lcc-q2", True),
|
|
41
39
|
("forest-to-cropland-lcc-q3", True),
|
|
42
40
|
("forest-to-cropland-lcc-q4", True),
|
|
41
|
+
("forest-to-gohac", False),
|
|
43
42
|
("forest-to-orchard", True),
|
|
44
43
|
("forest-to-orchard-with-backup-factors", True),
|
|
45
44
|
("forest-to-orchard-with-in-category-lcc", True),
|
|
@@ -119,64 +118,29 @@ def test_run_with_stats(
|
|
|
119
118
|
|
|
120
119
|
|
|
121
120
|
# input, expected
|
|
122
|
-
|
|
123
|
-
(
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
),
|
|
127
|
-
(
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
),
|
|
131
|
-
(
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
),
|
|
135
|
-
(
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
)
|
|
121
|
+
PARAMS_BUILD_COLUMN_NAME = [
|
|
122
|
+
(BiomassCategory.ANNUAL_CROPS, "AG_BIOMASS_EQUILIBRIUM_KG_C_HECTARE_ANNUAL_CROPS"),
|
|
123
|
+
(BiomassCategory.COCONUT, "AG_BIOMASS_EQUILIBRIUM_KG_C_HECTARE_COCONUT"),
|
|
124
|
+
(BiomassCategory.FOREST, "AG_BIOMASS_EQUILIBRIUM_KG_C_HECTARE_FOREST"),
|
|
125
|
+
(BiomassCategory.GRASSLAND, "AG_BIOMASS_EQUILIBRIUM_KG_C_HECTARE_GRASSLAND"),
|
|
126
|
+
(BiomassCategory.JATROPHA, "AG_BIOMASS_EQUILIBRIUM_KG_C_HECTARE_JATROPHA"),
|
|
127
|
+
(BiomassCategory.JOJOBA, "AG_BIOMASS_EQUILIBRIUM_KG_C_HECTARE_JOJOBA"),
|
|
128
|
+
(BiomassCategory.NATURAL_FOREST, "AG_BIOMASS_EQUILIBRIUM_KG_C_HECTARE_NATURAL_FOREST"),
|
|
129
|
+
(BiomassCategory.OIL_PALM, "AG_BIOMASS_EQUILIBRIUM_KG_C_HECTARE_OIL_PALM"),
|
|
130
|
+
(BiomassCategory.OLIVE, "AG_BIOMASS_EQUILIBRIUM_KG_C_HECTARE_OLIVE"),
|
|
131
|
+
(BiomassCategory.ORCHARD, "AG_BIOMASS_EQUILIBRIUM_KG_C_HECTARE_ORCHARD"),
|
|
132
|
+
(BiomassCategory.OTHER, "AG_BIOMASS_EQUILIBRIUM_KG_C_HECTARE_OTHER"),
|
|
133
|
+
(BiomassCategory.PLANTATION_FOREST, "AG_BIOMASS_EQUILIBRIUM_KG_C_HECTARE_PLANTATION_FOREST"),
|
|
134
|
+
(BiomassCategory.RUBBER, "AG_BIOMASS_EQUILIBRIUM_KG_C_HECTARE_RUBBER"),
|
|
135
|
+
(BiomassCategory.SHORT_ROTATION_COPPICE, "AG_BIOMASS_EQUILIBRIUM_KG_C_HECTARE_SHORT_ROTATION_COPPICE"),
|
|
136
|
+
(BiomassCategory.TEA, "AG_BIOMASS_EQUILIBRIUM_KG_C_HECTARE_TEA"),
|
|
137
|
+
(BiomassCategory.VINE, "AG_BIOMASS_EQUILIBRIUM_KG_C_HECTARE_VINE"),
|
|
138
|
+
(BiomassCategory.WOODY_PERENNIAL, "AG_BIOMASS_EQUILIBRIUM_KG_C_HECTARE_WOODY_PERENNIAL"),
|
|
139
|
+
("Miscellaneous value", "AG_BIOMASS_EQUILIBRIUM_KG_C_HECTARE_OTHER")
|
|
139
140
|
]
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
@mark.parametrize("input, expected", PARAMS_RESCALE_CATEGORY_COVER, ids=IDS_RESCALE_CATEGORY_COVER)
|
|
144
|
-
def test_rescale_category_cover(input: dict, expected: dict):
|
|
145
|
-
assert _rescale_category_cover(input) == expected
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
# a, b, expected
|
|
149
|
-
PARAMS_IS_LCC_EVENT = [
|
|
150
|
-
(
|
|
151
|
-
{
|
|
152
|
-
"appleTree": 33.333,
|
|
153
|
-
"pearTree": 33.333,
|
|
154
|
-
BiomassCategory.ANNUAL_CROPS: 33.334,
|
|
155
|
-
},
|
|
156
|
-
{
|
|
157
|
-
"appleTree": 33.33333,
|
|
158
|
-
"pearTree": 33.33333,
|
|
159
|
-
BiomassCategory.ANNUAL_CROPS: 33.33334,
|
|
160
|
-
},
|
|
161
|
-
True
|
|
162
|
-
),
|
|
163
|
-
(
|
|
164
|
-
{
|
|
165
|
-
"appleTree": 33.3333,
|
|
166
|
-
"pearTree": 33.3333,
|
|
167
|
-
BiomassCategory.ANNUAL_CROPS: 33.3334,
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
"appleTree": 33.33333,
|
|
171
|
-
"pearTree": 33.33333,
|
|
172
|
-
BiomassCategory.ANNUAL_CROPS: 33.33334,
|
|
173
|
-
},
|
|
174
|
-
False
|
|
175
|
-
)
|
|
176
|
-
]
|
|
177
|
-
IDS_IS_LCC_EVENT = ["True", "False"]
|
|
141
|
+
IDS_BUILD_COLUMN_NAME = [p[0] for p in PARAMS_BUILD_COLUMN_NAME]
|
|
178
142
|
|
|
179
143
|
|
|
180
|
-
@mark.parametrize("
|
|
181
|
-
def
|
|
182
|
-
assert
|
|
144
|
+
@mark.parametrize("input, expected", PARAMS_BUILD_COLUMN_NAME, ids=IDS_BUILD_COLUMN_NAME)
|
|
145
|
+
def test_build_col_name(input: BiomassCategory, expected: str):
|
|
146
|
+
assert _build_col_name(input) == expected
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from numpy.typing import NDArray
|
|
3
|
+
from os.path import isfile
|
|
4
|
+
from pytest import mark
|
|
5
|
+
from unittest.mock import MagicMock, patch
|
|
6
|
+
|
|
7
|
+
from hestia_earth.models.ipcc2019.belowGroundBiomass import _build_col_name, _should_run, MODEL, run, TERM_ID
|
|
8
|
+
from hestia_earth.models.ipcc2019.biomass_utils import BiomassCategory, sample_constant
|
|
9
|
+
|
|
10
|
+
from tests.utils import fake_new_measurement, fixtures_path
|
|
11
|
+
|
|
12
|
+
class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}"
|
|
13
|
+
utils_path = f"hestia_earth.models.{MODEL}.biomass_utils"
|
|
14
|
+
term_path = "hestia_earth.models.utils.term"
|
|
15
|
+
property_path = "hestia_earth.models.utils.property"
|
|
16
|
+
|
|
17
|
+
fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
|
|
18
|
+
|
|
19
|
+
_ITERATIONS = 1000
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _load_fixture(path: str, default=None):
|
|
23
|
+
if isfile(path):
|
|
24
|
+
with open(path, encoding="utf-8") as f:
|
|
25
|
+
return json.load(f)
|
|
26
|
+
return default
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def _fake_calc_descriptive_stats(arr: NDArray, *_args, **_kwargs):
|
|
30
|
+
return {"value": [round(row[0], 6) for row in arr]}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
# subfolder, should_run
|
|
34
|
+
PARAMS_SHOULD_RUN = [
|
|
35
|
+
("forest-to-animal-housing", False),
|
|
36
|
+
("forest-to-cropland", True),
|
|
37
|
+
("forest-to-cropland-greater-than-100", True),
|
|
38
|
+
("forest-to-cropland-less-than-100", True),
|
|
39
|
+
("forest-to-cropland-lcc-q2", True),
|
|
40
|
+
("forest-to-cropland-lcc-q3", True),
|
|
41
|
+
("forest-to-cropland-lcc-q4", True),
|
|
42
|
+
("forest-to-gohac", False),
|
|
43
|
+
("forest-to-orchard", True),
|
|
44
|
+
("forest-to-orchard-with-in-category-lcc", True),
|
|
45
|
+
("historical-land-cover-mix", True),
|
|
46
|
+
("historical-argentina-pasture", True),
|
|
47
|
+
("historical-brazil-maize", True),
|
|
48
|
+
("perennial-to-grassland-with-pasture-condition", True)
|
|
49
|
+
]
|
|
50
|
+
IDS_SHOULD_RUN = [p[0] for p in PARAMS_SHOULD_RUN]
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
@mark.parametrize("subfolder, should_run", PARAMS_SHOULD_RUN, ids=IDS_SHOULD_RUN)
|
|
54
|
+
def test_should_run(subfolder: str, should_run: bool):
|
|
55
|
+
folder = f"{fixtures_folder}/{subfolder}"
|
|
56
|
+
|
|
57
|
+
site = _load_fixture(f"{folder}/site.jsonld", {})
|
|
58
|
+
|
|
59
|
+
result, *_ = _should_run(site)
|
|
60
|
+
assert result == should_run
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def test_should_run_no_data():
|
|
64
|
+
SITE = {}
|
|
65
|
+
EXPECTED = False
|
|
66
|
+
|
|
67
|
+
result, *_ = _should_run(SITE)
|
|
68
|
+
assert result == EXPECTED
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
PARAMS_RUN = [subfolder for subfolder, should_run in PARAMS_SHOULD_RUN if should_run]
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
@mark.parametrize("subfolder", PARAMS_RUN)
|
|
75
|
+
@patch(f"{class_path}.calc_descriptive_stats", side_effect=_fake_calc_descriptive_stats)
|
|
76
|
+
@patch(f"{class_path}._new_measurement", side_effect=fake_new_measurement)
|
|
77
|
+
@patch(f"{utils_path}._get_sample_func", return_value=sample_constant)
|
|
78
|
+
def test_run(
|
|
79
|
+
_get_sample_func_mock: MagicMock,
|
|
80
|
+
_new_measurement_mock: MagicMock,
|
|
81
|
+
_calc_descriptive_stats_mock: MagicMock,
|
|
82
|
+
subfolder: str
|
|
83
|
+
):
|
|
84
|
+
folder = f"{fixtures_folder}/{subfolder}"
|
|
85
|
+
|
|
86
|
+
site = _load_fixture(f"{folder}/site.jsonld", {})
|
|
87
|
+
expected = _load_fixture(f"{folder}/result.jsonld", [])
|
|
88
|
+
|
|
89
|
+
with patch(f"{class_path}._ITERATIONS", _ITERATIONS):
|
|
90
|
+
result = run(site)
|
|
91
|
+
|
|
92
|
+
assert result == expected
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
# subfolder
|
|
96
|
+
PARAMS_RUN_WITH_STATS = [
|
|
97
|
+
"forest-to-cropland-with-stats",
|
|
98
|
+
"forest-to-orchard-with-in-category-lcc-with-stats",
|
|
99
|
+
"historical-land-cover-mix-with-stats"
|
|
100
|
+
]
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
@mark.parametrize("subfolder", PARAMS_RUN_WITH_STATS)
|
|
104
|
+
@patch(f"{class_path}._new_measurement", side_effect=fake_new_measurement)
|
|
105
|
+
def test_run_with_stats(
|
|
106
|
+
_new_measurement_mock: MagicMock,
|
|
107
|
+
subfolder: str
|
|
108
|
+
):
|
|
109
|
+
folder = f"{fixtures_folder}/{subfolder}"
|
|
110
|
+
|
|
111
|
+
site = _load_fixture(f"{folder}/site.jsonld", {})
|
|
112
|
+
expected = _load_fixture(f"{folder}/result.jsonld", [])
|
|
113
|
+
|
|
114
|
+
with patch(f"{class_path}._ITERATIONS", _ITERATIONS):
|
|
115
|
+
result = run(site)
|
|
116
|
+
|
|
117
|
+
assert result == expected
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
# input, expected
|
|
121
|
+
PARAMS_BUILD_COLUMN_NAME = [
|
|
122
|
+
(BiomassCategory.ANNUAL_CROPS, "BG_BIOMASS_EQUILIBRIUM_KG_C_HECTARE_OTHER"),
|
|
123
|
+
(BiomassCategory.COCONUT, "BG_BIOMASS_EQUILIBRIUM_KG_C_HECTARE_OTHER"),
|
|
124
|
+
(BiomassCategory.FOREST, "BG_BIOMASS_EQUILIBRIUM_KG_C_HECTARE_FOREST"),
|
|
125
|
+
(BiomassCategory.GRASSLAND, "BG_BIOMASS_EQUILIBRIUM_KG_C_HECTARE_OTHER"),
|
|
126
|
+
(BiomassCategory.JATROPHA, "BG_BIOMASS_EQUILIBRIUM_KG_C_HECTARE_OTHER"),
|
|
127
|
+
(BiomassCategory.JOJOBA, "BG_BIOMASS_EQUILIBRIUM_KG_C_HECTARE_OTHER"),
|
|
128
|
+
(BiomassCategory.NATURAL_FOREST, "BG_BIOMASS_EQUILIBRIUM_KG_C_HECTARE_NATURAL_FOREST"),
|
|
129
|
+
(BiomassCategory.OIL_PALM, "BG_BIOMASS_EQUILIBRIUM_KG_C_HECTARE_OTHER"),
|
|
130
|
+
(BiomassCategory.OLIVE, "BG_BIOMASS_EQUILIBRIUM_KG_C_HECTARE_OTHER"),
|
|
131
|
+
(BiomassCategory.ORCHARD, "BG_BIOMASS_EQUILIBRIUM_KG_C_HECTARE_OTHER"),
|
|
132
|
+
(BiomassCategory.OTHER, "BG_BIOMASS_EQUILIBRIUM_KG_C_HECTARE_OTHER"),
|
|
133
|
+
(BiomassCategory.PLANTATION_FOREST, "BG_BIOMASS_EQUILIBRIUM_KG_C_HECTARE_PLANTATION_FOREST"),
|
|
134
|
+
(BiomassCategory.RUBBER, "BG_BIOMASS_EQUILIBRIUM_KG_C_HECTARE_OTHER"),
|
|
135
|
+
(BiomassCategory.SHORT_ROTATION_COPPICE, "BG_BIOMASS_EQUILIBRIUM_KG_C_HECTARE_OTHER"),
|
|
136
|
+
(BiomassCategory.TEA, "BG_BIOMASS_EQUILIBRIUM_KG_C_HECTARE_OTHER"),
|
|
137
|
+
(BiomassCategory.VINE, "BG_BIOMASS_EQUILIBRIUM_KG_C_HECTARE_OTHER"),
|
|
138
|
+
(BiomassCategory.WOODY_PERENNIAL, "BG_BIOMASS_EQUILIBRIUM_KG_C_HECTARE_OTHER"),
|
|
139
|
+
("Miscellaneous value", "BG_BIOMASS_EQUILIBRIUM_KG_C_HECTARE_OTHER")
|
|
140
|
+
]
|
|
141
|
+
IDS_BUILD_COLUMN_NAME = [p[0] for p in PARAMS_BUILD_COLUMN_NAME]
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
@mark.parametrize("input, expected", PARAMS_BUILD_COLUMN_NAME, ids=IDS_BUILD_COLUMN_NAME)
|
|
145
|
+
def test_build_col_name(input: BiomassCategory, expected: str):
|
|
146
|
+
assert _build_col_name(input) == expected
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
from pytest import mark
|
|
2
|
+
|
|
3
|
+
from hestia_earth.models.ipcc2019.biomass_utils import (
|
|
4
|
+
_assign_biomass_category, _get_sample_func, _rescale_category_cover, BiomassCategory, detect_land_cover_change,
|
|
5
|
+
sample_constant, sample_plus_minus_error
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
_ITERATIONS = 1000
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
# input, expected
|
|
12
|
+
PARAMS_RESCALE_CATEGORY_COVER = [
|
|
13
|
+
(
|
|
14
|
+
{BiomassCategory.ANNUAL_CROPS: 90},
|
|
15
|
+
{BiomassCategory.ANNUAL_CROPS: 90, BiomassCategory.OTHER: 10}
|
|
16
|
+
),
|
|
17
|
+
(
|
|
18
|
+
{BiomassCategory.OTHER: 90},
|
|
19
|
+
{BiomassCategory.OTHER: 100}
|
|
20
|
+
),
|
|
21
|
+
(
|
|
22
|
+
{BiomassCategory.ANNUAL_CROPS: 60, BiomassCategory.VINE: 60},
|
|
23
|
+
{BiomassCategory.ANNUAL_CROPS: 50, BiomassCategory.VINE: 50}
|
|
24
|
+
),
|
|
25
|
+
(
|
|
26
|
+
{BiomassCategory.NATURAL_FOREST: 100},
|
|
27
|
+
{BiomassCategory.NATURAL_FOREST: 100}
|
|
28
|
+
)
|
|
29
|
+
]
|
|
30
|
+
IDS_RESCALE_CATEGORY_COVER = ["fill", "fill w/ other", "squash", "do nothing"]
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@mark.parametrize("input, expected", PARAMS_RESCALE_CATEGORY_COVER, ids=IDS_RESCALE_CATEGORY_COVER)
|
|
34
|
+
def test_rescale_category_cover(input: dict, expected: dict):
|
|
35
|
+
assert _rescale_category_cover(input) == expected
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
# a, b, expected
|
|
39
|
+
PARAMS_IS_LCC_EVENT = [
|
|
40
|
+
(
|
|
41
|
+
{
|
|
42
|
+
"appleTree": 33.333,
|
|
43
|
+
"pearTree": 33.333,
|
|
44
|
+
BiomassCategory.ANNUAL_CROPS: 33.334,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"appleTree": 33.33333,
|
|
48
|
+
"pearTree": 33.33333,
|
|
49
|
+
BiomassCategory.ANNUAL_CROPS: 33.33334,
|
|
50
|
+
},
|
|
51
|
+
True
|
|
52
|
+
),
|
|
53
|
+
(
|
|
54
|
+
{
|
|
55
|
+
"appleTree": 33.3333,
|
|
56
|
+
"pearTree": 33.3333,
|
|
57
|
+
BiomassCategory.ANNUAL_CROPS: 33.3334,
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"appleTree": 33.33333,
|
|
61
|
+
"pearTree": 33.33333,
|
|
62
|
+
BiomassCategory.ANNUAL_CROPS: 33.33334,
|
|
63
|
+
},
|
|
64
|
+
False
|
|
65
|
+
)
|
|
66
|
+
]
|
|
67
|
+
IDS_IS_LCC_EVENT = ["True", "False"]
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
@mark.parametrize("a, b, expected", PARAMS_IS_LCC_EVENT, ids=IDS_IS_LCC_EVENT)
|
|
71
|
+
def test_detect_land_cover_change(a: dict, b: dict, expected: bool):
|
|
72
|
+
assert detect_land_cover_change(a, b) is expected
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
# kwargs, sample_func, expected_shape
|
|
76
|
+
PARAMS_GET_SAMPLE_FUNC = [
|
|
77
|
+
({"value": 1}, sample_constant),
|
|
78
|
+
({"value": 1, "error": 10}, sample_plus_minus_error),
|
|
79
|
+
]
|
|
80
|
+
IDS_GET_SAMPLE_FUNC = ["constant", "+/- error"]
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
@mark.parametrize("kwargs, sample_func", PARAMS_GET_SAMPLE_FUNC, ids=IDS_GET_SAMPLE_FUNC)
|
|
84
|
+
def test_get_sample_func(kwargs, sample_func):
|
|
85
|
+
result = _get_sample_func(kwargs)
|
|
86
|
+
assert result == sample_func
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
# input, expected
|
|
90
|
+
PARAMS_ASSIGN_BIOMASS_CATEGORY = [
|
|
91
|
+
("Annual crops", BiomassCategory.ANNUAL_CROPS),
|
|
92
|
+
("Coconut", BiomassCategory.COCONUT),
|
|
93
|
+
("Forest", BiomassCategory.FOREST),
|
|
94
|
+
("Grassland", BiomassCategory.GRASSLAND),
|
|
95
|
+
("Jatropha", BiomassCategory.JATROPHA),
|
|
96
|
+
("Jojoba", BiomassCategory.JOJOBA),
|
|
97
|
+
("Natural forest", BiomassCategory.NATURAL_FOREST),
|
|
98
|
+
("Oil palm", BiomassCategory.OIL_PALM),
|
|
99
|
+
("Olive", BiomassCategory.OLIVE),
|
|
100
|
+
("Orchard", BiomassCategory.ORCHARD),
|
|
101
|
+
("Other", BiomassCategory.OTHER),
|
|
102
|
+
("Plantation forest", BiomassCategory.PLANTATION_FOREST),
|
|
103
|
+
("Rubber", BiomassCategory.RUBBER),
|
|
104
|
+
("Short rotation coppice", BiomassCategory.SHORT_ROTATION_COPPICE),
|
|
105
|
+
("Tea", BiomassCategory.TEA),
|
|
106
|
+
("Vine", BiomassCategory.VINE),
|
|
107
|
+
("Woody perennial", BiomassCategory.WOODY_PERENNIAL),
|
|
108
|
+
("Miscellaneous value", None)
|
|
109
|
+
]
|
|
110
|
+
IDS_ASSIGN_BIOMASS_CATEGORY = [p[0] for p in PARAMS_ASSIGN_BIOMASS_CATEGORY]
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
@mark.parametrize("input, expected", PARAMS_ASSIGN_BIOMASS_CATEGORY, ids=IDS_ASSIGN_BIOMASS_CATEGORY)
|
|
114
|
+
def test_assign_biomass_category(input: str, expected: BiomassCategory):
|
|
115
|
+
assert _assign_biomass_category(input) == expected
|
|
@@ -4,13 +4,13 @@ from os.path import isfile
|
|
|
4
4
|
from pytest import mark
|
|
5
5
|
from unittest.mock import patch
|
|
6
6
|
|
|
7
|
-
from hestia_earth.models.ipcc2019.
|
|
7
|
+
from hestia_earth.models.ipcc2019.co2ToAirAboveGroundBiomassStockChange import MODEL, run
|
|
8
8
|
|
|
9
|
-
from tests.utils import fake_new_emission, fixtures_path
|
|
9
|
+
from tests.utils import fake_new_emission, fixtures_path, order_list
|
|
10
10
|
|
|
11
|
-
class_path = f"hestia_earth.models.{MODEL}.
|
|
11
|
+
class_path = f"hestia_earth.models.{MODEL}.co2ToAirAboveGroundBiomassStockChange"
|
|
12
12
|
utils_path = f"hestia_earth.models.{MODEL}.co2ToAirCarbonStockChange_utils"
|
|
13
|
-
fixtures_folder = f"{fixtures_path}/{MODEL}/
|
|
13
|
+
fixtures_folder = f"{fixtures_path}/{MODEL}/co2ToAirAboveGroundBiomassStockChange"
|
|
14
14
|
|
|
15
15
|
RUN_SCENARIOS = [
|
|
16
16
|
("no-overlapping-cycles", 3),
|
|
@@ -63,7 +63,7 @@ def test_run(_get_site_mock, related_cycles_mock, _new_emission_mock, subfolder,
|
|
|
63
63
|
related_cycles_mock.return_value = cycles
|
|
64
64
|
|
|
65
65
|
result = run(cycle)
|
|
66
|
-
assert result == expected
|
|
66
|
+
assert order_list(result) == order_list(expected)
|
|
67
67
|
|
|
68
68
|
|
|
69
69
|
@patch(f"{class_path}._new_emission", side_effect=fake_new_emission)
|
|
@@ -4,13 +4,13 @@ from os.path import isfile
|
|
|
4
4
|
from pytest import mark
|
|
5
5
|
from unittest.mock import patch
|
|
6
6
|
|
|
7
|
-
from hestia_earth.models.ipcc2019.
|
|
7
|
+
from hestia_earth.models.ipcc2019.co2ToAirBelowGroundBiomassStockChange import MODEL, run
|
|
8
8
|
|
|
9
|
-
from tests.utils import fake_new_emission, fixtures_path
|
|
9
|
+
from tests.utils import fake_new_emission, fixtures_path, order_list
|
|
10
10
|
|
|
11
|
-
class_path = f"hestia_earth.models.{MODEL}.
|
|
11
|
+
class_path = f"hestia_earth.models.{MODEL}.co2ToAirBelowGroundBiomassStockChange"
|
|
12
12
|
utils_path = f"hestia_earth.models.{MODEL}.co2ToAirCarbonStockChange_utils"
|
|
13
|
-
fixtures_folder = f"{fixtures_path}/{MODEL}/
|
|
13
|
+
fixtures_folder = f"{fixtures_path}/{MODEL}/co2ToAirBelowGroundBiomassStockChange"
|
|
14
14
|
|
|
15
15
|
RUN_SCENARIOS = [
|
|
16
16
|
("no-overlapping-cycles", 3),
|
|
@@ -63,7 +63,7 @@ def test_run(_get_site_mock, related_cycles_mock, _new_emission_mock, subfolder,
|
|
|
63
63
|
related_cycles_mock.return_value = cycles
|
|
64
64
|
|
|
65
65
|
result = run(cycle)
|
|
66
|
-
assert result == expected
|
|
66
|
+
assert order_list(result) == order_list(expected)
|
|
67
67
|
|
|
68
68
|
|
|
69
69
|
@patch(f"{class_path}._new_emission", side_effect=fake_new_emission)
|
|
@@ -4,13 +4,13 @@ from os.path import isfile
|
|
|
4
4
|
from pytest import mark
|
|
5
5
|
from unittest.mock import patch
|
|
6
6
|
|
|
7
|
-
from hestia_earth.models.ipcc2019.
|
|
7
|
+
from hestia_earth.models.ipcc2019.co2ToAirSoilOrganicCarbonStockChange import MODEL, run
|
|
8
8
|
|
|
9
|
-
from tests.utils import fake_new_emission, fixtures_path
|
|
9
|
+
from tests.utils import fake_new_emission, fixtures_path, order_list
|
|
10
10
|
|
|
11
|
-
class_path = f"hestia_earth.models.{MODEL}.
|
|
11
|
+
class_path = f"hestia_earth.models.{MODEL}.co2ToAirSoilOrganicCarbonStockChange"
|
|
12
12
|
utils_path = f"hestia_earth.models.{MODEL}.co2ToAirCarbonStockChange_utils"
|
|
13
|
-
fixtures_folder = f"{fixtures_path}/{MODEL}/
|
|
13
|
+
fixtures_folder = f"{fixtures_path}/{MODEL}/co2ToAirSoilOrganicCarbonStockChange"
|
|
14
14
|
|
|
15
15
|
RUN_SCENARIOS = [
|
|
16
16
|
("no-overlapping-cycles", 3),
|
|
@@ -63,7 +63,7 @@ def test_run(_get_site_mock, related_cycles_mock, _new_emission_mock, subfolder,
|
|
|
63
63
|
related_cycles_mock.return_value = cycles
|
|
64
64
|
|
|
65
65
|
result = run(cycle)
|
|
66
|
-
assert result == expected
|
|
66
|
+
assert order_list(result) == order_list(expected)
|
|
67
67
|
|
|
68
68
|
|
|
69
69
|
@patch(f"{class_path}._new_emission", side_effect=fake_new_emission)
|
|
@@ -13,8 +13,8 @@ def test_run_no_emissions():
|
|
|
13
13
|
impact = json.load(f)
|
|
14
14
|
|
|
15
15
|
impact['emissionsResourceUse'] = []
|
|
16
|
-
|
|
17
|
-
assert value
|
|
16
|
+
indicator = run(impact)
|
|
17
|
+
assert indicator.get('value') == 0
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
@patch(f"{class_path}._new_indicator", side_effect=fake_new_indicator)
|
|
@@ -1,45 +1,58 @@
|
|
|
1
1
|
import json
|
|
2
2
|
from unittest.mock import patch
|
|
3
3
|
|
|
4
|
-
from hestia_earth.models.poschEtAl2008.terrestrialAcidificationPotentialAccumulatedExceedance import MODEL, TERM_ID,
|
|
4
|
+
from hestia_earth.models.poschEtAl2008.terrestrialAcidificationPotentialAccumulatedExceedance import MODEL, TERM_ID, \
|
|
5
|
+
run
|
|
5
6
|
from tests.utils import fixtures_path, fake_new_indicator
|
|
6
7
|
|
|
7
8
|
class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}"
|
|
8
9
|
fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
|
|
9
10
|
|
|
10
11
|
|
|
12
|
+
def fake_rounded_indicator(value: float):
|
|
13
|
+
indicator = fake_new_indicator(TERM_ID, MODEL)
|
|
14
|
+
indicator['value'] = round(value, 7)
|
|
15
|
+
return indicator
|
|
16
|
+
|
|
17
|
+
|
|
11
18
|
@patch(f"{class_path}._new_indicator", side_effect=fake_new_indicator)
|
|
12
19
|
def test_run(*args):
|
|
13
20
|
with open(f"{fixtures_folder}/impact-assessment.jsonld", encoding='utf-8') as f:
|
|
14
|
-
|
|
21
|
+
impactassessment = json.load(f)
|
|
15
22
|
|
|
16
|
-
with open(f"{fixtures_folder}/result.jsonld", encoding='utf-8') as f:
|
|
23
|
+
with open(f"{fixtures_folder}/Australia/result.jsonld", encoding='utf-8') as f:
|
|
17
24
|
expected = json.load(f)
|
|
18
25
|
|
|
19
|
-
value = run(
|
|
26
|
+
value = run(impactassessment)
|
|
20
27
|
assert value == expected
|
|
21
28
|
|
|
22
29
|
|
|
23
|
-
@patch(f"{class_path}.
|
|
30
|
+
@patch(f"{class_path}._indicator", side_effect=fake_rounded_indicator)
|
|
24
31
|
def test_lookup_to_bad_country(*args):
|
|
32
|
+
"""
|
|
33
|
+
Should default to region-world value
|
|
34
|
+
"""
|
|
25
35
|
with open(f"{fixtures_folder}/impact-assessment.jsonld", encoding='utf-8') as f:
|
|
26
|
-
|
|
27
|
-
cycle['country']['@id'] = "example-land-not-real"
|
|
36
|
+
impactassessment = json.load(f)
|
|
28
37
|
|
|
29
|
-
|
|
30
|
-
|
|
38
|
+
impactassessment['country']['@id'] = "example-land-not-real"
|
|
39
|
+
|
|
40
|
+
with open(f"{fixtures_folder}/region-world/result.jsonld", encoding='utf-8') as f:
|
|
41
|
+
expected = json.load(f)
|
|
42
|
+
|
|
43
|
+
value = run(impactassessment)
|
|
44
|
+
assert value == expected
|
|
31
45
|
|
|
32
46
|
|
|
33
47
|
@patch(f"{class_path}._new_indicator", side_effect=fake_new_indicator)
|
|
34
|
-
def
|
|
48
|
+
def test_run_no_emissions(*args):
|
|
35
49
|
"""
|
|
36
|
-
|
|
50
|
+
Impact assessment with no emissions should return a indicator of 0
|
|
37
51
|
"""
|
|
38
52
|
with open(f"{fixtures_folder}/impact-assessment.jsonld", encoding='utf-8') as f:
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
del
|
|
42
|
-
cycle['emissionsResourceUse'][2]['term']['termType'] = "wrong-type"
|
|
53
|
+
impactassessment = json.load(f)
|
|
54
|
+
|
|
55
|
+
del impactassessment['emissionsResourceUse']
|
|
43
56
|
|
|
44
|
-
value = run(
|
|
45
|
-
assert value['value'] == 0
|
|
57
|
+
value = run(impactassessment)
|
|
58
|
+
assert value['value'] == 0
|
|
@@ -9,36 +9,50 @@ class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}"
|
|
|
9
9
|
fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
|
|
10
10
|
|
|
11
11
|
|
|
12
|
+
def fake_rounded_indicator(value: float):
|
|
13
|
+
indicator = fake_new_indicator(TERM_ID, MODEL)
|
|
14
|
+
indicator['value'] = round(value, 7)
|
|
15
|
+
return indicator
|
|
16
|
+
|
|
17
|
+
|
|
12
18
|
@patch(f"{class_path}._new_indicator", side_effect=fake_new_indicator)
|
|
13
19
|
def test_run(*args):
|
|
14
20
|
with open(f"{fixtures_folder}/impact-assessment.jsonld", encoding='utf-8') as f:
|
|
15
|
-
|
|
21
|
+
impactassessment = json.load(f)
|
|
16
22
|
|
|
17
|
-
with open(f"{fixtures_folder}/result.jsonld", encoding='utf-8') as f:
|
|
23
|
+
with open(f"{fixtures_folder}/Belarus/result.jsonld", encoding='utf-8') as f:
|
|
18
24
|
expected = json.load(f)
|
|
19
25
|
|
|
20
|
-
value = run(
|
|
26
|
+
value = run(impactassessment)
|
|
21
27
|
assert value == expected
|
|
22
28
|
|
|
23
29
|
|
|
24
|
-
@patch(f"{class_path}.
|
|
30
|
+
@patch(f"{class_path}._indicator", side_effect=fake_rounded_indicator)
|
|
25
31
|
def test_lookup_to_bad_country(*args):
|
|
32
|
+
"""
|
|
33
|
+
Should default to region-world value
|
|
34
|
+
"""
|
|
26
35
|
with open(f"{fixtures_folder}/impact-assessment.jsonld", encoding='utf-8') as f:
|
|
27
|
-
|
|
28
|
-
cycle['country']['@id'] = "example-land-not-real"
|
|
36
|
+
impactassessment = json.load(f)
|
|
29
37
|
|
|
30
|
-
|
|
31
|
-
|
|
38
|
+
impactassessment['country']['@id'] = "example-land-not-real"
|
|
39
|
+
|
|
40
|
+
with open(f"{fixtures_folder}/region-world/result.jsonld", encoding='utf-8') as f:
|
|
41
|
+
expected = json.load(f)
|
|
42
|
+
|
|
43
|
+
value = run(impactassessment)
|
|
44
|
+
assert value == expected
|
|
32
45
|
|
|
33
46
|
|
|
34
47
|
@patch(f"{class_path}._new_indicator", side_effect=fake_new_indicator)
|
|
35
|
-
def
|
|
48
|
+
def test_run_no_emissions(*args):
|
|
36
49
|
"""
|
|
37
|
-
|
|
50
|
+
Impact assessment with no emissions should return a indicator of 0
|
|
38
51
|
"""
|
|
39
52
|
with open(f"{fixtures_folder}/impact-assessment.jsonld", encoding='utf-8') as f:
|
|
40
|
-
|
|
41
|
-
|
|
53
|
+
impactassessment = json.load(f)
|
|
54
|
+
|
|
55
|
+
del impactassessment['emissionsResourceUse']
|
|
42
56
|
|
|
43
|
-
value = run(
|
|
44
|
-
assert value['value'] ==
|
|
57
|
+
value = run(impactassessment)
|
|
58
|
+
assert value['value'] == 0
|