hestia-earth-models 0.64.7__py3-none-any.whl → 0.64.8__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.

Files changed (33) hide show
  1. hestia_earth/models/cycle/animal/milkYield.py +10 -22
  2. hestia_earth/models/cycle/unknownPreSeasonWaterRegime.py +0 -1
  3. hestia_earth/models/environmentalFootprintV3/soilQualityIndexLandOccupation.py +2 -2
  4. hestia_earth/models/environmentalFootprintV3/soilQualityIndexLandTransformation.py +182 -0
  5. hestia_earth/models/environmentalFootprintV3/soilQualityIndexTotalLandUseEffects.py +66 -0
  6. hestia_earth/models/environmentalFootprintV3/utils.py +1 -1
  7. hestia_earth/models/hyde32/utils.py +4 -0
  8. hestia_earth/models/ipcc2019/animal/pastureGrass.py +3 -1
  9. hestia_earth/models/ipcc2019/co2ToAirAboveGroundBiomassStockChangeLandUseChange.py +191 -0
  10. hestia_earth/models/ipcc2019/co2ToAirBelowGroundBiomassStockChangeLandUseChange.py +204 -0
  11. hestia_earth/models/ipcc2019/co2ToAirCarbonStockChange_utils.py +255 -35
  12. hestia_earth/models/ipcc2019/co2ToAirSoilOrganicCarbonStockChangeManagementChange.py +63 -149
  13. hestia_earth/models/ipcc2019/pastureGrass.py +3 -1
  14. hestia_earth/models/mocking/search-results.json +2020 -26
  15. hestia_earth/models/pooreNemecek2018/landOccupationDuringCycle.py +1 -1
  16. hestia_earth/models/site/management.py +3 -5
  17. hestia_earth/models/utils/input.py +5 -2
  18. hestia_earth/models/utils/site.py +4 -2
  19. hestia_earth/models/version.py +1 -1
  20. {hestia_earth_models-0.64.7.dist-info → hestia_earth_models-0.64.8.dist-info}/METADATA +2 -2
  21. {hestia_earth_models-0.64.7.dist-info → hestia_earth_models-0.64.8.dist-info}/RECORD +33 -25
  22. tests/models/cycle/animal/test_milkYield.py +1 -14
  23. tests/models/environmentalFootprintV3/test_soilQualityIndexLandTransformation.py +113 -0
  24. tests/models/environmentalFootprintV3/test_soilQualityIndexTotalLandUseEffects.py +50 -0
  25. tests/models/ipcc2019/test_co2ToAirAboveGroundBiomassStockChangeLandUseChange.py +83 -0
  26. tests/models/ipcc2019/test_co2ToAirBelowGroundBiomassStockChangeLandUseChange.py +83 -0
  27. tests/models/ipcc2019/test_co2ToAirCarbonStockChange_utils.py +6 -6
  28. tests/models/ipcc2019/test_co2ToAirSoilOrganicCarbonStockChangeManagementChange.py +5 -4
  29. tests/models/site/test_management.py +4 -1
  30. tests/models/utils/test_input.py +65 -1
  31. {hestia_earth_models-0.64.7.dist-info → hestia_earth_models-0.64.8.dist-info}/LICENSE +0 -0
  32. {hestia_earth_models-0.64.7.dist-info → hestia_earth_models-0.64.8.dist-info}/WHEEL +0 -0
  33. {hestia_earth_models-0.64.7.dist-info → hestia_earth_models-0.64.8.dist-info}/top_level.txt +0 -0
@@ -63,7 +63,7 @@ def _should_run(impact_assessment: dict):
63
63
  land_occupation_kg=land_occupation_m2_kg,
64
64
  land_covert_term_id=land_covert_term_id)
65
65
 
66
- should_run = all([land_occupation_m2_kg is not None])
66
+ should_run = all([land_covert_term_id, land_occupation_m2_kg is not None])
67
67
  logShouldRun(impact_assessment, MODEL, TERM_ID, should_run)
68
68
  return should_run, land_occupation_m2_kg, land_covert_term_id
69
69
 
@@ -267,10 +267,8 @@ def _should_run_all_products(cycles: list, site_type: str):
267
267
  dates = sorted(list(set(
268
268
  non_empty_list(flatten([[cycle.get('startDate'), cycle.get('endDate')] for cycle in cycles]))
269
269
  ))) if site_type not in _SKIP_LAND_COVER_SITE_TYPES else []
