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
@@ -1,8 +1,8 @@
1
1
  from hestia_earth.schema import EmissionMethodTier, MeasurementMethodClassification
2
2
 
3
3
  from hestia_earth.models.ipcc2019.co2ToAirCarbonStockChange_utils import (
4
- add_carbon_stock_change_emissions, calc_carbon_stock_change, calc_carbon_stock_change_emission, _convert_c_to_co2,
5
- lerp_carbon_stocks, CarbonStock, CarbonStockChange, CarbonStockChangeEmission
4
+ _add_carbon_stock_change_emissions, _calc_carbon_stock_change, _calc_carbon_stock_change_emission,
5
+ _convert_c_to_co2, _lerp_carbon_stocks, CarbonStock, CarbonStockChange, CarbonStockChangeEmission
6
6
  )
7
7
 
8
8
 
@@ -20,7 +20,7 @@ def test_lerp_carbon_stocks():
20
20
  21000, "2001-12-31", MeasurementMethodClassification.ON_SITE_PHYSICAL_MEASUREMENT
21
21
  )
22
22
 
23
- result = lerp_carbon_stocks(START, END, TARGET_DATE)
23
+ result = _lerp_carbon_stocks(START, END, TARGET_DATE)
24
24
  assert result == EXPECTED
25
25
 
26
26
 
@@ -29,7 +29,7 @@ def test_calc_carbon_stock_change():
29
29
  END = CarbonStock(21000, "2001", MeasurementMethodClassification.TIER_1_MODEL)
30
30
  EXPECTED = CarbonStockChange(1000, "2000", "2001", MeasurementMethodClassification.TIER_1_MODEL)
31
31
 
32
- result = calc_carbon_stock_change(START, END)
32
+ result = _calc_carbon_stock_change(START, END)
33
33
  assert result == EXPECTED
34
34
 
35
35
 
@@ -37,7 +37,7 @@ def test_calc_carbon_stock_change_emission():
37
37
  SOC_STOCK_CHANGE = CarbonStockChange(-1000, "2000", "2001", MeasurementMethodClassification.TIER_1_MODEL)
38
38
  EXPECTED = CarbonStockChangeEmission(3663.836163836164, "2000", "2001", EmissionMethodTier.TIER_1)
39
39
 
40
- result = calc_carbon_stock_change_emission(SOC_STOCK_CHANGE)
40
+ result = _calc_carbon_stock_change_emission(SOC_STOCK_CHANGE)
41
41
  assert result == EXPECTED
42
42
 
43
43
 
@@ -46,5 +46,5 @@ def test_add_carbon_stock_change_emissions():
46
46
  EMISSION_2 = CarbonStockChangeEmission(2000, "2001", "2002", EmissionMethodTier.TIER_1)
47
47
  EXPECTED = CarbonStockChangeEmission(5000, "2000", "2002", EmissionMethodTier.TIER_1)
48
48
 
49
- result = add_carbon_stock_change_emissions(EMISSION_1, EMISSION_2)
49
+ result = _add_carbon_stock_change_emissions(EMISSION_1, EMISSION_2)
50
50
  assert result == EXPECTED
@@ -9,6 +9,7 @@ from hestia_earth.models.ipcc2019.co2ToAirSoilOrganicCarbonStockChangeManagement
9
9
  from tests.utils import fake_new_emission, fixtures_path
10
10
 
11
11
  class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}"
12
+ utils_path = f"hestia_earth.models.{MODEL}.co2ToAirCarbonStockChange_utils"
12
13
  fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
13
14
 
