hestia-earth-models 0.74.7__py3-none-any.whl → 0.74.9__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.
- hestia_earth/models/cache_sites.py +1 -1
- hestia_earth/models/data/ecoinventV3/__init__.py +3 -3
- hestia_earth/models/data/hestiaAggregatedData/__init__.py +6 -4
- hestia_earth/models/faostat2018/liveweightPerHead.py +1 -1
- hestia_earth/models/faostat2018/product/price.py +1 -1
- hestia_earth/models/geospatialDatabase/ecoClimateZone.py +1 -1
- hestia_earth/models/geospatialDatabase/region.py +1 -1
- hestia_earth/models/geospatialDatabase/utils.py +1 -1
- hestia_earth/models/globalCropWaterModel2008/rootingDepth.py +2 -1
- hestia_earth/models/haversineFormula/transport/distance.py +1 -1
- hestia_earth/models/hestia/aboveGroundCropResidue.py +1 -3
- hestia_earth/models/hestia/cropResidueManagement.py +1 -0
- hestia_earth/models/hestia/excretaKgMass.py +1 -1
- hestia_earth/models/hestia/landCover.py +13 -6
- hestia_earth/models/hestia/landOccupationDuringCycle.py +1 -1
- hestia_earth/models/hestia/management.py +25 -11
- hestia_earth/models/hestia/pastureGrass.py +1 -1
- hestia_earth/models/impact_assessment/post_checks/__init__.py +3 -2
- hestia_earth/models/impact_assessment/post_checks/remove_no_value.py +13 -0
- hestia_earth/models/ipcc2019/biocharOrganicCarbonPerHa.py +2 -1
- hestia_earth/models/ipcc2019/ch4ToAirExcreta.py +4 -1
- hestia_earth/models/ipcc2019/organicCarbonPerHa.py +5 -1
- hestia_earth/models/ipcc2019/organicCarbonPerHa_tier_1.py +88 -101
- hestia_earth/models/ipcc2019/organicCarbonPerHa_utils.py +21 -0
- hestia_earth/models/mocking/search-results.json +1 -1
- hestia_earth/models/site/pre_checks/country.py +1 -2
- hestia_earth/models/utils/__init__.py +7 -5
- hestia_earth/models/utils/blank_node.py +13 -4
- hestia_earth/models/utils/completeness.py +1 -2
- hestia_earth/models/utils/emission.py +1 -1
- hestia_earth/models/utils/indicator.py +1 -1
- hestia_earth/models/utils/input.py +1 -1
- hestia_earth/models/utils/management.py +1 -1
- hestia_earth/models/utils/measurement.py +2 -1
- hestia_earth/models/utils/method.py +1 -2
- hestia_earth/models/utils/practice.py +1 -1
- hestia_earth/models/utils/product.py +2 -1
- hestia_earth/models/utils/property.py +2 -1
- hestia_earth/models/utils/term.py +1 -27
- hestia_earth/models/version.py +1 -1
- {hestia_earth_models-0.74.7.dist-info → hestia_earth_models-0.74.9.dist-info}/METADATA +2 -2
- {hestia_earth_models-0.74.7.dist-info → hestia_earth_models-0.74.9.dist-info}/RECORD +50 -47
- tests/models/hestia/test_aboveGroundCropResidue.py +13 -35
- tests/models/hestia/test_landOccupationDuringCycle.py +9 -2
- tests/models/impact_assessment/post_checks/test_remove_cache_fields.py +6 -0
- tests/models/impact_assessment/post_checks/test_remove_no_value.py +17 -0
- tests/models/ipcc2019/test_organicCarbonPerHa_tier_1.py +1 -1
- {hestia_earth_models-0.74.7.dist-info → hestia_earth_models-0.74.9.dist-info}/LICENSE +0 -0
- {hestia_earth_models-0.74.7.dist-info → hestia_earth_models-0.74.9.dist-info}/WHEEL +0 -0
- {hestia_earth_models-0.74.7.dist-info → hestia_earth_models-0.74.9.dist-info}/top_level.txt +0 -0
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
import os
|
|
2
2
|
import json
|
|
3
|
+
import pytest
|
|
4
|
+
from unittest.mock import patch
|
|
3
5
|
from tests.utils import fixtures_path, fake_new_product
|
|
4
6
|
|
|
5
|
-
from hestia_earth.models.hestia.aboveGroundCropResidue import MODEL, run, _should_run
|
|
7
|
+
from hestia_earth.models.hestia.aboveGroundCropResidue import MODEL, MODEL_KEY, run, _should_run
|
|
6
8
|
|
|
7
|
-
class_path = f"hestia_earth.models.{MODEL}.
|
|
8
|
-
fixtures_folder = f"{fixtures_path}/{MODEL}/
|
|
9
|
+
class_path = f"hestia_earth.models.{MODEL}.{MODEL_KEY}"
|
|
10
|
+
fixtures_folder = f"{fixtures_path}/{MODEL}/{MODEL_KEY}"
|
|
11
|
+
_folders = [d for d in os.listdir(fixtures_folder) if os.path.isdir(os.path.join(fixtures_folder, d))]
|
|
9
12
|
|
|
10
13
|
|
|
11
14
|
@patch(f"{class_path}._is_term_type_incomplete", return_value=True)
|
|
@@ -17,46 +20,21 @@ def test_should_run(*args):
|
|
|
17
20
|
assert not should_run
|
|
18
21
|
|
|
19
22
|
# product with total crop residue => run
|
|
20
|
-
with open(f"{fixtures_folder}/cycle.jsonld", encoding='utf-8') as f:
|
|
23
|
+
with open(f"{fixtures_folder}/with-total/cycle.jsonld", encoding='utf-8') as f:
|
|
21
24
|
cycle = json.load(f)
|
|
22
25
|
should_run, *args = _should_run(cycle)
|
|
23
26
|
assert should_run is True
|
|
24
27
|
|
|
25
28
|
|
|
29
|
+
@pytest.mark.parametrize('folder', _folders)
|
|
26
30
|
@patch(f"{class_path}._is_term_type_incomplete", return_value=True)
|
|
27
31
|
@patch(f"{class_path}._new_product", side_effect=fake_new_product)
|
|
28
|
-
def test_run(
|
|
29
|
-
with open(f"{fixtures_folder}/cycle.jsonld", encoding='utf-8') as f:
|
|
30
|
-
cycle = json.load(f)
|
|
31
|
-
|
|
32
|
-
with open(f"{fixtures_folder}/result.jsonld", encoding='utf-8') as f:
|
|
33
|
-
expected = json.load(f)
|
|
34
|
-
|
|
35
|
-
value = run(cycle)
|
|
36
|
-
assert value == expected
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
@patch(f"{class_path}._is_term_type_incomplete", return_value=True)
|
|
40
|
-
@patch(f"{class_path}._new_product", side_effect=fake_new_product)
|
|
41
|
-
def test_run_no_total(*args):
|
|
42
|
-
with open(f"{fixtures_folder}/no-total/cycle.jsonld", encoding='utf-8') as f:
|
|
43
|
-
cycle = json.load(f)
|
|
44
|
-
|
|
45
|
-
with open(f"{fixtures_folder}/no-total/result.jsonld", encoding='utf-8') as f:
|
|
46
|
-
expected = json.load(f)
|
|
47
|
-
|
|
48
|
-
value = run(cycle)
|
|
49
|
-
assert value == expected
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
@patch(f"{class_path}._is_term_type_incomplete", return_value=True)
|
|
53
|
-
@patch(f"{class_path}._new_product", side_effect=fake_new_product)
|
|
54
|
-
def test_run_with_leftOnField(*args):
|
|
55
|
-
with open(f"{fixtures_folder}/with-left-on-field-value/cycle.jsonld", encoding='utf-8') as f:
|
|
32
|
+
def test_run(mock_new_product, mock_complete, folder: str):
|
|
33
|
+
with open(f"{fixtures_folder}/{folder}/cycle.jsonld", encoding='utf-8') as f:
|
|
56
34
|
cycle = json.load(f)
|
|
57
35
|
|
|
58
|
-
with open(f"{fixtures_folder}/
|
|
36
|
+
with open(f"{fixtures_folder}/{folder}/result.jsonld", encoding='utf-8') as f:
|
|
59
37
|
expected = json.load(f)
|
|
60
38
|
|
|
61
39
|
value = run(cycle)
|
|
62
|
-
assert value == expected
|
|
40
|
+
assert value == expected, folder
|
|
@@ -30,7 +30,8 @@ PARAMS_SHOULD_RUN = [
|
|
|
30
30
|
("animal-missing-other-site-data", False), # mis-matched `otherSites` and `otherSitesDuration`
|
|
31
31
|
("animal-missing-site-data", False), # closes #1341
|
|
32
32
|
("poore-nemecek-2018-orchard", True), # ensure model returns the same value as deprecated one
|
|
33
|
-
("poore-nemecek-2018-cereal", True)
|
|
33
|
+
("poore-nemecek-2018-cereal", True), # ensure model returns the same value as deprecated one
|
|
34
|
+
("animal-no-cycle", False) # closes #1362
|
|
34
35
|
]
|
|
35
36
|
IDS_SHOULD_RUN = [p[0] for p in PARAMS_SHOULD_RUN]
|
|
36
37
|
|
|
@@ -45,10 +46,16 @@ def test_should_run(
|
|
|
45
46
|
|
|
46
47
|
impact["cycle"] = cycle
|
|
47
48
|
|
|
48
|
-
result, *
|
|
49
|
+
result, *_ = _should_run(impact)
|
|
49
50
|
assert result == expected
|
|
50
51
|
|
|
51
52
|
|
|
53
|
+
def test_should_run_no_cycle():
|
|
54
|
+
IMPACT = {}
|
|
55
|
+
result, *_ = _should_run(IMPACT)
|
|
56
|
+
assert result is False
|
|
57
|
+
|
|
58
|
+
|
|
52
59
|
PARAMS_RUN = [subfolder for subfolder, should_run in PARAMS_SHOULD_RUN if should_run]
|
|
53
60
|
|
|
54
61
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from hestia_earth.models.impact_assessment.post_checks.remove_no_value import run
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def test_run():
|
|
5
|
+
impacts = [
|
|
6
|
+
{'value': 10},
|
|
7
|
+
{'value': 0},
|
|
8
|
+
{'value': None},
|
|
9
|
+
{}
|
|
10
|
+
]
|
|
11
|
+
impact = {'impacts': impacts}
|
|
12
|
+
assert run(impact) == {
|
|
13
|
+
'impacts': [
|
|
14
|
+
{'value': 10},
|
|
15
|
+
{'value': 0}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
@@ -136,7 +136,7 @@ def test_assign_ipcc_soil_category(subfolder: str, expected: IpccSoilCategory):
|
|
|
136
136
|
with open(f"{folder}/site.jsonld", encoding='utf-8') as f:
|
|
137
137
|
site = json.load(f)
|
|
138
138
|
|
|
139
|
-
result = _assign_ipcc_soil_category(site.get("measurements", []))
|
|
139
|
+
result, *_ = _assign_ipcc_soil_category(site.get("measurements", []))
|
|
140
140
|
assert result == expected
|
|
141
141
|
|
|
142
142
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|