hestia-earth-models 0.70.1__py3-none-any.whl → 0.70.3__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 (49) hide show
  1. hestia_earth/models/cml2001Baseline/resourceUseMineralsAndMetalsDuringCycle.py +2 -1
  2. hestia_earth/models/config/Cycle.json +68 -0
  3. hestia_earth/models/config/Site.json +8 -0
  4. hestia_earth/models/cycle/practice/landCover.py +181 -0
  5. hestia_earth/models/emepEea2019/nh3ToAirExcreta.py +1 -1
  6. hestia_earth/models/hestia/excretaKgMass.py +1 -1
  7. hestia_earth/models/hestia/management.py +15 -113
  8. hestia_earth/models/hestia/pToSurfaceWaterAquacultureSystems.py +148 -0
  9. hestia_earth/models/hestia/soilMeasurement.py +1 -1
  10. hestia_earth/models/ipcc2019/ch4ToAirFloodedRice.py +8 -6
  11. hestia_earth/models/ipcc2019/ch4ToAirOrganicSoilCultivation.py +270 -0
  12. hestia_earth/models/ipcc2019/co2ToAirAboveGroundBiomassStockChange.py +0 -3
  13. hestia_earth/models/ipcc2019/co2ToAirBelowGroundBiomassStockChange.py +0 -3
  14. hestia_earth/models/ipcc2019/co2ToAirCarbonStockChange_utils.py +57 -43
  15. hestia_earth/models/ipcc2019/co2ToAirLimeHydrolysis.py +7 -5
  16. hestia_earth/models/ipcc2019/co2ToAirOrganicSoilCultivation.py +215 -0
  17. hestia_earth/models/ipcc2019/co2ToAirSoilOrganicCarbonStockChange.py +0 -3
  18. hestia_earth/models/ipcc2019/n2OToAirOrganicSoilCultivationDirect.py +161 -0
  19. hestia_earth/models/ipcc2019/no3ToGroundwaterExcreta.py +1 -1
  20. hestia_earth/models/ipcc2019/organicCarbonPerHa_tier_2.py +15 -4
  21. hestia_earth/models/ipcc2019/organicSoilCultivation_utils.py +159 -0
  22. hestia_earth/models/mocking/search-results.json +713 -705
  23. hestia_earth/models/pooreNemecek2018/excretaKgN.py +3 -1
  24. hestia_earth/models/site/grouped_measurement.py +132 -0
  25. hestia_earth/models/utils/__init__.py +4 -3
  26. hestia_earth/models/utils/blank_node.py +40 -11
  27. hestia_earth/models/utils/constant.py +26 -20
  28. hestia_earth/models/utils/excretaManagement.py +2 -2
  29. hestia_earth/models/utils/product.py +39 -1
  30. hestia_earth/models/utils/property.py +25 -12
  31. hestia_earth/models/version.py +1 -1
  32. {hestia_earth_models-0.70.1.dist-info → hestia_earth_models-0.70.3.dist-info}/METADATA +2 -2
  33. {hestia_earth_models-0.70.1.dist-info → hestia_earth_models-0.70.3.dist-info}/RECORD +49 -36
  34. tests/models/cycle/practice/test_landCover.py +27 -0
  35. tests/models/hestia/test_feedConversionRatio.py +2 -3
  36. tests/models/hestia/test_pToSurfaceWaterAquacultureSystems.py +56 -0
  37. tests/models/hestia/test_soilMeasurement.py +11 -19
  38. tests/models/ipcc2019/test_ch4ToAirEntericFermentation.py +4 -7
  39. tests/models/ipcc2019/test_ch4ToAirOrganicSoilCultivation.py +61 -0
  40. tests/models/ipcc2019/test_co2ToAirAboveGroundBiomassStockChange.py +11 -9
  41. tests/models/ipcc2019/test_co2ToAirBelowGroundBiomassStockChange.py +10 -8
  42. tests/models/ipcc2019/test_co2ToAirLimeHydrolysis.py +1 -1
  43. tests/models/ipcc2019/test_co2ToAirOrganicSoilCultivation.py +62 -0
  44. tests/models/ipcc2019/test_co2ToAirSoilOrganicCarbonStockChange.py +11 -9
  45. tests/models/ipcc2019/test_n2OToAirOrganicSoilCultivationDirect.py +61 -0
  46. tests/models/site/test_grouped_measurement.py +20 -0
  47. {hestia_earth_models-0.70.1.dist-info → hestia_earth_models-0.70.3.dist-info}/LICENSE +0 -0
  48. {hestia_earth_models-0.70.1.dist-info → hestia_earth_models-0.70.3.dist-info}/WHEEL +0 -0
  49. {hestia_earth_models-0.70.1.dist-info → hestia_earth_models-0.70.3.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,62 @@
1
+ import json
2
+ from pytest import mark
3
+ from unittest.mock import MagicMock, patch
4
+
5
+ from hestia_earth.models.ipcc2019.co2ToAirOrganicSoilCultivation 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
+
12
+ # subfolder, should_run
13
+ PARAMS_SHOULD_RUN = [
14
+ ("acacia", True),
15
+ ("annual-crops", True),
16
+ ("grassland", True),
17
+ ("oil-palm", True),
18
+ ("other", False),
19
+ ("paddy-rice-cultivation", True),
20
+ ("perennial-crops", True),
21
+ ("sago-palm", True),
22
+ ("polar", False),
23
+ ("mineral-soil", True),
24
+ ("unknown-soil", False),
25
+ ("unknown-land-occupation", False)
26
+ ]
27
+ IDS_SHOULD_RUN = [p[0] for p in PARAMS_SHOULD_RUN]
28
+
29
+
30
+ @mark.parametrize("subfolder, expected", PARAMS_SHOULD_RUN, ids=IDS_SHOULD_RUN)
31
+ def test_should_run(
32
+ subfolder: str,
33
+ expected: bool
34
+ ):
35
+ folder = f"{fixtures_folder}/{subfolder}"
36
+
37
+ with open(f"{folder}/cycle.jsonld", encoding="utf-8") as f:
38
+ cycle = json.load(f)
39
+
40
+ result, *_ = _should_run(cycle)
41
+ assert result == expected
42
+
43
+
44
+ PARAMS_RUN = [subfolder for subfolder, should_run in PARAMS_SHOULD_RUN if should_run]
45
+
46
+
47
+ @mark.parametrize("subfolder", PARAMS_RUN)
48
+ @patch(f"{class_path}._new_emission", side_effect=fake_new_emission)
49
+ def test_run(
50
+ _mock_new_emission: MagicMock,
51
+ subfolder: str,
52
+ ):
53
+ folder = f"{fixtures_folder}/{subfolder}"
54
+
55
+ with open(f"{folder}/cycle.jsonld", encoding="utf-8") as f:
56
+ cycle = json.load(f)
57
+
58
+ with open(f"{folder}/result.jsonld", encoding="utf-8") as f:
59
+ expected = json.load(f)
60
+
61
+ result = run(cycle)
62
+ assert result == expected
@@ -59,15 +59,17 @@ RUN_SCENARIOS = [
59
59
  ("overlapping-cycles", 4),
60
60
  ("complex-overlapping-cycles", 5),
61
61
  ("missing-measurement-dates", 3),
62
- ("no-organic-carbon-measurements", 1), # Closes issue #700
63
- ("non-consecutive-organic-carbon-measurements", 1), # Closes issue #827
64
- ("multiple-method-classifications", 5), # Closes issue #764
65
- ("non-soil-based-gohac-system", 3), # Closes issue #848
66
- ("with-gapfilled-start-date-end-date", 1), # Closes issue #972
67
- ("forest-to-orchard-with-ground-cover", 3), # Closes issue #989
68
- ("orchard-data-complete", 3), # Closes issue #1011
69
- ("orchard-data-partially-complete", 3), # Closes issue #1011
70
- ("with-linalgerror", 1)
62
+ ("no-organic-carbon-measurements", 1), # Closes #700
63
+ ("non-consecutive-organic-carbon-measurements", 1), # Closes #827
64
+ ("multiple-method-classifications", 5), # Closes #764
65
+ ("non-soil-based-gohac-system", 3), # Closes #848
66
+ ("with-gapfilled-start-date-end-date", 1), # Closes #972
67
+ ("forest-to-orchard-with-ground-cover", 3), # Closes #989
68
+ ("orchard-data-complete", 3), # Closes #1011
69
+ ("orchard-data-partially-complete", 3), # Closes #1011
70
+ ("with-linalgerror", 1),
71
+ ("no-measurements-data-complete", 1), # Closes #1227
72
+ ("no-measurements-data-incomplete", 1) # Closes #1227
71
73
  ]
72
74
  """List of (subfolder: str, num_cycles: int)."""
73
75
 
@@ -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