hestia-earth-models 0.51.0__py3-none-any.whl → 0.51.1__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 (44) hide show
  1. hestia_earth/models/agribalyse2016/machineryInfrastructureDepreciatedAmountPerCycle.py +14 -5
  2. hestia_earth/models/emepEea2019/co2ToAirFuelCombustion.py +5 -2
  3. hestia_earth/models/emepEea2019/n2OToAirFuelCombustionDirect.py +5 -2
  4. hestia_earth/models/emepEea2019/nh3ToAirExcreta.py +6 -2
  5. hestia_earth/models/emepEea2019/noxToAirFuelCombustion.py +5 -2
  6. hestia_earth/models/emepEea2019/so2ToAirFuelCombustion.py +5 -2
  7. hestia_earth/models/emepEea2019/utils.py +22 -3
  8. hestia_earth/models/geospatialDatabase/aware.py +5 -4
  9. hestia_earth/models/geospatialDatabase/ecoregion.py +5 -4
  10. hestia_earth/models/geospatialDatabase/region.py +7 -11
  11. hestia_earth/models/geospatialDatabase/utils.py +39 -25
  12. hestia_earth/models/geospatialDatabase/waterDepth.py +5 -4
  13. hestia_earth/models/impact_assessment/__init__.py +3 -3
  14. hestia_earth/models/ipcc2019/croppingDuration.py +1 -1
  15. hestia_earth/models/ipcc2019/n2OToAirInorganicFertiliserIndirect.py +106 -0
  16. hestia_earth/models/ipcc2019/n2OToAirOrganicFertiliserIndirect.py +108 -0
  17. hestia_earth/models/ipcc2019/utils.py +37 -0
  18. hestia_earth/models/jarvisAndPain1994/__init__.py +13 -0
  19. hestia_earth/models/jarvisAndPain1994/n2ToAirExcreta.py +53 -0
  20. hestia_earth/models/koble2014/aboveGroundCropResidue.py +44 -21
  21. hestia_earth/models/koble2014/utils.py +5 -1
  22. hestia_earth/models/mocking/search-results.json +298 -261
  23. hestia_earth/models/pooreNemecek2018/aboveGroundCropResidueTotal.py +15 -8
  24. hestia_earth/models/schmidt2007/__init__.py +13 -0
  25. hestia_earth/models/schmidt2007/ch4ToAirWasteTreatment.py +60 -0
  26. hestia_earth/models/schmidt2007/utils.py +16 -0
  27. hestia_earth/models/utils/term.py +6 -0
  28. hestia_earth/models/version.py +1 -1
  29. {hestia_earth_models-0.51.0.dist-info → hestia_earth_models-0.51.1.dist-info}/METADATA +1 -1
  30. {hestia_earth_models-0.51.0.dist-info → hestia_earth_models-0.51.1.dist-info}/RECORD +44 -30
  31. tests/models/emepEea2019/test_utils.py +17 -3
  32. tests/models/geospatialDatabase/test_region.py +4 -5
  33. tests/models/geospatialDatabase/test_utils.py +10 -1
  34. tests/models/ipcc2019/test_n2OToAirInorganicFertiliserIndirect.py +48 -0
  35. tests/models/ipcc2019/test_n2OToAirOrganicFertiliserIndirect.py +48 -0
  36. tests/models/jarvisAndPain1994/__init__.py +0 -0
  37. tests/models/jarvisAndPain1994/test_n2ToAirExcreta.py +37 -0
  38. tests/models/koble2014/test_aboveGroundCropResidue.py +13 -0
  39. tests/models/schmidt2007/__init__.py +0 -0
  40. tests/models/schmidt2007/test_ch4ToAirWasteTreatment.py +45 -0
  41. tests/models/schmidt2007/test_utils.py +39 -0
  42. {hestia_earth_models-0.51.0.dist-info → hestia_earth_models-0.51.1.dist-info}/LICENSE +0 -0
  43. {hestia_earth_models-0.51.0.dist-info → hestia_earth_models-0.51.1.dist-info}/WHEEL +0 -0
  44. {hestia_earth_models-0.51.0.dist-info → hestia_earth_models-0.51.1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,45 @@
1
+ from unittest.mock import patch
2
+ import json
3
+ from tests.utils import fixtures_path, fake_new_emission
4
+
5
+ from hestia_earth.models.schmidt2007.ch4ToAirWasteTreatment import MODEL, TERM_ID, run, _should_run
6
+
7
+ class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}"
8
+ fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
9
+
10
+
11
+ @patch(f"{class_path}.get_waste_values")
12
+ def test_should_run(mock_get_waste_values):
13
+ # no fuel values => no run
14
+ mock_get_waste_values.return_value = []
15
+ should_run, *args = _should_run({})
16
+ assert not should_run
17
+
18
+ # with fuel values => run
19
+ mock_get_waste_values.return_value = [0]
20
+ should_run, *args = _should_run({})
21
+ assert should_run is True
22
+
23
+
24
+ @patch(f"{class_path}._new_emission", side_effect=fake_new_emission)
25
+ def test_run(*args):
26
+ with open(f"{fixtures_folder}/cycle.jsonld", encoding='utf-8') as f:
27
+ cycle = json.load(f)
28
+
29
+ with open(f"{fixtures_folder}/result.jsonld", encoding='utf-8') as f:
30
+ expected = json.load(f)
31
+
32
+ value = run(cycle)
33
+ assert value == expected
34
+
35
+
36
+ @patch(f"{class_path}._new_emission", side_effect=fake_new_emission)
37
+ def test_run_data_complete(*args):
38
+ with open(f"{fixtures_folder}/no-input-data-complete/cycle.jsonld", encoding='utf-8') as f:
39
+ cycle = json.load(f)
40
+
41
+ with open(f"{fixtures_folder}/no-input-data-complete/result.jsonld", encoding='utf-8') as f:
42
+ expected = json.load(f)
43
+
44
+ value = run(cycle)
45
+ assert value == expected
@@ -0,0 +1,39 @@
1
+ from unittest.mock import patch
2
+
3
+ from hestia_earth.models.schmidt2007.utils import get_waste_values
4
+
5
+ class_path = 'hestia_earth.models.schmidt2007.utils'
6
+ TERMS = [
7
+ 'Oil palm mill effluent (waste)'
8
+ ]
9
+
10
+
11
+ @patch(f"{class_path}._is_term_type_complete", return_value=True)
12
+ def test_get_waste_values_no_inputs_complete(*args):
13
+ cycle = {'@type': 'Cycle', 'inputs': []}
14
+ assert get_waste_values('ch4ToAirWasteTreatment', cycle, '') == [0]
15
+
16
+ cycle = {'@type': 'Transformation', 'inputs': []}
17
+ assert get_waste_values('ch4ToAirWasteTreatment', cycle, '') == []
18
+
19
+
20
+ @patch(f"{class_path}._is_term_type_complete", return_value=False)
21
+ def test_get_waste_values_no_inputs_incomplete(*args):
22
+ cycle = {'@type': 'Cycle', 'inputs': []}
23
+ assert get_waste_values('ch4ToAirWasteTreatment', cycle, '') == []
24
+
25
+ cycle = {'@type': 'Transformation', 'inputs': []}
26
+ assert get_waste_values('ch4ToAirWasteTreatment', cycle, '') == []
27
+
28
+
29
+ def test_get_waste_values(*args):
30
+ cycle = {
31
+ '@type': 'Cycle',
32
+ 'products': [
33
+ {
34
+ 'term': {'@id': 'oilPalmMillEffluentWaste', 'termType': 'waste'},
35
+ 'value': [100]
36
+ }
37
+ ]
38
+ }
39
+ assert get_waste_values('ch4ToAirWasteTreatment', cycle, 'ch4EfSchmidt2007') == [1.3]