hestia-earth-models 0.64.6__py3-none-any.whl → 0.64.7__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/environmentalFootprintV3/soilQualityIndexLandOccupation.py +23 -22
- hestia_earth/models/mocking/search-results.json +26 -2002
- hestia_earth/models/pooreNemecek2018/landOccupationDuringCycle.py +11 -7
- hestia_earth/models/transformation/input/excreta.py +9 -13
- hestia_earth/models/version.py +1 -1
- {hestia_earth_models-0.64.6.dist-info → hestia_earth_models-0.64.7.dist-info}/METADATA +1 -1
- {hestia_earth_models-0.64.6.dist-info → hestia_earth_models-0.64.7.dist-info}/RECORD +13 -13
- tests/models/environmentalFootprintV3/test_freshwaterEcotoxicityPotentialCtue.py +4 -2
- tests/models/environmentalFootprintV3/test_soilQualityIndexLandOccupation.py +16 -24
- tests/models/pooreNemecek2018/test_landOccupationDuringCycle.py +4 -1
- {hestia_earth_models-0.64.6.dist-info → hestia_earth_models-0.64.7.dist-info}/LICENSE +0 -0
- {hestia_earth_models-0.64.6.dist-info → hestia_earth_models-0.64.7.dist-info}/WHEEL +0 -0
- {hestia_earth_models-0.64.6.dist-info → hestia_earth_models-0.64.7.dist-info}/top_level.txt +0 -0
|
@@ -2,6 +2,7 @@ from hestia_earth.models.log import logRequirements, logShouldRun
|
|
|
2
2
|
from hestia_earth.models.utils.indicator import _new_indicator
|
|
3
3
|
from hestia_earth.models.utils.impact_assessment import get_product, get_site
|
|
4
4
|
from hestia_earth.models.utils.cycle import land_occupation_per_kg
|
|
5
|
+
from hestia_earth.models.utils.site import get_land_cover_term_id
|
|
5
6
|
from . import MODEL
|
|
6
7
|
|
|
7
8
|
REQUIREMENTS = {
|
|
@@ -38,14 +39,15 @@ REQUIREMENTS = {
|
|
|
38
39
|
}
|
|
39
40
|
RETURNS = {
|
|
40
41
|
"Indicator": [{
|
|
41
|
-
"value": ""
|
|
42
|
+
"value": "",
|
|
43
|
+
"landCover": ""
|
|
42
44
|
}]
|
|
43
45
|
}
|
|
44
46
|
TERM_ID = 'landOccupationDuringCycle'
|
|
45
47
|
|
|
46
48
|
|
|
47
|
-
def _indicator(term_id: str, value: float):
|
|
48
|
-
indicator = _new_indicator(term_id, MODEL)
|
|
49
|
+
def _indicator(term_id: str, value: float, land_covert_term_id: str):
|
|
50
|
+
indicator = _new_indicator(term_id, MODEL, land_covert_term_id)
|
|
49
51
|
indicator['value'] = value
|
|
50
52
|
return indicator
|
|
51
53
|
|
|
@@ -54,16 +56,18 @@ def _should_run(impact_assessment: dict):
|
|
|
54
56
|
product = get_product(impact_assessment)
|
|
55
57
|
cycle = impact_assessment.get('cycle', {})
|
|
56
58
|
site = get_site(impact_assessment)
|
|
59
|
+
land_covert_term_id = get_land_cover_term_id(site.get('siteType'))
|
|
57
60
|
land_occupation_m2_kg = land_occupation_per_kg(MODEL, TERM_ID, cycle, site, product)
|
|
58
61
|
|
|
59
62
|
logRequirements(impact_assessment, model=MODEL, term=TERM_ID,
|
|
60
|
-
land_occupation_kg=land_occupation_m2_kg
|
|
63
|
+
land_occupation_kg=land_occupation_m2_kg,
|
|
64
|
+
land_covert_term_id=land_covert_term_id)
|
|
61
65
|
|
|
62
66
|
should_run = all([land_occupation_m2_kg is not None])
|
|
63
67
|
logShouldRun(impact_assessment, MODEL, TERM_ID, should_run)
|
|
64
|
-
return should_run, land_occupation_m2_kg
|
|
68
|
+
return should_run, land_occupation_m2_kg, land_covert_term_id
|
|
65
69
|
|
|
66
70
|
|
|
67
71
|
def run(impact_assessment: dict):
|
|
68
|
-
should_run, land_occupation_kg = _should_run(impact_assessment)
|
|
69
|
-
return [_indicator(TERM_ID, land_occupation_kg)] if should_run else []
|
|
72
|
+
should_run, land_occupation_kg, land_covert_term_id = _should_run(impact_assessment)
|
|
73
|
+
return [_indicator(TERM_ID, land_occupation_kg, land_covert_term_id)] if should_run else []
|
|
@@ -4,12 +4,13 @@ Input Excreta
|
|
|
4
4
|
Copy Cycle (or previous Transformation) `excreta` products into the Transformation inputs if they are missing.
|
|
5
5
|
"""
|
|
6
6
|
from functools import reduce
|
|
7
|
-
from hestia_earth.schema import NodeType, TermTermType
|
|
7
|
+
from hestia_earth.schema import NodeType, TermTermType, Input, Product
|
|
8
8
|
from hestia_earth.utils.model import filter_list_term_type, find_term_match
|
|
9
9
|
from hestia_earth.utils.tools import list_sum
|
|
10
10
|
|
|
11
11
|
from hestia_earth.models.log import logShouldRun
|
|
12
|
-
from hestia_earth.models.utils import term_id_prefix
|
|
12
|
+
from hestia_earth.models.utils import _omit, term_id_prefix
|
|
13
|
+
from hestia_earth.models.utils.blank_node import merge_blank_nodes
|
|
13
14
|
from hestia_earth.models.utils.input import _new_input
|
|
14
15
|
from hestia_earth.models.utils.transformation import previous_transformation
|
|
15
16
|
from .. import MODEL
|
|
@@ -43,13 +44,10 @@ MODEL_LOG = '/'.join([MODEL, 'input', MODEL_KEY])
|
|
|
43
44
|
def _to_input(transformation: dict):
|
|
44
45
|
def new_input(values: tuple):
|
|
45
46
|
product, ratio = values
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
del data['primary']
|
|
47
|
+
# omit all keys in Product but not in Input
|
|
48
|
+
data = _omit(product, list(Product().fields.keys() - Input().fields.keys()))
|
|
49
49
|
logShouldRun(transformation, MODEL_LOG, product.get('term', {}).get('@id'), True)
|
|
50
|
-
return {
|
|
51
|
-
**data,
|
|
52
|
-
**_new_input(product.get('term')),
|
|
50
|
+
return data | _new_input(product.get('term')) | {
|
|
53
51
|
'value': [v * ratio for v in product.get('value', [])],
|
|
54
52
|
'fromCycle': True
|
|
55
53
|
}
|
|
@@ -59,8 +57,7 @@ def _to_input(transformation: dict):
|
|
|
59
57
|
def _group_by_prefix(values: dict, input: dict):
|
|
60
58
|
term_id = input.get('term', {}).get('@id')
|
|
61
59
|
group_id = term_id_prefix(term_id)
|
|
62
|
-
values[group_id] = values.get(group_id, [])
|
|
63
|
-
values[group_id].append(input)
|
|
60
|
+
values[group_id] = values.get(group_id, []) + [input]
|
|
64
61
|
return values
|
|
65
62
|
|
|
66
63
|
|
|
@@ -84,10 +81,9 @@ def _run_transformation(cycle: dict):
|
|
|
84
81
|
previous = previous_transformation(cycle, transformations, transformation)
|
|
85
82
|
products = filter_list_term_type(previous.get('products', []), TermTermType.EXCRETA)
|
|
86
83
|
inputs = transformation.get('inputs', [])
|
|
87
|
-
|
|
88
|
-
grouped_inputs = reduce(_group_by_prefix, excreta, {})
|
|
84
|
+
grouped_inputs = reduce(_group_by_prefix, filter_list_term_type(inputs, TermTermType.EXCRETA), {})
|
|
89
85
|
missing_products = reduce(_group_missing_products(products), grouped_inputs.values(), [])
|
|
90
|
-
transformation['inputs'] = inputs
|
|
86
|
+
transformation['inputs'] = merge_blank_nodes(inputs, list(map(_to_input(transformation), missing_products)))
|
|
91
87
|
return transformations + [transformation]
|
|
92
88
|
return run
|
|
93
89
|
|
hestia_earth/models/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
VERSION = '0.64.
|
|
1
|
+
VERSION = '0.64.7'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: hestia-earth-models
|
|
3
|
-
Version: 0.64.
|
|
3
|
+
Version: 0.64.7
|
|
4
4
|
Summary: HESTIA's set of modules for filling gaps in the activity data using external datasets (e.g. populating soil properties with a geospatial dataset using provided coordinates) and internal lookups (e.g. populating machinery use from fuel use). Includes rules for when gaps should be filled versus not (e.g. never gap fill yield, gap fill crop residue if yield provided etc.).
|
|
5
5
|
Home-page: https://gitlab.com/hestia-earth/hestia-engine-models
|
|
6
6
|
Author: HESTIA Team
|
|
@@ -4,7 +4,7 @@ hestia_earth/models/cache_sites.py,sha256=KQp9cUKE-aIcYJoMWEtKFYS8gBFfsx5LKQhqoW
|
|
|
4
4
|
hestia_earth/models/log.py,sha256=DbfNcGzaC5hzkuMDxQqW6XYoNBI4Uxw4SIoOYoZA6og,3474
|
|
5
5
|
hestia_earth/models/preload_requests.py,sha256=Ibx-YOhR_1yuyFBxsLUbvJHVK7PLyMLoPu5l9jDN_Qk,1342
|
|
6
6
|
hestia_earth/models/requirements.py,sha256=eU4yT443fx7BnaokhrLB_PCizJI7Y6m4auyo8vQauNg,17363
|
|
7
|
-
hestia_earth/models/version.py,sha256=
|
|
7
|
+
hestia_earth/models/version.py,sha256=t7dOvw4O9g0IERDiBz_TU-VBx8C8EBuoC8snFc4ns-I,19
|
|
8
8
|
hestia_earth/models/agribalyse2016/__init__.py,sha256=WvK0qCQbnYtg9oZxrACd1wGormZyXibPtpCnIQeDqbw,415
|
|
9
9
|
hestia_earth/models/agribalyse2016/fuelElectricity.py,sha256=tnGxBmJdPfPFfehLUQcefEqy1lHvzsSpx_s7O8nf3Zs,4412
|
|
10
10
|
hestia_earth/models/agribalyse2016/machineryInfrastructureDepreciatedAmountPerCycle.py,sha256=BPjnWmg73i_OxM2ouCdMTWZtPIqyoUAXrvutntyteE0,3390
|
|
@@ -138,7 +138,7 @@ hestia_earth/models/emepEea2019/utils.py,sha256=oTHjbRRwJZv_tpO9MOlfpyQRmN0a1kvE
|
|
|
138
138
|
hestia_earth/models/emissionNotRelevant/__init__.py,sha256=nIuPIkQR1ghv_T_Ab4Ckq5wmGdWVmgbaOjhtKfIJ-WE,2183
|
|
139
139
|
hestia_earth/models/environmentalFootprintV3/__init__.py,sha256=lzg9qccwd9tbspw0lQ58YPprnvvSLTn3QV5T2-tPcC4,425
|
|
140
140
|
hestia_earth/models/environmentalFootprintV3/freshwaterEcotoxicityPotentialCtue.py,sha256=X62-4v0NJdM_Z5kLK3NuU4GNEeSrXlKlMZQB_o4JZ6c,1018
|
|
141
|
-
hestia_earth/models/environmentalFootprintV3/soilQualityIndexLandOccupation.py,sha256=
|
|
141
|
+
hestia_earth/models/environmentalFootprintV3/soilQualityIndexLandOccupation.py,sha256=uo489YIEIO1kuVYm6AKDGysLLjxcBchGWGr0jjLOJo4,4426
|
|
142
142
|
hestia_earth/models/environmentalFootprintV3/utils.py,sha256=HKz_ckzuMZvo8YL-laApyhiccl2NoJUxHs2npwBCMWw,712
|
|
143
143
|
hestia_earth/models/epa2014/__init__.py,sha256=ckGf_6X7CCzI_18OqchEkuJAXKXM1x7V53u480ckknM,408
|
|
144
144
|
hestia_earth/models/epa2014/no3ToGroundwaterExcreta.py,sha256=fN4fOOcjBg3tl0lzNeJ8mzg6mrvQRxilx-R5Gc4l4Nw,1724
|
|
@@ -395,7 +395,7 @@ hestia_earth/models/linkedImpactAssessment/landTransformationFromPermanentPastur
|
|
|
395
395
|
hestia_earth/models/linkedImpactAssessment/utils.py,sha256=dGwGc2d-8_WQElTpfyPmz5vQtL-LHQRmiZnCTuPXMDs,1876
|
|
396
396
|
hestia_earth/models/mocking/__init__.py,sha256=n3Fkkrvh8zHNWiJZmnfQ7WZ91JRzAO9P6pSG1JpwtXo,687
|
|
397
397
|
hestia_earth/models/mocking/mock_search.py,sha256=qgABw-sZK37XtsALKt8AHF2VJPUrZSnHv5Qj1Dn93oA,2405
|
|
398
|
-
hestia_earth/models/mocking/search-results.json,sha256=
|
|
398
|
+
hestia_earth/models/mocking/search-results.json,sha256=wOz1T0GfXcwzzoXZ0QioZ4oL7N5WkZitP7g1fOAQP18,11627
|
|
399
399
|
hestia_earth/models/pooreNemecek2018/__init__.py,sha256=nPboL7ULJzL5nJD5q7q9VOZt_fxbKVm8fmn1Az5YkVY,417
|
|
400
400
|
hestia_earth/models/pooreNemecek2018/aboveGroundCropResidueTotal.py,sha256=Qt-mel4dkhK6N5uUOutNOinCTFjbjtGzITaaI0LvYc4,2396
|
|
401
401
|
hestia_earth/models/pooreNemecek2018/belowGroundCropResidue.py,sha256=JT0RybbvWVlo01FO8K0Yj41HrEaJT3Kj1xfayr2X-xw,2315
|
|
@@ -403,7 +403,7 @@ hestia_earth/models/pooreNemecek2018/ch4ToAirAquacultureSystems.py,sha256=CxjhFi
|
|
|
403
403
|
hestia_earth/models/pooreNemecek2018/excretaKgN.py,sha256=kB4C1mSA9h8uUJXXaf-39ZwhzAmmvapkfA7v0nUN_Qg,6418
|
|
404
404
|
hestia_earth/models/pooreNemecek2018/excretaKgVs.py,sha256=5rK3wfI8JO2feaFRv23-s9bH09DIl4LLLcjHS3cf-Ow,8424
|
|
405
405
|
hestia_earth/models/pooreNemecek2018/freshwaterWithdrawalsDuringCycle.py,sha256=HB_9q5eE6al2Te3v29hC5wqxsYe4P46ZAPwdWNzx3v0,3939
|
|
406
|
-
hestia_earth/models/pooreNemecek2018/landOccupationDuringCycle.py,sha256=
|
|
406
|
+
hestia_earth/models/pooreNemecek2018/landOccupationDuringCycle.py,sha256=GFOm1T9I_aqnGRS3Rsb7gGFEMn9jB4irtdoNW8SFI6s,3118
|
|
407
407
|
hestia_earth/models/pooreNemecek2018/longFallowDuration.py,sha256=Wdm6QyOttCFP9Y3OjbaYrvdMmivOmMIT-m5Eg9SM9rY,1511
|
|
408
408
|
hestia_earth/models/pooreNemecek2018/n2OToAirAquacultureSystemsDirect.py,sha256=HJ7IstImGyasIKosK2lQZ-v6Lqt3_aEfZhoiC4CY0rM,2586
|
|
409
409
|
hestia_earth/models/pooreNemecek2018/n2ToAirAquacultureSystems.py,sha256=SoZlogDd7_4kq5S9gc8KmVeIXacWWhaUkWlKTuho_OA,2431
|
|
@@ -544,7 +544,7 @@ hestia_earth/models/stehfestBouwman2006GisImplementation/noxToAirOrganicFertilis
|
|
|
544
544
|
hestia_earth/models/stehfestBouwman2006GisImplementation/noxToAirSoilFlux.py,sha256=yRsk-WcI13mVz4jerCAxJY91hqNs2JelXhbufP83Km0,3403
|
|
545
545
|
hestia_earth/models/transformation/__init__.py,sha256=63Y_fXFBn4sX2l7F0hMsWkgIvxk5Tw9XoDBQr6bUBQQ,352
|
|
546
546
|
hestia_earth/models/transformation/input/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
547
|
-
hestia_earth/models/transformation/input/excreta.py,sha256=
|
|
547
|
+
hestia_earth/models/transformation/input/excreta.py,sha256=Ic2PrVZcVkxV7M5_Ouk1Yx3GZiiSsQSGQvTWMRE-dHo,4281
|
|
548
548
|
hestia_earth/models/transformation/input/max.py,sha256=epoVopKlKl7epxwz-iLTfmnCHBjmOhiBMhGEQB8-LtU,1574
|
|
549
549
|
hestia_earth/models/transformation/input/min.py,sha256=E3o7Fpoyx-DVrFk_QzQrs24kwvCX9Ylb4mvCoUOwtcw,1574
|
|
550
550
|
hestia_earth/models/transformation/input/properties.py,sha256=tIWhpYDzywATe3_NAMQhrL0hMFeeRHnpZWmLcRsJP8Q,2294
|
|
@@ -723,8 +723,8 @@ tests/models/emepEea2019/test_so2ToAirFuelCombustion.py,sha256=zRTyeeQM1fRdRVFWb
|
|
|
723
723
|
tests/models/emepEea2019/test_tspToAirAnimalHousing.py,sha256=4MNDsxIeUk5_3IvZwEZslxgoPNyQN9OQFDNY3uGNX6E,714
|
|
724
724
|
tests/models/emepEea2019/test_utils.py,sha256=G6z8tEfWM0OPnUBaFCQgQyEi5-kRF_DqsqdYaPnzR_I,8761
|
|
725
725
|
tests/models/environmentalFootprintV3/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
726
|
-
tests/models/environmentalFootprintV3/test_freshwaterEcotoxicityPotentialCtue.py,sha256=
|
|
727
|
-
tests/models/environmentalFootprintV3/test_soilQualityIndexLandOccupation.py,sha256=
|
|
726
|
+
tests/models/environmentalFootprintV3/test_freshwaterEcotoxicityPotentialCtue.py,sha256=ZPDKM23qlLMe_ZzeA-QIutSkFlod3BsmjloA9WA8nug,845
|
|
727
|
+
tests/models/environmentalFootprintV3/test_soilQualityIndexLandOccupation.py,sha256=5cv3R1Zam0aW00smkWNKExgdWomhT9Ad8bCTH8KZCdw,4324
|
|
728
728
|
tests/models/epa2014/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
729
729
|
tests/models/epa2014/test_no3ToGroundwaterExcreta.py,sha256=ESVz4UURvQfhjGBTxjuAV_bymMBcvGNfLAkYMvNup9U,1217
|
|
730
730
|
tests/models/fantkeEtAl2016/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -980,7 +980,7 @@ tests/models/pooreNemecek2018/test_ch4ToAirAquacultureSystems.py,sha256=rUxD57yl
|
|
|
980
980
|
tests/models/pooreNemecek2018/test_excretaKgN.py,sha256=lKM-Q7TjQoxjvjY9tCcmJxoWvHuxglNCVsPXh6JBgCY,4063
|
|
981
981
|
tests/models/pooreNemecek2018/test_excretaKgVs.py,sha256=LIoLevR0tHrZwazuGprt6SCFtmDrj4NBq1s1SJEhQCA,3252
|
|
982
982
|
tests/models/pooreNemecek2018/test_freshwaterWithdrawalsDuringCycle.py,sha256=5QxDU6VzcwWup3Nuhn32kJoIlAkqcSggGr4CmoRqrFA,1623
|
|
983
|
-
tests/models/pooreNemecek2018/test_landOccupationDuringCycle.py,sha256=
|
|
983
|
+
tests/models/pooreNemecek2018/test_landOccupationDuringCycle.py,sha256=MrgxJIuojKCuwCKX6d_KMsg8dTkfdxWwZPnCtjFZDwo,1873
|
|
984
984
|
tests/models/pooreNemecek2018/test_longFallowDuration.py,sha256=kelZajIbKyvVm1vX_grRZy0IUrtejGI5GPn03qbElnw,925
|
|
985
985
|
tests/models/pooreNemecek2018/test_n2OToAirAquacultureSystemsDirect.py,sha256=4YAoUhIwfEmRe2B5BvNg247VeB7UXHNeZqr2mRtJA7Y,2207
|
|
986
986
|
tests/models/pooreNemecek2018/test_n2ToAirAquacultureSystems.py,sha256=YqwAvbYfLVamfkUJUwGTEWEnz8ts66jVF8831QcWNkg,2200
|
|
@@ -1154,8 +1154,8 @@ tests/models/utils/test_term.py,sha256=M5Sa26v2gzQYbZ4H_fo7DspnaCx__-WtL-MULGapC
|
|
|
1154
1154
|
tests/models/utils/test_time_series.py,sha256=LMhRPf8rp3nAriKAC-2K3FDkrMWntRTUUCERw7Lt68g,2686
|
|
1155
1155
|
tests/models/webbEtAl2012AndSintermannEtAl2012/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
1156
1156
|
tests/models/webbEtAl2012AndSintermannEtAl2012/test_nh3ToAirOrganicFertiliser.py,sha256=qi2FNXS5Af2WDtm7nq_FsprH3BfCF0XxnE0XHmC4aIY,2244
|
|
1157
|
-
hestia_earth_models-0.64.
|
|
1158
|
-
hestia_earth_models-0.64.
|
|
1159
|
-
hestia_earth_models-0.64.
|
|
1160
|
-
hestia_earth_models-0.64.
|
|
1161
|
-
hestia_earth_models-0.64.
|
|
1157
|
+
hestia_earth_models-0.64.7.dist-info/LICENSE,sha256=AC7h7GAgCZGJK_Tzh6LUCrML9gQEfowWwecEw2w54QM,1154
|
|
1158
|
+
hestia_earth_models-0.64.7.dist-info/METADATA,sha256=QNAYnAT1-gWDF6jiD3vDBfJQXuwsVE3hzMZDdq6TTEo,3343
|
|
1159
|
+
hestia_earth_models-0.64.7.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
|
|
1160
|
+
hestia_earth_models-0.64.7.dist-info/top_level.txt,sha256=1dqA9TqpOLTEgpqa-YBsmbCmmNU1y56AtfFGEceZ2A0,19
|
|
1161
|
+
hestia_earth_models-0.64.7.dist-info/RECORD,,
|
|
@@ -8,10 +8,12 @@ class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}"
|
|
|
8
8
|
fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
|
|
9
9
|
|
|
10
10
|
|
|
11
|
+
with open(f"{fixtures_path}/impact_assessment/emissions/impact-assessment.jsonld", encoding='utf-8') as f:
|
|
12
|
+
impact = json.load(f)
|
|
13
|
+
|
|
14
|
+
|
|
11
15
|
@patch(f"{class_path}._new_indicator", side_effect=fake_new_indicator)
|
|
12
16
|
def test_run(*args):
|
|
13
|
-
with open(f"{fixtures_path}/impact_assessment/emissions/impact-assessment.jsonld", encoding='utf-8') as f:
|
|
14
|
-
impact = json.load(f)
|
|
15
17
|
with open(f"{fixtures_folder}/cycle.jsonld", encoding='utf-8') as f:
|
|
16
18
|
cycle = json.load(f)
|
|
17
19
|
|
|
@@ -8,6 +8,10 @@ class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}"
|
|
|
8
8
|
fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
|
|
9
9
|
|
|
10
10
|
|
|
11
|
+
with open(f"{fixtures_path}/impact_assessment/emissions/impact-assessment.jsonld", encoding='utf-8') as f:
|
|
12
|
+
impact = json.load(f)
|
|
13
|
+
|
|
14
|
+
|
|
11
15
|
def test_should_run():
|
|
12
16
|
with open(f"{fixtures_folder}/cycle.jsonld", encoding='utf-8') as f:
|
|
13
17
|
cycle = json.load(f)
|
|
@@ -16,41 +20,25 @@ def test_should_run():
|
|
|
16
20
|
cycle['site']['management'] = [{"endDate": "2024-03-31", "@type": "Management",
|
|
17
21
|
"term": {"termType": "landCover", "@type": "Term", "@id": "ocean"}}]
|
|
18
22
|
|
|
19
|
-
should_run, *args = _should_run(cycle)
|
|
23
|
+
should_run, *args = _should_run({'cycle': cycle})
|
|
20
24
|
assert not should_run
|
|
21
25
|
|
|
22
26
|
# no management => no run
|
|
23
27
|
cycle['site']['management'] = []
|
|
24
|
-
should_run, *args = _should_run(cycle)
|
|
28
|
+
should_run, *args = _should_run({'cycle': cycle})
|
|
25
29
|
assert not should_run
|
|
26
30
|
|
|
27
31
|
|
|
28
32
|
@patch(f"{class_path}._new_indicator", side_effect=fake_new_indicator)
|
|
29
33
|
def test_run(*args):
|
|
30
|
-
"""
|
|
31
|
-
Example data:
|
|
32
|
-
Country: Italy
|
|
33
|
-
Quantity in m^2: 1.3573373E-9
|
|
34
|
-
CF METHOD factor: 4.3198E+01
|
|
35
|
-
"Charact Result [soil quality index]" result also in result.jsonld : 5.86342566854E-08
|
|
36
|
-
siteArea in test file in ha: 1.3573373E-9 / 10 000 = 1.3573373e-13
|
|
37
|
-
|
|
38
|
-
Name Flow: forest Land occupation
|
|
39
|
-
Parameters
|
|
40
|
-
----------
|
|
41
|
-
args
|
|
42
|
-
|
|
43
|
-
Returns
|
|
44
|
-
-------
|
|
45
|
-
|
|
46
|
-
"""
|
|
47
34
|
with open(f"{fixtures_folder}/cycle.jsonld", encoding='utf-8') as f:
|
|
48
35
|
cycle = json.load(f)
|
|
49
36
|
|
|
50
37
|
with open(f"{fixtures_folder}/result.jsonld", encoding='utf-8') as f:
|
|
51
38
|
expected = json.load(f)
|
|
52
39
|
|
|
53
|
-
|
|
40
|
+
impact['cycle'] = cycle
|
|
41
|
+
value = run(impact)
|
|
54
42
|
assert value == expected
|
|
55
43
|
|
|
56
44
|
|
|
@@ -77,7 +65,8 @@ def test_run_other_sites(*args):
|
|
|
77
65
|
with open(f"{fixtures_folder}/otherSites/result.jsonld", encoding='utf-8') as f:
|
|
78
66
|
expected = json.load(f)
|
|
79
67
|
|
|
80
|
-
|
|
68
|
+
impact['cycle'] = cycle
|
|
69
|
+
value = run(impact)
|
|
81
70
|
assert value == expected
|
|
82
71
|
|
|
83
72
|
|
|
@@ -100,7 +89,8 @@ def test_run_with_subclass_landcover(*args):
|
|
|
100
89
|
with open(f"{fixtures_folder}/plantationForest/result.jsonld", encoding='utf-8') as f:
|
|
101
90
|
expected = json.load(f)
|
|
102
91
|
|
|
103
|
-
|
|
92
|
+
impact['cycle'] = cycle
|
|
93
|
+
value = run(impact)
|
|
104
94
|
assert value == expected
|
|
105
95
|
|
|
106
96
|
|
|
@@ -115,7 +105,8 @@ def test_run_with_region_missing_data(*args):
|
|
|
115
105
|
with open(f"{fixtures_folder}/default-region-world/result.jsonld", encoding='utf-8') as f:
|
|
116
106
|
expected = json.load(f)
|
|
117
107
|
|
|
118
|
-
|
|
108
|
+
impact['cycle'] = cycle
|
|
109
|
+
value = run(impact)
|
|
119
110
|
assert value == expected
|
|
120
111
|
|
|
121
112
|
|
|
@@ -132,5 +123,6 @@ def test_run_with_no_region(*args):
|
|
|
132
123
|
with open(f"{fixtures_folder}/default-region-world/result.jsonld", encoding='utf-8') as f:
|
|
133
124
|
expected = json.load(f)
|
|
134
125
|
|
|
135
|
-
|
|
126
|
+
impact['cycle'] = cycle
|
|
127
|
+
value = run(impact)
|
|
136
128
|
assert value == expected
|
|
@@ -9,8 +9,9 @@ class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}"
|
|
|
9
9
|
fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
|
|
10
10
|
|
|
11
11
|
|
|
12
|
+
@patch(f"{class_path}.get_land_cover_term_id", return_value='cropland')
|
|
12
13
|
@patch(f"{class_path}.land_occupation_per_kg", return_value=None)
|
|
13
|
-
def test_should_run(mock_land_occupation):
|
|
14
|
+
def test_should_run(mock_land_occupation, *args):
|
|
14
15
|
# with a cycle and functionalUnit = 1 ha => no run
|
|
15
16
|
impact = {'cycle': {'functionalUnit': CycleFunctionalUnit._1_HA.value}}
|
|
16
17
|
should_run, *args = _should_run(impact)
|
|
@@ -22,6 +23,7 @@ def test_should_run(mock_land_occupation):
|
|
|
22
23
|
assert should_run is True
|
|
23
24
|
|
|
24
25
|
|
|
26
|
+
@patch(f"{class_path}.get_land_cover_term_id", return_value='cropland')
|
|
25
27
|
@patch(f"{class_path}._new_indicator", side_effect=fake_new_indicator)
|
|
26
28
|
def test_run(*args):
|
|
27
29
|
with open(f"{fixtures_folder}/impact-assessment.jsonld", encoding='utf-8') as f:
|
|
@@ -34,6 +36,7 @@ def test_run(*args):
|
|
|
34
36
|
assert value == expected
|
|
35
37
|
|
|
36
38
|
|
|
39
|
+
@patch(f"{class_path}.get_land_cover_term_id", return_value='cropland')
|
|
37
40
|
@patch(f"{class_path}._new_indicator", side_effect=fake_new_indicator)
|
|
38
41
|
def test_run_with_plantation(*args):
|
|
39
42
|
with open(f"{fixtures_folder}/with-orchard-crop/impact-assessment.jsonld", encoding='utf-8') as f:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|