14
15
  RUN_SCENARIOS = [
@@ -44,8 +45,8 @@ RUN_IDS = [f"{param[0]}, cycle{param[2]}" for param in RUN_PARAMS]
44
45
 
45
46
  @mark.parametrize("subfolder, num_cycles, cycle_index", RUN_PARAMS, ids=RUN_IDS)
46
47
  @patch(f"{class_path}._new_emission", side_effect=fake_new_emission)
47
- @patch(f"{class_path}.related_cycles")
48
- @patch(f"{class_path}._get_site")
48
+ @patch(f"{utils_path}.related_cycles")
49
+ @patch(f"{utils_path}._get_site")
49
50
  def test_run(_get_site_mock, related_cycles_mock, _new_emission_mock, subfolder, num_cycles, cycle_index):
50
51
  """
51
52
  Test `run` function for each cycle in each scenario.
@@ -66,8 +67,8 @@ def test_run(_get_site_mock, related_cycles_mock, _new_emission_mock, subfolder,
66
67
 
67
68
 
68
69
  @patch(f"{class_path}._new_emission", side_effect=fake_new_emission)
69
- @patch(f"{class_path}.related_cycles")
70
- @patch(f"{class_path}._get_site")
70
+ @patch(f"{utils_path}.related_cycles")
71
+ @patch(f"{utils_path}._get_site")
71
72
  def test_run_empty(_get_site_mock, related_cycles_mock, _new_emission_mock):
72
73
  """
73
74
  Test `run` function for each cycle in each scenario.
@@ -25,7 +25,10 @@ TERM_BY_ID = {
25
25
  }
26
26
  }
27
27
 
28
- LAND_COVER_TERM_BY_SITE_TYPE = {SiteSiteType.ANIMAL_HOUSING.value: "animalHousing"}
28
+ LAND_COVER_TERM_BY_SITE_TYPE = {
29
+ SiteSiteType.ANIMAL_HOUSING.value: "animalHousing",
30
+ SiteSiteType.CROPLAND.value: "cropland"
31
+ }
29
32
 
30
33
 
31
34
  def lookup_side_effect(*args, **kwargs):
@@ -1,7 +1,9 @@
1
+ import pytest
1
2
  from unittest.mock import patch
3
+ from hestia_earth.schema import TermTermType
2
4
  from tests.utils import TERM
3
5
 
4
- from hestia_earth.models.utils.input import _new_input
6
+ from hestia_earth.models.utils.input import _new_input, get_feed_inputs
5
7
 
6
8
  class_path = 'hestia_earth.models.utils.input'
7
9
 
@@ -22,3 +24,65 @@ def test_new_input(*args):
22
24
  '@type': 'Input',
23
25
  'term': TERM
24
26
  }
27
+
28
+
29
+ @pytest.mark.parametrize(
30
+ 'test_name,cycle,expected_input_length',
31
+ [
32
+ (
33
+ 'no inputs',
34
+ {},
35
+ 0
36
+ ),
37
+ (
38
+ 'with crop feed',
39
+ {
40
+ 'inputs': [{
41
+ 'term': {'units': 'kg', 'termType': TermTermType.CROP.value, '@id': 'wheatGrain'},
42
+ 'isAnimalFeed': True,
43
+ 'value': [10]
44
+ }]
45
+ },
46
+ 1
47
+ ),
48
+ (
49
+ 'with crop no feed',
50
+ {
51
+ 'inputs': [{
52
+ 'term': {'units': 'kg', 'termType': TermTermType.CROP.value, '@id': 'wheatGrain'},
53
+ 'isAnimalFeed': False,
54
+ 'value': [10]
55
+ }]
56
+ },
57
+ 0
58
+ ),
59
+ (
60
+ 'with feed food additive and energy content',
61
+ {
62
+ 'inputs': [{
63
+ 'term': {
64
+ 'units': 'kg', 'termType': TermTermType.FEEDFOODADDITIVE.value, '@id': 'aminoAcidsUnspecified'
65
+ },
66
+ 'isAnimalFeed': True,
67
+ 'value': [10]
68
+ }]
69
+ },
70
+ 1
71
+ ),
72
+ (
73
+ 'with feed food additive not energy content',
74
+ {
75
+ 'inputs': [{
76
+ 'term': {
77
+ 'units': 'kg', 'termType': TermTermType.FEEDFOODADDITIVE.value, '@id': 'premixUnspecified'
78
+ },
79
+ 'isAnimalFeed': True,
80
+ 'value': [10]
81
+ }]
82
+ },
83
+ 0
84
+ ),
85
+ ]
86
+ )
87
+ def test_get_feed_inputs(test_name, cycle, expected_input_length):
88
+ assert len(get_feed_inputs(cycle)) == expected_input_length, test_name