270
- site_type_term = download_hestia(get_landCover_term_id_from_site_type(site_type)) if all([
271
- len(dates) >= 2,
272
- site_type
273
- ]) else None
270
+ site_type_id = get_landCover_term_id_from_site_type(site_type) if site_type else None
271
+ site_type_term = download_hestia(site_type_id) if all([len(dates) >= 2, site_type_id]) else None
274
272
  products_site_type = [{
275
273
  "term": linked_node(site_type_term),
276
274
  "value": 100,
@@ -286,7 +284,7 @@ def _should_run(site: dict):
286
284
 
287
285
  products_animal, products_crop_forage, products_land_cover = _should_run_all_products(
288
286
  cycles=cycles,
289
- site_type=site.get("siteType", "")
287
+ site_type=site.get("siteType")
290
288
  )
291
289
  all_products = products_land_cover + products_crop_forage + products_animal
292
290
  all_products = condense_nodes(all_products)
@@ -7,7 +7,7 @@ from hestia_earth.utils.lookup import download_lookup, get_table_value, column_n
7
7
  from ..log import logger
8
8
  from . import _term_id, _include_model, _filter_list_term_unit, _load_calculated_node
9
9
  from .constant import Units
10
- from .blank_node import get_total_value, get_total_value_converted
10
+ from .blank_node import get_total_value, get_total_value_converted, get_lookup_value
11
11
 
12
12
 
13
13
  def _new_input(term, model=None):
@@ -96,7 +96,10 @@ def get_feed_inputs(cycle: dict):
96
96
  return [input for input in inputs if all([
97
97
  list_sum(input.get('value', [])) > 0,
98
98
  input.get('term', {}).get('units') == Units.KG.value,
99
- input.get('isAnimalFeed', False) is True
99
+ input.get('isAnimalFeed', False) is True,
100
+ # handle feed food additives
101
+ input.get('term', {}).get('termType') != TermTermType.FEEDFOODADDITIVE.value or
102
+ bool(get_lookup_value(input.get('term', {}), 'hasEnergyContent'))
100
103
  ])]
101
104
 
102
105
 
@@ -125,5 +125,7 @@ def region_factor(model: str, region_id: str, term_id: str, termType: TermTermTy
125
125
 
126
126
  def get_land_cover_term_id(site_type: str):
127
127
  land_cover_terms = get_land_cover_siteTypes()
128
- term = next((term for term in land_cover_terms if term["name"].lower() == site_type.lower()), {})
129
- return term.get("@id", "")
128
+ term = next((
129
+ term for term in land_cover_terms if term["name"].lower() == site_type.lower()
130
+ ), {}) if site_type else {}
131
+ return term.get('@id')
@@ -1 +1 @@
1
- VERSION = '0.64.7'
1
+ VERSION = '0.64.8'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hestia-earth-models
3
- Version: 0.64.7
3
+ Version: 0.64.8
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
@@ -12,7 +12,7 @@ Classifier: Programming Language :: Python :: 3.6
12
12
  Description-Content-Type: text/markdown
13
13
  License-File: LICENSE
14
14
  Requires-Dist: hestia-earth.schema==30.*
15
- Requires-Dist: hestia-earth.utils>=0.13.4
15
+ Requires-Dist: hestia-earth.utils>=0.13.5
16
16
  Requires-Dist: python-dateutil>=2.8.1
17
17
  Requires-Dist: CurrencyConverter==0.16.8
18
18
  Requires-Dist: haversine>=2.7.0
@@ -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=t7dOvw4O9g0IERDiBz_TU-VBx8C8EBuoC8snFc4ns-I,19
7
+ hestia_earth/models/version.py,sha256=L60xIy0nhRJ6qj8RKQ1dAZGRyLHbUcTSsWzwzTRRH2M,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
@@ -67,10 +67,10 @@ hestia_earth/models/cycle/startDate.py,sha256=pbBi55b6uJezPE8EOovOCSwQVrbwpmxwmr
67
67
  hestia_earth/models/cycle/startDateDefinition.py,sha256=6oJmT6XRKYbv2Jer2UJpkOQqHQKjIAEqPz7yv7k-HP4,2187
68
68
  hestia_earth/models/cycle/stockingDensityAnimalHousingAverage.py,sha256=f1houLdigq6EGMrG3dL8WqAaGVlpXNJB74VbSxWQUCY,1843
69
69
  hestia_earth/models/cycle/transformation.py,sha256=06KTfVubh2I47dfnG9Iv6AbuUBbURM8BAVOkRu7XmHw,1255
70
- hestia_earth/models/cycle/unknownPreSeasonWaterRegime.py,sha256=9EP8FMXO5fHqmhVNSqR_Dfe38KxwyPOCF6kMewiI_VE,1478
70
+ hestia_earth/models/cycle/unknownPreSeasonWaterRegime.py,sha256=s0vO5-6yNA2I2PbQvoXDO-THxU4k7wveieQFY-q26c0,1453
71
71
  hestia_earth/models/cycle/utils.py,sha256=SaJyQEufLlUCeA6P2rgK5nev1D8J1eCthPUwG0ZPvRE,1407
72
72
  hestia_earth/models/cycle/animal/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
73
- hestia_earth/models/cycle/animal/milkYield.py,sha256=O5-OruRhUpKpxsfhGskTHLP8PDd-awAxlEh8acq_PaQ,3011
73
+ hestia_earth/models/cycle/animal/milkYield.py,sha256=QIPa3MJLkX0CUdmeAcA3lFOi0UmXqbG3Z0-uKH8thTM,2371
74
74
  hestia_earth/models/cycle/animal/properties.py,sha256=OGjRl79w-h439jTkjA8b4V61fMuo0McoUs3JrgK-0Zc,596
75
75
  hestia_earth/models/cycle/animal/input/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
76
76
  hestia_earth/models/cycle/animal/input/hestiaAggregatedData.py,sha256=EpJ6qU0jsoSMEuZYIKCn1f-loJ53_nmpnyDhH5sZTuw,2529
@@ -138,8 +138,10 @@ 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=uo489YIEIO1kuVYm6AKDGysLLjxcBchGWGr0jjLOJo4,4426
142
- hestia_earth/models/environmentalFootprintV3/utils.py,sha256=HKz_ckzuMZvo8YL-laApyhiccl2NoJUxHs2npwBCMWw,712
141
+ hestia_earth/models/environmentalFootprintV3/soilQualityIndexLandOccupation.py,sha256=fFYSOjO_G1XPRW0Au7erYj4XSAZkoMN0Lx4DvEziSBo,4514
142
+ hestia_earth/models/environmentalFootprintV3/soilQualityIndexLandTransformation.py,sha256=K0ot5wLo8beAHkBmXEQGPDRykoBoQ0u2ihxLAZWpy6I,7259
143
+ hestia_earth/models/environmentalFootprintV3/soilQualityIndexTotalLandUseEffects.py,sha256=-Lsc2VLtOwFnNqCL7nHKsyLfcSWIgYGs4iMso3AoDk8,2679
144
+ hestia_earth/models/environmentalFootprintV3/utils.py,sha256=fZ99_G0Kh4OUW5wH-LglzCrKp8l2plKuCs4yvUH_3hs,699
143
145
  hestia_earth/models/epa2014/__init__.py,sha256=ckGf_6X7CCzI_18OqchEkuJAXKXM1x7V53u480ckknM,408
144
146
  hestia_earth/models/epa2014/no3ToGroundwaterExcreta.py,sha256=fN4fOOcjBg3tl0lzNeJ8mzg6mrvQRxilx-R5Gc4l4Nw,1724
145
147
  hestia_earth/models/fantkeEtAl2016/__init__.py,sha256=NtOlRmjTA4e8i0nW8erwdm-DDtfYlbLiARqqv82bkU4,415
@@ -203,7 +205,7 @@ hestia_earth/models/hyde32/landTransformationFromOtherNaturalVegetation100YearAv
203
205
  hestia_earth/models/hyde32/landTransformationFromOtherNaturalVegetation20YearAverageDuringCycle.py,sha256=Yi6Jnh4G4hILUoV2fgkDBNzT9Q7BY5wCUHEB-OUejys,2460
204
206
  hestia_earth/models/hyde32/landTransformationFromPermanentPasture100YearAverageDuringCycle.py,sha256=ZkRn4toDe3flLtJG6iptE6cCFEkexVQ4lg2nr779Do8,2442
205
207
  hestia_earth/models/hyde32/landTransformationFromPermanentPasture20YearAverageDuringCycle.py,sha256=wz2YMJ_qG1_2BosqsI6TDKAPqvVE6a3Ejuikz-cv-Z0,2433
206
- hestia_earth/models/hyde32/utils.py,sha256=9HoTiNi52iSopIh0Q_6l7kObr4MPxrBkAvQf6T-zm1U,3383
208
+ hestia_earth/models/hyde32/utils.py,sha256=38iHv9XBkQpvQn0iht22DP35bh9fC5BRmi3YVppEyGo,3505
207
209
  hestia_earth/models/impact_assessment/__init__.py,sha256=gTR_PhWps593fPhm-V826VLLrZVH8CNQTqxExB7GGNI,418
208
210
  hestia_earth/models/impact_assessment/allocationMethod.py,sha256=Qz41nTtMpDCcPy7PjhVtafE13dfJLX_D3Rg3yNhdY_Q,1279
209
211
  hestia_earth/models/impact_assessment/emissions.py,sha256=mJsTasM-5AFtZeKzQ9Q38SDLcnl_lQwfjQ52ro2Pjmg,3444
@@ -247,9 +249,11 @@ hestia_earth/models/ipcc2019/ch4ToAirAquacultureSystems.py,sha256=q6yyEiYQhHJ2Vy
247
249
  hestia_earth/models/ipcc2019/ch4ToAirEntericFermentation.py,sha256=7rA9thwYXbJkSFTEl71AbFVQfBz0CaJfblpJpO9s6D8,11611
248
250
  hestia_earth/models/ipcc2019/ch4ToAirExcreta.py,sha256=eY_yb7ncTb_2HoUUgXZnnRHiybTXYj_DTe3CmDzD3fY,6717
249
251
  hestia_earth/models/ipcc2019/ch4ToAirFloodedRice.py,sha256=TJ4J7VA5n4RPrJYZQeR3lc3ZoCw7T1E5Cb1XJewr834,7331
250
- hestia_earth/models/ipcc2019/co2ToAirCarbonStockChange_utils.py,sha256=n87ghsqDEuZodeJOAHadfS2au4rqB-cuhZoZhrG55dw,32154
252
+ hestia_earth/models/ipcc2019/co2ToAirAboveGroundBiomassStockChangeLandUseChange.py,sha256=Hw7Nd1L2afLWHS0SbJT60m_YefmgR_izIvOf6mw-mxQ,5752
253
+ hestia_earth/models/ipcc2019/co2ToAirBelowGroundBiomassStockChangeLandUseChange.py,sha256=x5dvIQ3QfSrEM-VFIC7_owQr-1aC7T6RXGoc5X-q90k,5803
254
+ hestia_earth/models/ipcc2019/co2ToAirCarbonStockChange_utils.py,sha256=LTISlOz71vTgslkI5c5iqL0lqwDI6rOcwSlNcRMgTxQ,40729
251
255
  hestia_earth/models/ipcc2019/co2ToAirLimeHydrolysis.py,sha256=7z0zdqiiWQwkyJCgSNMoK2mft3cJkTRlqwKrMuSKdWI,2454
252
- hestia_earth/models/ipcc2019/co2ToAirSoilOrganicCarbonStockChangeManagementChange.py,sha256=Fgy67gYS57QIcmbgjwyTYKT8Plh9Xy8_fuW63I6-AmY,8669
256
+ hestia_earth/models/ipcc2019/co2ToAirSoilOrganicCarbonStockChangeManagementChange.py,sha256=QhLVmjFZABdP9uPe5d8X1QLEvhKmrgKW9ywwlDArqY4,5804
253
257
  hestia_earth/models/ipcc2019/co2ToAirUreaHydrolysis.py,sha256=Ofld5SuRKndcKB3FFFoUdzSgNq-gc4kmiNyyrPKQ3Io,3580
254
258
  hestia_earth/models/ipcc2019/croppingDuration.py,sha256=-CesZ2cNDOQoU3QyVFnSWYO-6-JXxuhRDQoHoxTawDA,3228
255
259
  hestia_earth/models/ipcc2019/ligninContent.py,sha256=Qh-UH4lv1TIf7wWlbAPwIZZHxzbbmQgND3m15pt5Si8,7285
@@ -274,13 +278,13 @@ hestia_earth/models/ipcc2019/organicCarbonPerHa.py,sha256=iRUSVxMpBGgsVDkuBABPKI
274
278
  hestia_earth/models/ipcc2019/organicCarbonPerHa_tier_1_utils.py,sha256=d112vbcbKHHoy0q3ncaI3d9dsAPydSEaWbXWupJe1-c,81908
275
279
  hestia_earth/models/ipcc2019/organicCarbonPerHa_tier_2_utils.py,sha256=A84r6u45HFk5jEb2nTWGTFTwX1qjq8F6qwkNUuiyH48,63542
276
280
  hestia_earth/models/ipcc2019/organicCarbonPerHa_utils.py,sha256=HGJC2zcEvtbkovccAZ5MYm84wBXUZH0Q3UyJOXD0ltA,10157
277
- hestia_earth/models/ipcc2019/pastureGrass.py,sha256=w8LMbxJTdZtC2nrWoooPA0jrA9-FIFBZA-dBpGyqAUg,10158
281
+ hestia_earth/models/ipcc2019/pastureGrass.py,sha256=Hhm9szzsL3otuo-V6fQ_cNyDbG0dlubr4-1L4WefbDE,10304
278
282
  hestia_earth/models/ipcc2019/pastureGrass_utils.py,sha256=Bzz4yPDdA7YVUhhJhQCCVu0uKONeO3b6a48_ZITZgzU,13889
279
283
  hestia_earth/models/ipcc2019/utils.py,sha256=MSDMu15D9DnilFUgi4_6jYXC0FaKso3OODauGTMB6hs,6229
280
284
  hestia_earth/models/ipcc2019/animal/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
281
285
  hestia_earth/models/ipcc2019/animal/liveweightGain.py,sha256=Gwd6J6k-W84EAsC_cNMLaNy3p4-2pqCSc3grBfPvanw,2618
282
286
  hestia_earth/models/ipcc2019/animal/liveweightPerHead.py,sha256=Lhnk58SvVtM2FayljOBPHFFx5OBFFqsiaVG8ZjwCaXA,2634
283
- hestia_earth/models/ipcc2019/animal/pastureGrass.py,sha256=edBXCVjJB5ZBGJ9_zE3H6xKpT84hPqe3dv5JF879tXw,12066
287
+ hestia_earth/models/ipcc2019/animal/pastureGrass.py,sha256=4vs-KIlCKQhU1EpX0BFlVAQrh1szm154AnrPDs13oE4,12212
284
288
  hestia_earth/models/ipcc2019/animal/utils.py,sha256=ziyphGLEO_eitOLtBG0BLpJfmN3csqUetFZuDo8FX2U,990
285
289
  hestia_earth/models/ipcc2019/animal/weightAtMaturity.py,sha256=IHrG6cqLVhOiIbrvK0w5xDu4bHmy5om-1qBKMmkFC2o,3376
286
290
  hestia_earth/models/ipcc2021/__init__.py,sha256=VTgGFKhwMmk_nuI1RRq0in27fHYVPBonlXlPK00K8no,409
@@ -395,7 +399,7 @@ hestia_earth/models/linkedImpactAssessment/landTransformationFromPermanentPastur
395
399
  hestia_earth/models/linkedImpactAssessment/utils.py,sha256=dGwGc2d-8_WQElTpfyPmz5vQtL-LHQRmiZnCTuPXMDs,1876
396
400
  hestia_earth/models/mocking/__init__.py,sha256=n3Fkkrvh8zHNWiJZmnfQ7WZ91JRzAO9P6pSG1JpwtXo,687
397
401
  hestia_earth/models/mocking/mock_search.py,sha256=qgABw-sZK37XtsALKt8AHF2VJPUrZSnHv5Qj1Dn93oA,2405
398
- hestia_earth/models/mocking/search-results.json,sha256=wOz1T0GfXcwzzoXZ0QioZ4oL7N5WkZitP7g1fOAQP18,11627
402
+ hestia_earth/models/mocking/search-results.json,sha256=IgD-CYkxGRF8pfPqCwY9jf_mRxK3kgRhXm5W_WSxPsI,55196
399
403
  hestia_earth/models/pooreNemecek2018/__init__.py,sha256=nPboL7ULJzL5nJD5q7q9VOZt_fxbKVm8fmn1Az5YkVY,417
400
404
  hestia_earth/models/pooreNemecek2018/aboveGroundCropResidueTotal.py,sha256=Qt-mel4dkhK6N5uUOutNOinCTFjbjtGzITaaI0LvYc4,2396
401
405
  hestia_earth/models/pooreNemecek2018/belowGroundCropResidue.py,sha256=JT0RybbvWVlo01FO8K0Yj41HrEaJT3Kj1xfayr2X-xw,2315
@@ -403,7 +407,7 @@ hestia_earth/models/pooreNemecek2018/ch4ToAirAquacultureSystems.py,sha256=CxjhFi
403
407
  hestia_earth/models/pooreNemecek2018/excretaKgN.py,sha256=kB4C1mSA9h8uUJXXaf-39ZwhzAmmvapkfA7v0nUN_Qg,6418
404
408
  hestia_earth/models/pooreNemecek2018/excretaKgVs.py,sha256=5rK3wfI8JO2feaFRv23-s9bH09DIl4LLLcjHS3cf-Ow,8424
405
409
  hestia_earth/models/pooreNemecek2018/freshwaterWithdrawalsDuringCycle.py,sha256=HB_9q5eE6al2Te3v29hC5wqxsYe4P46ZAPwdWNzx3v0,3939
406
- hestia_earth/models/pooreNemecek2018/landOccupationDuringCycle.py,sha256=GFOm1T9I_aqnGRS3Rsb7gGFEMn9jB4irtdoNW8SFI6s,3118
410
+ hestia_earth/models/pooreNemecek2018/landOccupationDuringCycle.py,sha256=78N513lNtjol0KKddxmG3Pb9vAmledlrWbfURVdLHBA,3139
407
411
  hestia_earth/models/pooreNemecek2018/longFallowDuration.py,sha256=Wdm6QyOttCFP9Y3OjbaYrvdMmivOmMIT-m5Eg9SM9rY,1511
408
412
  hestia_earth/models/pooreNemecek2018/n2OToAirAquacultureSystemsDirect.py,sha256=HJ7IstImGyasIKosK2lQZ-v6Lqt3_aEfZhoiC4CY0rM,2586
409
413
  hestia_earth/models/pooreNemecek2018/n2ToAirAquacultureSystems.py,sha256=SoZlogDd7_4kq5S9gc8KmVeIXacWWhaUkWlKTuho_OA,2431
@@ -497,7 +501,7 @@ hestia_earth/models/site/brackishWater.py,sha256=vLEhIZv5PUKwzwvIuYrWi7K---fq7ZX
497
501
  hestia_earth/models/site/cationExchangeCapacityPerKgSoil.py,sha256=0eH4A-tXJ0hvIkiYXWxlx8TfrdbIKUGYUDk97-yQJgg,3653
498
502
  hestia_earth/models/site/flowingWater.py,sha256=v3g5722GIA4zQAUQI9yGFiZvFvI1QAVZqlQrY-6_B3A,1731
499
503
  hestia_earth/models/site/freshWater.py,sha256=FXs3Vt8V4e-wn325_dwSTOKlZtn5ksNUpvYGDeLJShY,1255
500
- hestia_earth/models/site/management.py,sha256=FoLQYILOiobB4cJyOWdpG7A4q30TgOs_MGEN67-eqV8,11409
504
+ hestia_earth/models/site/management.py,sha256=lFBqe5eW6O_Wb1JfV-X6J8_lLIeVzn64TvGLfF7flgM,11441
501
505
  hestia_earth/models/site/netPrimaryProduction.py,sha256=UIIQkYd911qVzrWjxBLrC37e-RARIVgDwLdARY9BuLw,1849
502
506
  hestia_earth/models/site/organicCarbonPerHa.py,sha256=F2ShinHf0m9qKa1nCYBspsDkRY6jzOl0wM8mSDre22I,14916
503
507
  hestia_earth/models/site/organicCarbonPerKgSoil.py,sha256=t--wAshiAKS-JvEKhLFRadGvgSBv5NFZ68jdyms_wh4,1945
@@ -578,7 +582,7 @@ hestia_earth/models/utils/fuel.py,sha256=r1MKMMxg-PYiVlRutP83RuvY2rsdCQ1iN6ekSGG
578
582
  hestia_earth/models/utils/impact_assessment.py,sha256=ma2oINLTIL1qplqC5D1_DbQu4EILpMXSgYNEslxIa2Y,7059
579
583
  hestia_earth/models/utils/indicator.py,sha256=IFrVIUYpmdVLOR1SKkrTReDbG1Tzq2b6daVvLMYpCs4,537
580
584
  hestia_earth/models/utils/inorganicFertiliser.py,sha256=_dLBY-otGkLr8PobR5dQ89bF2uwc2PB4JPrHFSksMEQ,1900
581
- hestia_earth/models/utils/input.py,sha256=YycsAbSBfVDMu6PftDsisMFGnEp87wOj-3rrnHnOgzo,4927
585
+ hestia_earth/models/utils/input.py,sha256=gsVFKTC9WF8dO6YAg_-H_GAOQTnvAr49Ox5-eTH8zf8,5145
582
586
  hestia_earth/models/utils/landCover.py,sha256=8-nfynzCx9gf9YfhpuoH6Cn4kQwWFpYA5RmoGW-0ETE,300
583
587
  hestia_earth/models/utils/liveAnimal.py,sha256=GnajBPZw5d94raf80KtLloaOqlfqGAPwUtP9bRlGWeE,1754
584
588
  hestia_earth/models/utils/lookup.py,sha256=2UztS6CHpFEsoERm5kwV3qUtzm0VpZQ4Fnmtceb2o18,7293
@@ -589,7 +593,7 @@ hestia_earth/models/utils/practice.py,sha256=tNadOzsrNlCEt801B815XaruJXzZ5yPASam
589
593
  hestia_earth/models/utils/product.py,sha256=DhDgiReR8k9n9aaRM2xk3PIY3nfoE1ISKg9pKsBVzVQ,10143
590
594
  hestia_earth/models/utils/productivity.py,sha256=rTJX_nemxHpOcPN7jiM2hFHknoLUIW8y-hFxVxIkg70,593
591
595
  hestia_earth/models/utils/property.py,sha256=gBy6FidNDhjzokOXOWcIDBMKcdPPBXxIZgdAxgQsmWc,5127
592
- hestia_earth/models/utils/site.py,sha256=zEj2PtIghk-L_vVJidlXM6_ed7HTc2-ogP0sQSh49vw,3874
596
+ hestia_earth/models/utils/site.py,sha256=MyWh_jhY1XbN2EZRdJsHzNJW0PGQqEC1wAmiie4nQy0,3905
593
597
  hestia_earth/models/utils/source.py,sha256=Y-CcO5Y3q5Hz4A4RdX35C1EUjL9w1NKnOrzVfOWQ7nU,1748
594
598
  hestia_earth/models/utils/stats.py,sha256=-0vvhSDAhp4ZYXD1l6sO2hdok8_HgUM6OjCSYGSTHqU,15291
595
599
  hestia_earth/models/utils/temperature.py,sha256=ljlG4-yCgFFb6LRZweb18cZKLrr7K2mqd4E4Hz_D1f8,476
@@ -670,7 +674,7 @@ tests/models/cycle/test_stockingDensityAnimalHousingAverage.py,sha256=WlnuKxhK_3
670
674
  tests/models/cycle/test_transformations.py,sha256=Ws_8KhNqeHogGFXTQ4qZXQ5Ph2I3ZUaY0yO1itFUHLk,464
671
675
  tests/models/cycle/test_unknownPreSeasonWaterRegime.py,sha256=4JSSpDvBQEQrDoytNVzuIcm9UVio4TzZpZm52iMWBVA,1220
672
676
  tests/models/cycle/animal/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
673
- tests/models/cycle/animal/test_milkYield.py,sha256=e3FX8ikrS7nNeOuy8K7rNLs577odN5xrFohUWQw-tag,1323
677
+ tests/models/cycle/animal/test_milkYield.py,sha256=E6WLhuSRydREyKmqmOuOPB8VH1nwZwUMcUULshIdj7k,873
674
678
  tests/models/cycle/animal/test_properties.py,sha256=ND9ltZQie1xXtQvAzoDUkBYGV_N3rw5D5W-irARvO0s,715
675
679
  tests/models/cycle/animal/input/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
676
680
  tests/models/cycle/animal/input/test_hestiaAggregatedData.py,sha256=19rTpeoktPFMyOSolACMJkSe2p96xLsXAeRVjND0WbY,1229
@@ -725,6 +729,8 @@ tests/models/emepEea2019/test_utils.py,sha256=G6z8tEfWM0OPnUBaFCQgQyEi5-kRF_Dqsq
725
729
  tests/models/environmentalFootprintV3/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
726
730
  tests/models/environmentalFootprintV3/test_freshwaterEcotoxicityPotentialCtue.py,sha256=ZPDKM23qlLMe_ZzeA-QIutSkFlod3BsmjloA9WA8nug,845
727
731
  tests/models/environmentalFootprintV3/test_soilQualityIndexLandOccupation.py,sha256=5cv3R1Zam0aW00smkWNKExgdWomhT9Ad8bCTH8KZCdw,4324
732
+ tests/models/environmentalFootprintV3/test_soilQualityIndexLandTransformation.py,sha256=XgxgTmuc1jZ0l1nmOd3KpIUfW7uY_erCj0GUN7DYmCQ,3564
733
+ tests/models/environmentalFootprintV3/test_soilQualityIndexTotalLandUseEffects.py,sha256=6cIdQ-EpMc3gdvt2PLKxX8nUhN05nUTlNpOm6njQYHY,1949
728
734
  tests/models/epa2014/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
729
735
  tests/models/epa2014/test_no3ToGroundwaterExcreta.py,sha256=ESVz4UURvQfhjGBTxjuAV_bymMBcvGNfLAkYMvNup9U,1217
730
736
  tests/models/fantkeEtAl2016/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -831,9 +837,11 @@ tests/models/ipcc2019/test_ch4ToAirAquacultureSystems.py,sha256=o7bHOS4JkwexRrDh
831
837
  tests/models/ipcc2019/test_ch4ToAirEntericFermentation.py,sha256=3Hv86L4X_Va2mZL4KI-36AV00z-KBbKo0cb2ABg6Rv8,7928
832
838
  tests/models/ipcc2019/test_ch4ToAirExcreta.py,sha256=e58NXmBW2SNVLUqQO9A66Xq6jiGTyhdFZDZk51JApF8,2902
833
839
  tests/models/ipcc2019/test_ch4ToAirFloodedRice.py,sha256=FAp5b45WdX5Ih4yGUOZ4CmVD8smW1Lw1tnulx9AKVBI,1980
834
- tests/models/ipcc2019/test_co2ToAirCarbonStockChange_utils.py,sha256=uet7ue1K1zNtBRd-6uxC20Sxl0DOq_jT0wIMZ6LzBZY,2165
840
+ tests/models/ipcc2019/test_co2ToAirAboveGroundBiomassStockChangeLandUseChange.py,sha256=wqkTiQpKPYy-jLdYEpP4pfp56iDUcx_nCD6x2Woefqw,2988
841
+ tests/models/ipcc2019/test_co2ToAirBelowGroundBiomassStockChangeLandUseChange.py,sha256=LwWdnozxdM8TvfOcXbd3iaUDas0ztl6GnLj7oX84UnM,2912
842
+ tests/models/ipcc2019/test_co2ToAirCarbonStockChange_utils.py,sha256=wCEtrbMl6zef8V-n_Ci_rtlQAlfuKm3khUVltr8eAcc,2173
835
843
  tests/models/ipcc2019/test_co2ToAirLimeHydrolysis.py,sha256=e5iuZ-kQNEVih0ZRgRPWqaUtXcLpfkoU7sQypbqA9_Y,1345
836
- tests/models/ipcc2019/test_co2ToAirSoilOrganicCarbonStockChangeManagementChange.py,sha256=WMWU3INQEy_hzrAP7gG36YeUFUcJaX8Y_JzHCLw4M6s,2852
844
+ tests/models/ipcc2019/test_co2ToAirSoilOrganicCarbonStockChangeManagementChange.py,sha256=C1mK1Zl-541HJD02pSe8uX3h0ZiY64Yfys2_Qnqa7wA,2928
837
845
  tests/models/ipcc2019/test_co2ToAirUreaHydrolysis.py,sha256=MmtEME0xjsa3KojFk_fxOLK6RZM_6p5HIpY2DOFHVu4,1530
838
846
  tests/models/ipcc2019/test_croppingDuration.py,sha256=gLRXeR6Tqa7ciD9KTRfsIflSeIIWT2iOpZMdcxAQla4,1871
839
847
  tests/models/ipcc2019/test_ligninContent.py,sha256=eIKEN__ab-0R52EhlhPSBiHnmTl6xOf1XbI33O-W9A4,4146
@@ -1072,7 +1080,7 @@ tests/models/site/test_brackishWater.py,sha256=YGCp4glaWudKklYBSp-50KbfvIRtp3F4Q
1072
1080
  tests/models/site/test_cationExchangeCapacityPerKgSoil.py,sha256=tNMhN998vcjQ15I-5mNnFh2d7mHzEBIBO6o1VSfQNUE,1075
1073
1081
  tests/models/site/test_flowingWater.py,sha256=t_rxvdlmUVDsFBoDF20_zDM-0iiLKkNCV7knO9l1T7o,1370
1074
1082
  tests/models/site/test_freshWater.py,sha256=GOeAxHhPW_2E1wQdQRX4W-r7mnb_LgmiAVLImitoApw,982
1075
- tests/models/site/test_management.py,sha256=X3yfYTJEdMXtnEXkCizj1XNYBuA7hJSsqwUcEEyjoCY,7178
1083
+ tests/models/site/test_management.py,sha256=hNUCwn-eJhoKBqxjfCRytZipPNqqtJQ41G2kcvJquNs,7229
1076
1084
  tests/models/site/test_netPrimaryProduction.py,sha256=JCxG0MODbKVvl3hOqmKzh4FjHYn3Xs9KsVod6LvKQII,1108
1077
1085
  tests/models/site/test_organicCarbonPerHa.py,sha256=XtGrE7ZqthTF0x8lDxJ1slNd_GvYHEyEydcRgA46jEc,3207
1078
1086
  tests/models/site/test_organicCarbonPerKgSoil.py,sha256=0M-NMg_T3UXzGT_VlKOKhSxg4cZ0_zhd3FRgY5Hpj6o,1087
@@ -1140,7 +1148,7 @@ tests/models/utils/test_emission.py,sha256=3KfhQGV5Vh_WXTPt6McvZ2dBp9TVM7eAUTLgR
1140
1148
  tests/models/utils/test_feedipedia.py,sha256=S7c1W4bJ5xWXPh42pPbl3R7lDX_iEeaEtFaPXgB7hgE,906
1141
1149
  tests/models/utils/test_impact_assessment.py,sha256=qEm4Y5txWnkSJKP1puvwgKFXkv06c7vUKmwDyIJxkdc,1114
1142
1150
  tests/models/utils/test_indicator.py,sha256=GwYKV5N_yEPcJWz7FirRnK48rl62ofAn_TkAo0MioIM,639
1143
- tests/models/utils/test_input.py,sha256=bSG6YKmT2ofY2oD5CGbNwR8-To-ihyNyr14Td5-jNRU,585
1151
+ tests/models/utils/test_input.py,sha256=sxNFToFGPv-OjiM_hZSYx_aSWPuAT575hffQ1NhG3L4,2444
1144
1152
  tests/models/utils/test_liveAnimal.py,sha256=bntT4vULWsDF2DOigtiMjpS0gJS5ipalPsfrk-JxC-I,986
1145
1153
  tests/models/utils/test_lookup.py,sha256=107k7wsqDkxm_HFQ41W6gU1naslx3TXz1yDRQ5OhF10,401
1146
1154
  tests/models/utils/test_measurement.py,sha256=KBJobXlBUOwf2KuUduM1oQSR22JX6Pq0h5e3TRbQn-w,3678
@@ -1154,8 +1162,8 @@ tests/models/utils/test_term.py,sha256=M5Sa26v2gzQYbZ4H_fo7DspnaCx__-WtL-MULGapC
1154
1162
  tests/models/utils/test_time_series.py,sha256=LMhRPf8rp3nAriKAC-2K3FDkrMWntRTUUCERw7Lt68g,2686
1155
1163
  tests/models/webbEtAl2012AndSintermannEtAl2012/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
1156
1164
  tests/models/webbEtAl2012AndSintermannEtAl2012/test_nh3ToAirOrganicFertiliser.py,sha256=qi2FNXS5Af2WDtm7nq_FsprH3BfCF0XxnE0XHmC4aIY,2244
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,,
1165
+ hestia_earth_models-0.64.8.dist-info/LICENSE,sha256=AC7h7GAgCZGJK_Tzh6LUCrML9gQEfowWwecEw2w54QM,1154
1166
+ hestia_earth_models-0.64.8.dist-info/METADATA,sha256=4UYoZURD_6LGH95ysuWrhXju7wQe7L1gXJSFQjRB7Ns,3343
1167
+ hestia_earth_models-0.64.8.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
1168
+ hestia_earth_models-0.64.8.dist-info/top_level.txt,sha256=1dqA9TqpOLTEgpqa-YBsmbCmmNU1y56AtfFGEceZ2A0,19
1169
+ hestia_earth_models-0.64.8.dist-info/RECORD,,
@@ -1,7 +1,6 @@
1
- from unittest.mock import patch
2
1
  import json
3
2
 
4
- from tests.utils import fixtures_path, fake_new_practice
3
+ from tests.utils import fixtures_path
5
4
  from hestia_earth.models.cycle.animal.milkYield import MODEL, MODEL_KEY, run, _should_run
6
5
 
7
6
  class_path = f"hestia_earth.models.{MODEL}.animal.{MODEL_KEY}"
@@ -29,15 +28,3 @@ def test_run():
29
28
 
30
29
  value = run(cycle)
31
30
  assert value == expected
32
-
33
-
34
- @patch(f"{class_path}._new_practice", side_effect=fake_new_practice)
35
- def test_run_with_offspring(*args):
36
- with open(f"{fixtures_folder}/with-offspring/cycle.jsonld", encoding='utf-8') as f:
37
- cycle = json.load(f)
38
-
39
- with open(f"{fixtures_folder}/with-offspring/result.jsonld", encoding='utf-8') as f:
40
- expected = json.load(f)
41
-
42
- value = run(cycle)
43
- assert value == expected
@@ -0,0 +1,113 @@
1
+ import json
2
+ from unittest.mock import patch
3
+
4
+ from hestia_earth.models.environmentalFootprintV3.soilQualityIndexLandTransformation import MODEL, TERM_ID, run, \
5
+ _should_run
6
+ from tests.utils import fixtures_path, fake_new_indicator
7
+
8
+ class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}"
9
+ fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
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
+
18
+ def test_should_run_ocean(*args):
19
+ """
20
+ Should not run if a LandCover has no CF (ocean)
21
+ """
22
+ with open(f"{fixtures_folder}/bad-sites/site-LandCover-has-no-CF.jsonld", encoding='utf-8') as f:
23
+ site = json.load(f)
24
+
25
+ should_run, *args = _should_run(site)
26
+ assert should_run is False
27
+
28
+
29
+ def test_should_run_no_management_entries(*args):
30
+ """
31
+ no management => no run
32
+ """
33
+ with open(f"{fixtures_folder}/bad-sites/site-no-management.jsonld", encoding='utf-8') as f:
34
+ site = json.load(f)
35
+
36
+ should_run, *args = _should_run(site)
37
+ assert should_run is False
38
+
39
+
40
+ def test_should_run_no_sites(*args):
41
+ """
42
+ impact assessment with no site => no run
43
+ """
44
+ with open(f"{fixtures_path}/impact_assessment/emissions/impact-assessment.jsonld", encoding='utf-8') as f:
45
+ site = json.load(f)
46
+
47
+ should_run, *args = _should_run(site)
48
+ assert should_run is False
49
+
50
+
51
+ def test_should_run_no_transformation(*args):
52
+ """
53
+ 1 management with no transformation => no run
54
+ """
55
+ with open(f"{fixtures_folder}/bad-sites/site-no-transformations.jsonld", encoding='utf-8') as f:
56
+ site = json.load(f)
57
+
58
+ should_run, *args = _should_run(site)
59
+ assert should_run is False
60
+
61
+
62
+ @patch(f"{class_path}._indicator", side_effect=fake_rounded_indicator)
63
+ def test_run_in_cycle(*args):
64
+ with open(f"{fixtures_folder}/Italy/site-italy-inside-cycle.jsonld", encoding='utf-8') as f:
65
+ site = json.load(f)
66
+
67
+ with open(f"{fixtures_folder}/Italy/result.jsonld", encoding='utf-8') as f:
68
+ expected = json.load(f)
69
+
70
+ value = run(site)
71
+ assert value == expected
72
+
73
+
74
+ @patch(f"{class_path}._indicator", side_effect=fake_rounded_indicator)
75
+ def test_run_other_sites(*args):
76
+ with open(f"{fixtures_folder}/Italy/site-italy-otherSites.jsonld", encoding='utf-8') as f:
77
+ site = json.load(f)
78
+
79
+ with open(f"{fixtures_folder}/Italy/result-otherSites.jsonld", encoding='utf-8') as f:
80
+ expected = json.load(f)
81
+
82
+ value = run(site)
83
+ assert value == expected
84
+
85
+
86
+ @patch(f"{class_path}._indicator", side_effect=fake_rounded_indicator)
87
+ def test_run_with_region(*args):
88
+ """
89
+ When given valid sub-region or country not in the lookup file should default to 'region-world'
90
+ """
91
+ with open(f"{fixtures_folder}/region-world/region-europe.jsonld", encoding='utf-8') as f:
92
+ site = json.load(f)
93
+
94
+ with open(f"{fixtures_folder}/region-world/result-default-region-world.jsonld", encoding='utf-8') as f:
95
+ expected = json.load(f)
96
+
97
+ value = run(site)
98
+ assert value == expected
99
+
100
+
101
+ @patch(f"{class_path}._indicator", side_effect=fake_rounded_indicator)
102
+ def test_run_with_no_region(*args):
103
+ """
104
+ When no location is specified, defaults to region world.
105
+ """
106
+ with open(f"{fixtures_folder}/region-world/no-region.jsonld", encoding='utf-8') as f:
107
+ site = json.load(f)
108
+
109
+ with open(f"{fixtures_folder}/region-world/result-default-region-world.jsonld", encoding='utf-8') as f:
110
+ expected = json.load(f)
111
+
112
+ value = run(site)
113
+ assert value == expected
@@ -0,0 +1,50 @@
1
+ import json
2
+ from unittest.mock import patch
3
+
4
+ from pytest import mark
5
+
6
+ from hestia_earth.models.environmentalFootprintV3.soilQualityIndexTotalLandUseEffects import MODEL, TERM_ID, run, \
7
+ _should_run
8
+ from tests.utils import fixtures_path, fake_new_indicator
9
+
10
+ class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}"
11
+ fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
12
+
13
+ transform_indicator = {'term': {'@id': 'soilQualityIndexLandTransformation'}, 'value': 10}
14
+ occupation_indicator = {'term': {'@id': 'soilQualityIndexLandOccupation'}, 'value': 10}
15
+ missing_value_indicator = {'term': {'@id': 'soilQualityIndexLandOccupation'}}
16
+ bad_value_indicator = {'term': {'@id': 'soilQualityIndexLandOccupation'}, 'value': "42"}
17
+
18
+
19
+ @mark.parametrize(
20
+ "emissions_resource_use, expected",
21
+ [
22
+ ([], False),
23
+ ([transform_indicator], False),
24
+ ([transform_indicator, transform_indicator], False),
25
+ ([transform_indicator, missing_value_indicator], False),
26
+ ([transform_indicator, bad_value_indicator], False),
27
+ ([transform_indicator, occupation_indicator], True),
28
+ ],
29
+ ids=["Empty", "missing entry", "duplicate entry", "no value in entry", "bad value in entry", "correct assessment"]
30
+ )
31
+ def test_should_run(emissions_resource_use, expected):
32
+ with open(f"{fixtures_folder}/impactassessment.jsonld", encoding='utf-8') as f:
33
+ impactassessment = json.load(f)
34
+
35
+ impactassessment['emissionsResourceUse'] = emissions_resource_use
36
+
37
+ should_run, *args = _should_run(impactassessment)
38
+ assert should_run is expected
39
+
40
+
41
+ @patch(f"{class_path}._new_indicator", side_effect=fake_new_indicator)
42
+ def test_run(*args):
43
+ with open(f"{fixtures_folder}/impactassessment.jsonld", encoding='utf-8') as f:
44
+ impactassessment = json.load(f)
45
+
46
+ with open(f"{fixtures_folder}/result.jsonld", encoding='utf-8') as f:
47
+ expected = json.load(f)
48
+
49
+ value = run(impactassessment)
50
+ assert value == expected
@@ -0,0 +1,83 @@
1
+ from functools import reduce
2
+ import json
3
+ from os.path import isfile
4
+ from pytest import mark
5
+ from unittest.mock import patch
6
+
7
+ from hestia_earth.models.ipcc2019.co2ToAirAboveGroundBiomassStockChangeLandUseChange import MODEL, run, TERM_ID
8
+
9
+ from tests.utils import fake_new_emission, fixtures_path
10
+
11
+ class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}"
12
+ utils_path = f"hestia_earth.models.{MODEL}.co2ToAirCarbonStockChange_utils"
13
+ fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
14
+
15
+ RUN_SCENARIOS = [
16
+ ("no-overlapping-cycles", 3),
17
+ ("overlapping-cycles", 4),
18
+ ("complex-overlapping-cycles", 5),
19
+ ("missing-measurement-dates", 3),
20
+ ("no-biomass-measurements", 1), # Closes issue #700
21
+ ("non-consecutive-biomass-measurements", 1), # Closes issue #827
22
+ ("multiple-method-classifications", 5), # Closes issue #764
23
+ ("non-soil-based-gohac-system", 3), # Closes issue #848
24
+ ("soil-based-gohac-system", 3) # Closes issue #848
25
+ ]
26
+ """List of (subfolder: str, num_cycles: int)."""
27
+
28
+
29
+ def _load_fixture(path: str, default=None):
30
+ if isfile(path):
31
+ with open(path, encoding="utf-8") as f:
32
+ return json.load(f)
33
+ return default
34
+
35
+
36
+ RUN_PARAMS = reduce(
37
+ lambda params, scenario: params + [(scenario[0], scenario[1], i) for i in range(scenario[1])],
38
+ RUN_SCENARIOS,
39
+ list()
40
+ )
41
+ """List of (subfolder: str, num_cycles: int, cycle_index: int)."""
42
+
43
+ RUN_IDS = [f"{param[0]}, cycle{param[2]}" for param in RUN_PARAMS]
44
+
45
+
46
+ @mark.parametrize("subfolder, num_cycles, cycle_index", RUN_PARAMS, ids=RUN_IDS)
47
+ @patch(f"{class_path}._new_emission", side_effect=fake_new_emission)
48
+ @patch(f"{utils_path}.related_cycles")
49
+ @patch(f"{utils_path}._get_site") # TODO: rationalise order of patches
50
+ def test_run(_get_site_mock, related_cycles_mock, _new_emission_mock, subfolder, num_cycles, cycle_index):
51
+ """
52
+ Test `run` function for each cycle in each scenario.
53
+ """
54
+ site = _load_fixture(f"{fixtures_folder}/{subfolder}/site.jsonld")
55
+ cycle = _load_fixture(f"{fixtures_folder}/{subfolder}/cycle{cycle_index}.jsonld")
56
+ expected = _load_fixture(f"{fixtures_folder}/{subfolder}/result{cycle_index}.jsonld", default=[])
57
+
58
+ cycles = [
59
+ _load_fixture(f"{fixtures_folder}/{subfolder}/cycle{i}.jsonld") for i in range(num_cycles)
60
+ ]
61
+
62
+ _get_site_mock.return_value = site
63
+ related_cycles_mock.return_value = cycles
64
+
65
+ result = run(cycle)
66
+ assert result == expected
67
+
68
+
69
+ @patch(f"{class_path}._new_emission", side_effect=fake_new_emission)
70
+ @patch(f"{utils_path}.related_cycles")
71
+ @patch(f"{utils_path}._get_site") # TODO: rationalise order of patches
72
+ def test_run_empty(_get_site_mock, related_cycles_mock, _new_emission_mock):
73
+ """
74
+ Test `run` function for each cycle in each scenario.
75
+ """
76
+ CYCLE = {}
77
+ EXPECTED = []
78
+
79
+ _get_site_mock.return_value = {}
80
+ related_cycles_mock.return_value = [CYCLE]
81
+
82
+ result = run(CYCLE)
83
+ assert result == EXPECTED
@@ -0,0 +1,83 @@
1
+ from functools import reduce
2
+ import json
3
+ from os.path import isfile
4
+ from pytest import mark
5
+ from unittest.mock import patch
6
+
7
+ from hestia_earth.models.ipcc2019.co2ToAirBelowGroundBiomassStockChangeLandUseChange import MODEL, run, TERM_ID
8
+
9
+ from tests.utils import fake_new_emission, fixtures_path
10
+
11
+ class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}"
12
+ utils_path = f"hestia_earth.models.{MODEL}.co2ToAirCarbonStockChange_utils"
13
+ fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
14
+
15
+ RUN_SCENARIOS = [
16
+ ("no-overlapping-cycles", 3),
17
+ ("overlapping-cycles", 4),
18
+ ("complex-overlapping-cycles", 5),
19
+ ("missing-measurement-dates", 3),
20
+ ("no-biomass-measurements", 1), # Closes issue #700
21
+ ("non-consecutive-biomass-measurements", 1), # Closes issue #827
22
+ ("multiple-method-classifications", 5), # Closes issue #764
23
+ ("non-soil-based-gohac-system", 3), # Closes issue #848
24
+ ("soil-based-gohac-system", 3) # Closes issue #848
25
+ ]
26
+ """List of (subfolder: str, num_cycles: int)."""
27
+
28
+
29
+ def _load_fixture(path: str, default=None):
30
+ if isfile(path):
31
+ with open(path, encoding="utf-8") as f:
32
+ return json.load(f)
33
+ return default
34
+
35
+
36
+ RUN_PARAMS = reduce(
37
+ lambda params, scenario: params + [(scenario[0], scenario[1], i) for i in range(scenario[1])],
38
+ RUN_SCENARIOS,
39
+ list()
40
+ )
41
+ """List of (subfolder: str, num_cycles: int, cycle_index: int)."""
42
+
43
+ RUN_IDS = [f"{param[0]}, cycle{param[2]}" for param in RUN_PARAMS]
44
+
45
+
46
+ @mark.parametrize("subfolder, num_cycles, cycle_index", RUN_PARAMS, ids=RUN_IDS)
47
+ @patch(f"{class_path}._new_emission", side_effect=fake_new_emission)
48
+ @patch(f"{utils_path}.related_cycles")
49
+ @patch(f"{utils_path}._get_site")
50
+ def test_run(_get_site_mock, related_cycles_mock, _new_emission_mock, subfolder, num_cycles, cycle_index):
51
+ """
52
+ Test `run` function for each cycle in each scenario.
53
+ """
54
+ site = _load_fixture(f"{fixtures_folder}/{subfolder}/site.jsonld")
55
+ cycle = _load_fixture(f"{fixtures_folder}/{subfolder}/cycle{cycle_index}.jsonld")
56
+ expected = _load_fixture(f"{fixtures_folder}/{subfolder}/result{cycle_index}.jsonld", default=[])
57
+
58
+ cycles = [
59
+ _load_fixture(f"{fixtures_folder}/{subfolder}/cycle{i}.jsonld") for i in range(num_cycles)
60
+ ]
61
+
62
+ _get_site_mock.return_value = site
63
+ related_cycles_mock.return_value = cycles
64
+
65
+ result = run(cycle)
66
+ assert result == expected
67
+
68
+
69
+ @patch(f"{class_path}._new_emission", side_effect=fake_new_emission)
70
+ @patch(f"{utils_path}.related_cycles")
71
+ @patch(f"{utils_path}._get_site")
72
+ def test_run_empty(_get_site_mock, related_cycles_mock, _new_emission_mock):
73
+ """
74
+ Test `run` function for each cycle in each scenario.
75
+ """
76
+ CYCLE = {}
77
+ EXPECTED = []
78
+
79
+ _get_site_mock.return_value = {}
80
+ related_cycles_mock.return_value = [CYCLE]
81
+
82
+ result = run(CYCLE)
83
+ assert result == EXPECTED