hestia-earth-models 0.74.13__py3-none-any.whl → 0.74.15__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 (39) hide show
  1. hestia_earth/models/config/ImpactAssessment.json +4 -2
  2. hestia_earth/models/config/Site.json +11 -3
  3. hestia_earth/models/ecoalimV9/cycle.py +20 -5
  4. hestia_earth/models/ecoalimV9/utils.py +52 -2
  5. hestia_earth/models/emepEea2019/fuelCombustion_utils.py +21 -21
  6. hestia_earth/models/environmentalFootprintV3_1/environmentalFootprintSingleOverallScore.py +27 -18
  7. hestia_earth/models/hestia/landCover.py +27 -41
  8. hestia_earth/models/hestia/landCover_utils.py +40 -45
  9. hestia_earth/models/hestia/landOccupationDuringCycle.py +9 -27
  10. hestia_earth/models/hestia/soilClassification.py +314 -0
  11. hestia_earth/models/ipcc2019/aboveGroundBiomass.py +5 -15
  12. hestia_earth/models/ipcc2019/belowGroundBiomass.py +5 -15
  13. hestia_earth/models/ipcc2019/biocharOrganicCarbonPerHa.py +5 -39
  14. hestia_earth/models/ipcc2019/ch4ToAirEntericFermentation.py +2 -1
  15. hestia_earth/models/ipcc2019/ch4ToAirOrganicSoilCultivation.py +5 -5
  16. hestia_earth/models/ipcc2019/co2ToAirCarbonStockChange_utils.py +6 -21
  17. hestia_earth/models/ipcc2019/co2ToAirOrganicSoilCultivation.py +4 -5
  18. hestia_earth/models/ipcc2019/n2OToAirOrganicSoilCultivationDirect.py +5 -5
  19. hestia_earth/models/ipcc2019/nonCo2EmissionsToAirNaturalVegetationBurning.py +17 -46
  20. hestia_earth/models/ipcc2019/organicCarbonPerHa.py +10 -10
  21. hestia_earth/models/ipcc2019/organicCarbonPerHa_utils.py +4 -19
  22. hestia_earth/models/ipcc2019/organicSoilCultivation_utils.py +0 -9
  23. hestia_earth/models/log.py +71 -1
  24. hestia_earth/models/mocking/search-results.json +1 -1
  25. hestia_earth/models/utils/__init__.py +2 -2
  26. hestia_earth/models/utils/aggregated.py +3 -3
  27. hestia_earth/models/utils/blank_node.py +12 -4
  28. hestia_earth/models/utils/lookup.py +9 -10
  29. hestia_earth/models/version.py +1 -1
  30. {hestia_earth_models-0.74.13.dist-info → hestia_earth_models-0.74.15.dist-info}/METADATA +2 -2
  31. {hestia_earth_models-0.74.13.dist-info → hestia_earth_models-0.74.15.dist-info}/RECORD +39 -36
  32. tests/models/ecoalimV9/test_cycle.py +3 -2
  33. tests/models/hestia/test_landCover.py +1 -1
  34. tests/models/hestia/test_soilClassification.py +72 -0
  35. tests/models/ipcc2019/test_organicCarbonPerHa_utils.py +4 -48
  36. tests/models/test_log.py +128 -0
  37. {hestia_earth_models-0.74.13.dist-info → hestia_earth_models-0.74.15.dist-info}/LICENSE +0 -0
  38. {hestia_earth_models-0.74.13.dist-info → hestia_earth_models-0.74.15.dist-info}/WHEEL +0 -0
  39. {hestia_earth_models-0.74.13.dist-info → hestia_earth_models-0.74.15.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,128 @@
1
+ from enum import Enum
2
+ from numpy import array
3
+ from pytest import mark
4
+
5
+ from hestia_earth.models.log import (
6
+ format_bool, format_decimal_percentage, format_enum, format_float, format_int, format_nd_array, format_str
7
+ )
8
+
9
+
10
+ @mark.parametrize(
11
+ "value, kwargs, expected",
12
+ [
13
+ (True, {}, "True"),
14
+ (False, {}, "False"),
15
+ ([], {}, "None"),
16
+ ("str", {}, "None"),
17
+ (None, {}, "None"),
18
+ (None, {"default": "Override"}, "Override")
19
+ ],
20
+ ids=["True", "False", "list", "str", "None", "None w/ default"]
21
+ )
22
+ def test_format_bool(value, kwargs, expected):
23
+ assert format_bool(value, **kwargs) == expected
24
+
25
+
26
+ @mark.parametrize(
27
+ "value, kwargs, expected",
28
+ [
29
+ (3.141592653, {}, "314.159 pct"),
30
+ (0, {}, "0 pct"),
31
+ ("20", {}, "None"),
32
+ (None, {}, "None"),
33
+ (3.141592653, {"unit": "kg"}, "314.159 kg"),
34
+ (3.141592653, {"ndigits": 4}, "314.1593 pct"),
35
+ (None, {"default": "Override"}, "Override"),
36
+ ],
37
+ ids=["float", "zero", "str", "None", "float w/ unit", "float w/ ndigits", "None w/ default"]
38
+ )
39
+ def test_format_decimal_percentage(value, kwargs, expected):
40
+ assert format_decimal_percentage(value, **kwargs) == expected
41
+
42
+
43
+ class TestEnum(Enum):
44
+ WITH_LEGAL_CHARS = "with legal chars"
45
+ WITH_RESERVED_CHARS = "with_reserved_chars"
46
+
47
+
48
+ @mark.parametrize(
49
+ "value, kwargs, expected",
50
+ [
51
+ (TestEnum.WITH_LEGAL_CHARS, {}, TestEnum.WITH_LEGAL_CHARS.value),
52
+ (TestEnum.WITH_RESERVED_CHARS, {}, "with-reserved-chars"),
53
+ ("str", {}, "None"),
54
+ (None, {}, "None"),
55
+ (None, {"default": "Override"}, "Override")
56
+ ],
57
+ ids=["Enum w/ legal chars", "Enum w/ illegal chars", "str", "None", "None w/ default"]
58
+ )
59
+ def test_format_enum(value, kwargs, expected):
60
+ assert format_enum(value, **kwargs) == expected
61
+
62
+
63
+ @mark.parametrize(
64
+ "value, kwargs, expected",
65
+ [
66
+ (3.141592653, {}, "3.142"),
67
+ (0, {}, "0"),
68
+ ("20", {}, "None"),
69
+ (None, {}, "None"),
70
+ (3.141592653, {"unit": "kg"}, "3.142 kg"),
71
+ (3.141592653, {"ndigits": 4}, "3.1416"),
72
+ (None, {"default": "Override"}, "Override"),
73
+ ],
74
+ ids=["float", "zero", "str", "None", "float w/ unit", "float w/ ndigits", "None w/ default"]
75
+ )
76
+ def test_format_float(value, kwargs, expected):
77
+ assert format_float(value, **kwargs) == expected
78
+
79
+
80
+ @mark.parametrize(
81
+ "value, kwargs, expected",
82
+ [
83
+ (3.141592653, {}, "3"),
84
+ (0, {}, "0"),
85
+ ("20", {}, "None"),
86
+ (None, {}, "None"),
87
+ (3.141592653, {"unit": "kg"}, "3 kg"),
88
+ (None, {"default": "Override"}, "Override")
89
+ ],
90
+ ids=["float", "zero", "str", "None", "float w/ unit", "None w/ default"]
91
+ )
92
+ def test_format_int(value, kwargs, expected):
93
+ assert format_int(value, **kwargs) == expected
94
+
95
+
96
+ @mark.parametrize(
97
+ "value, kwargs, expected",
98
+ [
99
+ (array(3.141592653), {}, "3.142 ± 0.0"),
100
+ (array([1, 2, 3, 4]), {}, "2.5 ± 1.118"),
101
+ (array([[11, 12, 13, 14], [21, 22, 23, 24]]), {}, "17.5 ± 5.123"),
102
+ (3.141592653, {}, "3.142"),
103
+ (0, {}, "0"),
104
+ ("20", {}, "None"),
105
+ (None, {}, "None"),
106
+ (array(3.141592653), {"unit": "kg"}, "3.142 ± 0.0 kg"),
107
+ (array(3.141592653), {"ndigits": 4}, "3.1416 ± 0.0"),
108
+ (None, {"default": "Override"}, "Override"),
109
+ ],
110
+ ids=["scalar", "1d", "2d", "float", "zero", "str", "None", "float w/ unit", "float w/ ndigits", "None w/ default"]
111
+ )
112
+ def test_format_nd_array(value, kwargs, expected):
113
+ assert format_nd_array(value, **kwargs) == expected
114
+
115
+
116
+ @mark.parametrize(
117
+ "value, kwargs, expected",
118
+ [
119
+ ("string", {}, "string"),
120
+ ("some_reserved:chars,get=replaced", {}, "some-reserved-chars-get-replaced"),
121
+ ([], {}, "None"),
122
+ (None, {}, "None"),
123
+ (None, {"default": "Override"}, "Override")
124
+ ],
125
+ ids=["legal chars", "illegal chars", "list", "None", "None w/ default"]
126
+ )
127
+ def test_format_str(value, kwargs, expected):
128
+ assert format_str(value, **kwargs) == expected