hestia-earth-models 0.61.8__py3-none-any.whl → 0.62.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.
- hestia_earth/models/blonkConsultants2016/utils.py +3 -2
- hestia_earth/models/cycle/completeness/electricityFuel.py +5 -1
- hestia_earth/models/cycle/post_checks/__init__.py +3 -2
- hestia_earth/models/cycle/post_checks/otherSites.py +40 -0
- hestia_earth/models/cycle/pre_checks/__init__.py +2 -1
- hestia_earth/models/cycle/pre_checks/otherSites.py +42 -0
- hestia_earth/models/cycle/pre_checks/site.py +1 -1
- hestia_earth/models/cycle/product/economicValueShare.py +47 -31
- hestia_earth/models/ecoinventV3AndEmberClimate/utils.py +1 -1
- hestia_earth/models/emepEea2019/utils.py +4 -3
- hestia_earth/models/geospatialDatabase/heavyWinterPrecipitation.py +1 -1
- hestia_earth/models/ipcc2019/animal/pastureGrass.py +36 -30
- hestia_earth/models/ipcc2019/co2ToAirSoilOrganicCarbonStockChangeManagementChange.py +30 -4
- hestia_earth/models/ipcc2019/n2OToAirExcretaDirect.py +6 -2
- hestia_earth/models/ipcc2019/n2OToAirExcretaIndirect.py +1 -1
- hestia_earth/models/ipcc2019/n2OToAirInorganicFertiliserDirect.py +1 -1
- hestia_earth/models/ipcc2019/n2OToAirInorganicFertiliserIndirect.py +1 -1
- hestia_earth/models/ipcc2019/n2OToAirOrganicFertiliserIndirect.py +1 -1
- hestia_earth/models/ipcc2019/organicCarbonPerHa.py +4 -6
- hestia_earth/models/ipcc2019/organicCarbonPerHa_tier_1_utils.py +4 -2
- hestia_earth/models/ipcc2019/organicCarbonPerHa_tier_2_utils.py +12 -11
- hestia_earth/models/ipcc2019/pastureGrass.py +40 -22
- hestia_earth/models/ipcc2019/pastureGrass_utils.py +43 -60
- hestia_earth/models/mocking/search-results.json +261 -257
- hestia_earth/models/schererPfister2015/utils.py +2 -2
- hestia_earth/models/site/brackishWater.py +1 -1
- hestia_earth/models/site/flowingWater.py +1 -1
- hestia_earth/models/site/freshWater.py +1 -1
- hestia_earth/models/site/management.py +29 -11
- hestia_earth/models/site/pre_checks/cache_sources.py +9 -13
- hestia_earth/models/site/salineWater.py +1 -1
- hestia_earth/models/stehfestBouwman2006/n2OToAirCropResidueDecompositionDirect.py +12 -2
- hestia_earth/models/stehfestBouwman2006/n2OToAirExcretaDirect.py +12 -2
- hestia_earth/models/stehfestBouwman2006/n2OToAirInorganicFertiliserDirect.py +11 -1
- hestia_earth/models/stehfestBouwman2006/n2OToAirOrganicFertiliserDirect.py +11 -1
- hestia_earth/models/stehfestBouwman2006/noxToAirCropResidueDecomposition.py +12 -2
- hestia_earth/models/stehfestBouwman2006/noxToAirExcreta.py +12 -2
- hestia_earth/models/stehfestBouwman2006/noxToAirInorganicFertiliser.py +11 -1
- hestia_earth/models/stehfestBouwman2006/noxToAirOrganicFertiliser.py +11 -1
- hestia_earth/models/stehfestBouwman2006GisImplementation/noxToAirCropResidueDecomposition.py +12 -2
- hestia_earth/models/stehfestBouwman2006GisImplementation/noxToAirExcreta.py +12 -2
- hestia_earth/models/stehfestBouwman2006GisImplementation/noxToAirInorganicFertiliser.py +11 -1
- hestia_earth/models/stehfestBouwman2006GisImplementation/noxToAirOrganicFertiliser.py +11 -1
- hestia_earth/models/utils/blank_node.py +159 -146
- hestia_earth/models/utils/constant.py +2 -0
- hestia_earth/models/utils/lookup.py +19 -6
- hestia_earth/models/utils/source.py +1 -1
- hestia_earth/models/version.py +1 -1
- {hestia_earth_models-0.61.8.dist-info → hestia_earth_models-0.62.1.dist-info}/METADATA +3 -3
- {hestia_earth_models-0.61.8.dist-info → hestia_earth_models-0.62.1.dist-info}/RECORD +64 -59
- tests/models/cycle/post_checks/test_otherSites.py +15 -0
- tests/models/cycle/pre_checks/test_otherSites.py +21 -0
- tests/models/cycle/product/test_economicValueShare.py +8 -0
- tests/models/ipcc2019/animal/test_pastureGrass.py +2 -2
- tests/models/ipcc2019/test_co2ToAirSoilOrganicCarbonStockChangeManagementChange.py +5 -2
- tests/models/ipcc2019/test_organicCarbonPerHa.py +2 -1
- tests/models/ipcc2019/test_pastureGrass.py +0 -16
- tests/models/site/pre_checks/test_cache_sources.py +6 -10
- tests/models/site/test_management.py +162 -2
- tests/models/utils/test_blank_node.py +154 -296
- tests/models/utils/test_lookup.py +10 -0
- {hestia_earth_models-0.61.8.dist-info → hestia_earth_models-0.62.1.dist-info}/LICENSE +0 -0
- {hestia_earth_models-0.61.8.dist-info → hestia_earth_models-0.62.1.dist-info}/WHEEL +0 -0
- {hestia_earth_models-0.61.8.dist-info → hestia_earth_models-0.62.1.dist-info}/top_level.txt +0 -0
|
@@ -5,6 +5,7 @@ import pytest
|
|
|
5
5
|
from hestia_earth.schema import TermTermType
|
|
6
6
|
|
|
7
7
|
from hestia_earth.models.site.management import MODEL, MODEL_KEY, run, _should_run
|
|
8
|
+
from hestia_earth.models.utils.blank_node import condense_nodes
|
|
8
9
|
from tests.utils import fixtures_path
|
|
9
10
|
|
|
10
11
|
CLASS_PATH = f"hestia_earth.models.{MODEL}.{MODEL_KEY}"
|
|
@@ -14,7 +15,8 @@ TERM_BY_ID = {
|
|
|
14
15
|
'genericCropPlant': {'@type': 'Term', '@id': 'genericCropPlant', 'termType': TermTermType.LANDCOVER.value},
|
|
15
16
|
'wheatPlant': {'@type': 'Term', '@id': 'wheatPlant', 'termType': TermTermType.LANDCOVER.value},
|
|
16
17
|
'oatPlant': {'@type': 'Term', '@id': 'oatPlant', 'termType': TermTermType.LANDCOVER.value},
|
|
17
|
-
'agatiTree': {'@type': 'Term', '@id': 'agatiTree', 'termType': TermTermType.LANDCOVER.value}
|
|
18
|
+
'agatiTree': {'@type': 'Term', '@id': 'agatiTree', 'termType': TermTermType.LANDCOVER.value},
|
|
19
|
+
'wildGarlicPlant': {'@type': 'Term', '@id': 'wildGarlicPlant', 'termType': TermTermType.LANDCOVER.value},
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
|
|
@@ -28,6 +30,152 @@ def lookup_side_effect(*args, **kwargs):
|
|
|
28
30
|
return True
|
|
29
31
|
|
|
30
32
|
|
|
33
|
+
@pytest.mark.parametrize(
|
|
34
|
+
"test_name,input_nodes,expected_output_nodes",
|
|
35
|
+
[
|
|
36
|
+
(
|
|
37
|
+
"No match",
|
|
38
|
+
[
|
|
39
|
+
{"startDate": "2001", "endDate": "2002", "term": {"@id": "treeNutTree", "units": "% area"},
|
|
40
|
+
"value": [2]},
|
|
41
|
+
{"startDate": "2003", "endDate": "2004", "term": {"@id": "bananaPlant", "units": "% area"},
|
|
42
|
+
"value": [2]},
|
|
43
|
+
],
|
|
44
|
+
[
|
|
45
|
+
{"startDate": "2001", "endDate": "2002", "term": {"@id": "treeNutTree", "units": "% area"},
|
|
46
|
+
"value": [2]},
|
|
47
|
+
{"startDate": "2003", "endDate": "2004", "term": {"@id": "bananaPlant", "units": "% area"},
|
|
48
|
+
"value": [2]},
|
|
49
|
+
],
|
|
50
|
+
),
|
|
51
|
+
(
|
|
52
|
+
"No continuity",
|
|
53
|
+
[
|
|
54
|
+
{"startDate": "2001", "endDate": "2002", "term": {"@id": "treeNutTree", "units": "% area"},
|
|
55
|
+
"value": [2]},
|
|
56
|
+
{"startDate": "2004", "endDate": "2005", "term": {"@id": "treeNutTree", "units": "% area"},
|
|
57
|
+
"value": [2]},
|
|
58
|
+
],
|
|
59
|
+
[
|
|
60
|
+
{"startDate": "2001", "endDate": "2002", "term": {"@id": "treeNutTree", "units": "% area"},
|
|
61
|
+
"value": [2]},
|
|
62
|
+
{"startDate": "2004", "endDate": "2005", "term": {"@id": "treeNutTree", "units": "% area"},
|
|
63
|
+
"value": [2]},
|
|
64
|
+
],
|
|
65
|
+
),
|
|
66
|
+
(
|
|
67
|
+
"No continuity (multiple values differ)",
|
|
68
|
+
[
|
|
69
|
+
{"startDate": "2001", "endDate": "2002", "term": {"@id": "treeNutTree", "units": "% area"},
|
|
70
|
+
"value": [10, 20]},
|
|
71
|
+
{"startDate": "2003", "endDate": "2004", "term": {"@id": "treeNutTree", "units": "% area"},
|
|
72
|
+
"value": [10, 30]},
|
|
73
|
+
],
|
|
74
|
+
[
|
|
75
|
+
{"startDate": "2001", "endDate": "2002", "term": {"@id": "treeNutTree", "units": "% area"},
|
|
76
|
+
"value": [10, 20]},
|
|
77
|
+
{"startDate": "2003", "endDate": "2004", "term": {"@id": "treeNutTree", "units": "% area"},
|
|
78
|
+
"value": [10, 30]},
|
|
79
|
+
],
|
|
80
|
+
),
|
|
81
|
+
(
|
|
82
|
+
"2->1 condense (YYYY dates)",
|
|
83
|
+
[
|
|
84
|
+
{"startDate": "2001", "endDate": "2001", "term": {"@id": "treeNutTree", "units": "% area"},
|
|
85
|
+
"value": [10, 20]},
|
|
86
|
+
{"startDate": "2002", "endDate": "2002", "term": {"@id": "treeNutTree", "units": "% area"},
|
|
87
|
+
"value": [10, 20]},
|
|
88
|
+
],
|
|
89
|
+
[
|
|
90
|
+
{"startDate": "2001-01-01", "endDate": "2002-12-31", "term": {"@id": "treeNutTree", "units": "% area"},
|
|
91
|
+
"value": [10, 20]}
|
|
92
|
+
],
|
|
93
|
+
),
|
|
94
|
+
(
|
|
95
|
+
"4->2 condense (YYYY-MM dates)",
|
|
96
|
+
[
|
|
97
|
+
{"startDate": "2001-01", "endDate": "2001-12", "term": {"@id": "treeNutTree", "units": "% area"},
|
|
98
|
+
"value": [2]},
|
|
99
|
+
{"startDate": "2002-01", "endDate": "2002-03", "term": {"@id": "treeNutTree", "units": "% area"},
|
|
100
|
+
"value": [2]},
|
|
101
|
+
],
|
|
102
|
+
[
|
|
103
|
+
{"startDate": "2001-01-01", "endDate": "2002-03-31", "term": {"@id": "treeNutTree", "units": "% area"},
|
|
104
|
+
"value": [2]}
|
|
105
|
+
],
|
|
106
|
+
),
|
|
107
|
+
(
|
|
108
|
+
"2->1 condense (YYYY-MM-DD dates)",
|
|
109
|
+
[
|
|
110
|
+
{"startDate": "2001-01-01", "endDate": "2001-12-31", "term": {"@id": "treeNutTree", "units": "% area"},
|
|
111
|
+
"value": [2]},
|
|
112
|
+
{"startDate": "2002-01-01", "endDate": "2002-05-04", "term": {"@id": "treeNutTree", "units": "% area"},
|
|
113
|
+
"value": [2]},
|
|
114
|
+
],
|
|
115
|
+
[
|
|
116
|
+
{"startDate": "2001-01-01", "endDate": "2002-05-04", "term": {"@id": "treeNutTree", "units": "% area"},
|
|
117
|
+
"value": [2]}
|
|
118
|
+
],
|
|
119
|
+
),
|
|
120
|
+
(
|
|
121
|
+
"3->1 condense",
|
|
122
|
+
[
|
|
123
|
+
{"startDate": "2001-01-01", "endDate": "2001-12-31", "term": {"@id": "bananaPlant", "units": "% area"},
|
|
124
|
+
"value": [9]},
|
|
125
|
+
{"startDate": "2002-01-01", "endDate": "2002-10-31", "term": {"@id": "bananaPlant", "units": "% area"},
|
|
126
|
+
"value": [9]},
|
|
127
|
+
{"startDate": "2002-11-01", "endDate": "2004-04-05", "term": {"@id": "bananaPlant", "units": "% area"},
|
|
128
|
+
"value": [9]},
|
|
129
|
+
],
|
|
130
|
+
[
|
|
131
|
+
{"startDate": "2001-01-01", "endDate": "2004-04-05", "term": {"@id": "bananaPlant", "units": "% area"},
|
|
132
|
+
"value": [9]}
|
|
133
|
+
],
|
|
134
|
+
),
|
|
135
|
+
(
|
|
136
|
+
"3->2 partial condense",
|
|
137
|
+
[
|
|
138
|
+
{"startDate": "2001-01-01", "endDate": "2001-12-31", "term": {"@id": "bananaPlant", "units": "% area"},
|
|
139
|
+
"value": [9]},
|
|
140
|
+
{"startDate": "2012-02-01", "endDate": "2012-12-31", "term": {"@id": "bananaPlant", "units": "% area"},
|
|
141
|
+
"value": [9]},
|
|
142
|
+
{"startDate": "2002-01-01", "endDate": "2003-12-31", "term": {"@id": "bananaPlant", "units": "% area"},
|
|
143
|
+
"value": [9]},
|
|
144
|
+
],
|
|
145
|
+
[
|
|
146
|
+
{"startDate": "2001-01-01", "endDate": "2003-12-31", "term": {"@id": "bananaPlant", "units": "% area"},
|
|
147
|
+
"value": [9]},
|
|
148
|
+
{"startDate": "2012-02-01", "endDate": "2012-12-31", "term": {"@id": "bananaPlant", "units": "% area"},
|
|
149
|
+
"value": [9]}
|
|
150
|
+
],
|
|
151
|
+
),
|
|
152
|
+
(
|
|
153
|
+
"7->2 multi-condense",
|
|
154
|
+
[
|
|
155
|
+
{"startDate": "2001-01-01", "endDate": "2001-11-30", "term": {"@id": "bananaPlant", "units": "% area"},
|
|
156
|
+
"value": [7]},
|
|
157
|
+
{"startDate": "2012-02-01", "endDate": "2012-12-31", "term": {"@id": "bananaPlant", "units": "% area"},
|
|
158
|
+
"value": [7]},
|
|
159
|
+
{"startDate": "2001-12-01", "endDate": "2001-12-31", "term": {"@id": "bananaPlant", "units": "% area"},
|
|
160
|
+
"value": [7]},
|
|
161
|
+
{"startDate": "2002-01-01", "endDate": "2002-12-31", "term": {"@id": "bananaPlant", "units": "% area"},
|
|
162
|
+
"value": [7]},
|
|
163
|
+
{"startDate": "2013-01-01", "endDate": "2013-05-20", "term": {"@id": "bananaPlant", "units": "% area"},
|
|
164
|
+
"value": [7]},
|
|
165
|
+
],
|
|
166
|
+
[
|
|
167
|
+
{"startDate": "2001-01-01", "endDate": "2002-12-31", "term": {"@id": "bananaPlant", "units": "% area"},
|
|
168
|
+
"value": [7]},
|
|
169
|
+
{"startDate": "2012-02-01", "endDate": "2013-05-20", "term": {"@id": "bananaPlant", "units": "% area"},
|
|
170
|
+
"value": [7]}
|
|
171
|
+
],
|
|
172
|
+
),
|
|
173
|
+
]
|
|
174
|
+
)
|
|
175
|
+
def test_condense_nodes(test_name, input_nodes, expected_output_nodes):
|
|
176
|
+
assert condense_nodes(input_nodes) == expected_output_nodes
|
|
177
|
+
|
|
178
|
+
|
|
31
179
|
@patch(f"{CLASS_PATH}.download_hestia", side_effect=lambda id, *args: TERM_BY_ID[id])
|
|
32
180
|
@patch(f"{CLASS_PATH}.related_cycles")
|
|
33
181
|
def test_should_run(mock_related_cycles, *args):
|
|
@@ -121,7 +269,19 @@ def test_should_run(mock_related_cycles, *args):
|
|
|
121
269
|
("Example 1", f"{fixtures_folder}/inputs/example1"),
|
|
122
270
|
("Example 2", f"{fixtures_folder}/inputs/example2"),
|
|
123
271
|
("Example 3", f"{fixtures_folder}/inputs/example3"),
|
|
124
|
-
("Example 4", f"{fixtures_folder}/inputs/example4")
|
|
272
|
+
("Example 4", f"{fixtures_folder}/inputs/example4"),
|
|
273
|
+
("Condense Nodes", f"{fixtures_folder}/inputs/condense_nodes")
|
|
274
|
+
# Expected:
|
|
275
|
+
# - appleTree (81) x 3 condenses 2020-03-01 to 2021-02-15
|
|
276
|
+
# - animalManureUsed (true) x 2 condenses 2001-04-01 to 2001-12-31
|
|
277
|
+
# - treeNutTree, lebbekTree (82) does not condense [different terms]
|
|
278
|
+
# - organicFertiliserUsed (true|false) does not condense [different values]
|
|
279
|
+
# - glassOrHighAccessibleCover (83) does not condense [different date ranges (overlapping)]
|
|
280
|
+
# - durianTree (84) does not condense [different date ranges (disjoint)]
|
|
281
|
+
# - irrigatedSurfaceIrrigationContinuouslyFlooded (85) does not condense ["%" units]
|
|
282
|
+
# - sassafrasTree (86) x 2 condenses 2001-01-01 to 2004-12-31
|
|
283
|
+
# - bananaPlant (87) does not condense [non-consecutive years]
|
|
284
|
+
# - durianTree (89) does not condense [dates overwritten See 808]
|
|
125
285
|
]
|
|
126
286
|
)
|
|
127
287
|
@patch(f"{CLASS_PATH}.download_hestia", side_effect=lambda id, *args: TERM_BY_ID[id])
|