hestia-earth-models 0.70.1__py3-none-any.whl → 0.70.2__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.
Files changed (42) hide show
  1. hestia_earth/models/cml2001Baseline/resourceUseMineralsAndMetalsDuringCycle.py +2 -1
  2. hestia_earth/models/config/Cycle.json +60 -0
  3. hestia_earth/models/config/Site.json +8 -0
  4. hestia_earth/models/hestia/excretaKgMass.py +1 -1
  5. hestia_earth/models/hestia/management.py +4 -6
  6. hestia_earth/models/hestia/pToSurfaceWaterAquacultureSystems.py +148 -0
  7. hestia_earth/models/hestia/soilMeasurement.py +1 -1
  8. hestia_earth/models/ipcc2019/ch4ToAirFloodedRice.py +8 -6
  9. hestia_earth/models/ipcc2019/ch4ToAirOrganicSoilCultivation.py +270 -0
  10. hestia_earth/models/ipcc2019/co2ToAirAboveGroundBiomassStockChange.py +0 -3
  11. hestia_earth/models/ipcc2019/co2ToAirBelowGroundBiomassStockChange.py +0 -3
  12. hestia_earth/models/ipcc2019/co2ToAirCarbonStockChange_utils.py +57 -43
  13. hestia_earth/models/ipcc2019/co2ToAirLimeHydrolysis.py +7 -5
  14. hestia_earth/models/ipcc2019/co2ToAirOrganicSoilCultivation.py +215 -0
  15. hestia_earth/models/ipcc2019/co2ToAirSoilOrganicCarbonStockChange.py +0 -3
  16. hestia_earth/models/ipcc2019/n2OToAirOrganicSoilCultivationDirect.py +161 -0
  17. hestia_earth/models/ipcc2019/organicSoilCultivation_utils.py +159 -0
  18. hestia_earth/models/mocking/search-results.json +714 -706
  19. hestia_earth/models/site/grouped_measurement.py +132 -0
  20. hestia_earth/models/utils/__init__.py +4 -3
  21. hestia_earth/models/utils/blank_node.py +38 -9
  22. hestia_earth/models/utils/constant.py +26 -20
  23. hestia_earth/models/utils/product.py +39 -1
  24. hestia_earth/models/utils/property.py +14 -6
  25. hestia_earth/models/version.py +1 -1
  26. {hestia_earth_models-0.70.1.dist-info → hestia_earth_models-0.70.2.dist-info}/METADATA +1 -1
  27. {hestia_earth_models-0.70.1.dist-info → hestia_earth_models-0.70.2.dist-info}/RECORD +42 -31
  28. tests/models/hestia/test_feedConversionRatio.py +2 -3
  29. tests/models/hestia/test_pToSurfaceWaterAquacultureSystems.py +56 -0
  30. tests/models/hestia/test_soilMeasurement.py +11 -19
  31. tests/models/ipcc2019/test_ch4ToAirEntericFermentation.py +2 -5
  32. tests/models/ipcc2019/test_ch4ToAirOrganicSoilCultivation.py +61 -0
  33. tests/models/ipcc2019/test_co2ToAirAboveGroundBiomassStockChange.py +11 -9
  34. tests/models/ipcc2019/test_co2ToAirBelowGroundBiomassStockChange.py +10 -8
  35. tests/models/ipcc2019/test_co2ToAirLimeHydrolysis.py +1 -1
  36. tests/models/ipcc2019/test_co2ToAirOrganicSoilCultivation.py +62 -0
  37. tests/models/ipcc2019/test_co2ToAirSoilOrganicCarbonStockChange.py +11 -9
  38. tests/models/ipcc2019/test_n2OToAirOrganicSoilCultivationDirect.py +61 -0
  39. tests/models/site/test_grouped_measurement.py +20 -0
  40. {hestia_earth_models-0.70.1.dist-info → hestia_earth_models-0.70.2.dist-info}/LICENSE +0 -0
  41. {hestia_earth_models-0.70.1.dist-info → hestia_earth_models-0.70.2.dist-info}/WHEEL +0 -0
  42. {hestia_earth_models-0.70.1.dist-info → hestia_earth_models-0.70.2.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,61 @@
1
+ import json
2
+ from pytest import mark
3
+ from unittest.mock import MagicMock, patch
4
+
5
+ from hestia_earth.models.ipcc2019.n2OToAirOrganicSoilCultivationDirect import MODEL, TERM_ID, _should_run, run
6
+ from tests.utils import fake_new_emission, fixtures_path
7
+
8
+ class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}"
9
+ fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
10
+
11
+ # subfolder, should_run
12
+ PARAMS_SHOULD_RUN = [
13
+ ("acacia", True),
14
+ ("annual-crops", True),
15
+ ("grassland", True),
16
+ ("oil-palm", True),
17
+ ("other", False),
18
+ ("paddy-rice-cultivation", True),
19
+ ("perennial-crops", True),
20
+ ("sago-palm", True),
21
+ ("polar", False),
22
+ ("mineral-soil", True),
23
+ ("unknown-soil", False),
24
+ ("unknown-land-occupation", False)
25
+ ]
26
+ IDS_SHOULD_RUN = [p[0] for p in PARAMS_SHOULD_RUN]
27
+
28
+
29
+ @mark.parametrize("subfolder, expected", PARAMS_SHOULD_RUN, ids=IDS_SHOULD_RUN)
30
+ def test_should_run(
31
+ subfolder: str,
32
+ expected: bool
33
+ ):
34
+ folder = f"{fixtures_folder}/{subfolder}"
35
+
36
+ with open(f"{folder}/cycle.jsonld", encoding="utf-8") as f:
37
+ cycle = json.load(f)
38
+
39
+ result, *_ = _should_run(cycle)
40
+ assert result == expected
41
+
42
+
43
+ PARAMS_RUN = [subfolder for subfolder, should_run in PARAMS_SHOULD_RUN if should_run]
44
+
45
+
46
+ @mark.parametrize("subfolder", PARAMS_RUN,)
47
+ @patch(f"{class_path}._new_emission", side_effect=fake_new_emission)
48
+ def test_run(
49
+ _mock_new_emission: MagicMock,
50
+ subfolder: str
51
+ ):
52
+ folder = f"{fixtures_folder}/{subfolder}"
53
+
54
+ with open(f"{folder}/cycle.jsonld", encoding="utf-8") as f:
55
+ cycle = json.load(f)
56
+
57
+ with open(f"{folder}/result.jsonld", encoding="utf-8") as f:
58
+ expected = json.load(f)
59
+
60
+ result = run(cycle)
61
+ assert result == expected
@@ -0,0 +1,20 @@
1
+ import json
2
+ from unittest.mock import patch
3
+ from tests.utils import fixtures_path, fake_new_measurement
4
+
5
+ from hestia_earth.models.site.grouped_measurement import MODEL, MODEL_KEY, run
6
+
7
+ class_path = f"hestia_earth.models.{MODEL}.{MODEL_KEY}"
8
+ fixtures_folder = f"{fixtures_path}/{MODEL}/{MODEL_KEY}"
9
+
10
+
11
+ @patch(f"{class_path}._new_measurement", side_effect=fake_new_measurement)
12
+ def test_run(*args):
13
+ with open(f"{fixtures_folder}/site.jsonld", encoding='utf-8') as f:
14
+ site = json.load(f)
15
+
16
+ with open(f"{fixtures_folder}/result.jsonld", encoding='utf-8') as f:
17
+ expected = json.load(f)
18
+
19
+ result = run(site)
20
+ assert result == expected