hestia-earth-models 0.59.5__py3-none-any.whl → 0.59.7__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/cache_sites.py +6 -8
- hestia_earth/models/cycle/animal/milkYield.py +86 -0
- hestia_earth/models/cycle/endDate.py +50 -0
- hestia_earth/models/cycle/inorganicFertiliser.py +3 -2
- hestia_earth/models/cycle/milkYield.py +8 -3
- hestia_earth/models/cycle/pre_checks/__init__.py +1 -2
- hestia_earth/models/cycle/siteDuration.py +1 -1
- hestia_earth/models/cycle/startDate.py +42 -0
- hestia_earth/models/emepEea2019/nh3ToAirInorganicFertiliser.py +9 -6
- hestia_earth/models/faostat2018/liveweightPerHead.py +77 -41
- hestia_earth/models/faostat2018/product/price.py +43 -57
- hestia_earth/models/faostat2018/utils.py +10 -2
- hestia_earth/models/geospatialDatabase/utils.py +0 -1
- hestia_earth/models/haversineFormula/transport/distance.py +6 -3
- hestia_earth/models/ipcc2006/n2OToAirInorganicFertiliserIndirect.py +1 -1
- hestia_earth/models/ipcc2019/co2ToAirLimeHydrolysis.py +1 -1
- hestia_earth/models/ipcc2019/co2ToAirUreaHydrolysis.py +2 -7
- hestia_earth/models/ipcc2019/organicCarbonPerHa.py +26 -6
- hestia_earth/models/ipcc2019/pastureGrass.py +2 -1
- hestia_earth/models/linkedImpactAssessment/__init__.py +3 -3
- hestia_earth/models/mocking/search-results.json +244 -232
- hestia_earth/models/schmidt2007/h2SToAirWasteTreatment.py +58 -0
- hestia_earth/models/site/management.py +3 -1
- hestia_earth/models/site/pre_checks/cache_geospatialDatabase.py +2 -2
- hestia_earth/models/utils/__init__.py +4 -1
- hestia_earth/models/utils/animalProduct.py +6 -4
- hestia_earth/models/utils/blank_node.py +3 -2
- hestia_earth/models/utils/product.py +9 -1
- hestia_earth/models/utils/property.py +2 -1
- hestia_earth/models/utils/site.py +7 -4
- hestia_earth/models/version.py +1 -1
- {hestia_earth_models-0.59.5.dist-info → hestia_earth_models-0.59.7.dist-info}/METADATA +1 -1
- {hestia_earth_models-0.59.5.dist-info → hestia_earth_models-0.59.7.dist-info}/RECORD +44 -38
- tests/models/cycle/animal/test_milkYield.py +43 -0
- tests/models/cycle/test_endDate.py +24 -0
- tests/models/cycle/test_startDate.py +22 -0
- tests/models/faostat2018/product/test_price.py +40 -48
- tests/models/faostat2018/test_liveweightPerHead.py +106 -42
- tests/models/ipcc2019/test_organicCarbonPerHa.py +102 -39
- tests/models/schmidt2007/test_h2SToAirWasteTreatment.py +45 -0
- tests/models/utils/test_blank_node.py +71 -3
- hestia_earth/models/cycle/pre_checks/startDate.py +0 -52
- tests/models/cycle/pre_checks/test_startDate.py +0 -44
- {hestia_earth_models-0.59.5.dist-info → hestia_earth_models-0.59.7.dist-info}/LICENSE +0 -0
- {hestia_earth_models-0.59.5.dist-info → hestia_earth_models-0.59.7.dist-info}/WHEEL +0 -0
- {hestia_earth_models-0.59.5.dist-info → hestia_earth_models-0.59.7.dist-info}/top_level.txt +0 -0
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Pre Checks Start Date
|
|
3
|
-
|
|
4
|
-
This model calculates the
|
|
5
|
-
[startDate](https://hestia.earth/schema/Cycle#startDate) from the
|
|
6
|
-
[endDate](https://hestia.earth/schema/Cycle#endDate) and
|
|
7
|
-
[cycleDuration](https://hestia.earth/schema/Cycle#cycleDuration).
|
|
8
|
-
"""
|
|
9
|
-
from dateutil.relativedelta import relativedelta
|
|
10
|
-
from hestia_earth.utils.date import is_in_days
|
|
11
|
-
from hestia_earth.utils.tools import safe_parse_date
|
|
12
|
-
|
|
13
|
-
from hestia_earth.models.log import logRequirements, logShouldRun
|
|
14
|
-
from .. import MODEL
|
|
15
|
-
|
|
16
|
-
REQUIREMENTS = {
|
|
17
|
-
"Cycle": {
|
|
18
|
-
"endDate": "",
|
|
19
|
-
"cycleDuration": ""
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
RETURNS = {
|
|
23
|
-
"Cycle": {
|
|
24
|
-
"startDate": ""
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
MODEL_KEY = 'startDate'
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
def _run(cycle: dict):
|
|
31
|
-
days = -float(cycle.get('cycleDuration'))
|
|
32
|
-
return (safe_parse_date(cycle.get('endDate')) + relativedelta(days=days)).strftime('%Y-%m-%d')
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
def _should_run(cycle: dict):
|
|
36
|
-
has_full_date = is_in_days(cycle.get('endDate'))
|
|
37
|
-
cycleDuration = cycle.get('cycleDuration')
|
|
38
|
-
|
|
39
|
-
logRequirements(cycle, model=MODEL, key=MODEL_KEY,
|
|
40
|
-
has_full_date=has_full_date,
|
|
41
|
-
cycleDuration=cycleDuration)
|
|
42
|
-
|
|
43
|
-
should_run = all([
|
|
44
|
-
has_full_date,
|
|
45
|
-
cycleDuration is not None,
|
|
46
|
-
cycle.get(MODEL_KEY) is None
|
|
47
|
-
])
|
|
48
|
-
logShouldRun(cycle, MODEL, None, should_run, key=MODEL_KEY)
|
|
49
|
-
return should_run
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
def run(cycle: dict): return {**cycle, MODEL_KEY: _run(cycle)} if _should_run(cycle) else cycle
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import json
|
|
2
|
-
from tests.utils import fixtures_path
|
|
3
|
-
|
|
4
|
-
from hestia_earth.models.cycle.pre_checks.startDate import run, _should_run
|
|
5
|
-
|
|
6
|
-
fixtures_folder = f"{fixtures_path}/cycle/pre_checks/startDate"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def test_should_run():
|
|
10
|
-
cycle = {}
|
|
11
|
-
|
|
12
|
-
# no endDate => no run
|
|
13
|
-
cycle['endDate'] = None
|
|
14
|
-
assert not _should_run(cycle)
|
|
15
|
-
|
|
16
|
-
cycle['endDate'] = '2010'
|
|
17
|
-
# no cycleDuration => no run
|
|
18
|
-
cycle['cycleDuration'] = None
|
|
19
|
-
assert not _should_run(cycle)
|
|
20
|
-
|
|
21
|
-
cycle['cycleDuration'] = 120
|
|
22
|
-
# with a startDate => no run
|
|
23
|
-
cycle['startDate'] = '2010'
|
|
24
|
-
assert not _should_run(cycle)
|
|
25
|
-
|
|
26
|
-
cycle['startDate'] = None
|
|
27
|
-
# endDate not precise enough => no run
|
|
28
|
-
cycle['endDate'] = '2020-01'
|
|
29
|
-
assert not _should_run(cycle)
|
|
30
|
-
|
|
31
|
-
# endDate is precise enough => run
|
|
32
|
-
cycle['endDate'] = '2020-01-01'
|
|
33
|
-
assert _should_run(cycle) is True
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
def test_run():
|
|
37
|
-
with open(f"{fixtures_folder}/cycle.jsonld", encoding='utf-8') as f:
|
|
38
|
-
cycle = json.load(f)
|
|
39
|
-
|
|
40
|
-
with open(f"{fixtures_folder}/result.jsonld", encoding='utf-8') as f:
|
|
41
|
-
expected = json.load(f)
|
|
42
|
-
|
|
43
|
-
value = run(cycle)
|
|
44
|
-
assert value == expected
|
|
File without changes
|
|
File without changes
|
|
File without changes
|