hestia-earth-utils 0.16.10__tar.gz → 0.16.12__tar.gz
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_utils-0.16.10/hestia_earth_utils.egg-info → hestia_earth_utils-0.16.12}/PKG-INFO +1 -1
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/hestia_earth/utils/blank_node.py +0 -1
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/hestia_earth/utils/tools.py +10 -4
- hestia_earth_utils-0.16.12/hestia_earth/utils/version.py +1 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12/hestia_earth_utils.egg-info}/PKG-INFO +1 -1
- hestia_earth_utils-0.16.12/tests/test_blank_node.py +74 -0
- hestia_earth_utils-0.16.10/hestia_earth/utils/version.py +0 -1
- hestia_earth_utils-0.16.10/tests/test_blank_node.py +0 -59
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/MANIFEST.in +0 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/README.md +0 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/bin/hestia-format-upload +0 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/bin/hestia-pivot-csv +0 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/hestia_earth/utils/__init__.py +0 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/hestia_earth/utils/api.py +0 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/hestia_earth/utils/calculation_status.py +0 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/hestia_earth/utils/cycle.py +0 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/hestia_earth/utils/date.py +0 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/hestia_earth/utils/descriptive_stats.py +0 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/hestia_earth/utils/emission.py +0 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/hestia_earth/utils/lookup.py +0 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/hestia_earth/utils/lookup_utils.py +0 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/hestia_earth/utils/model.py +0 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/hestia_earth/utils/pipeline.py +0 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/hestia_earth/utils/pivot/__init__.py +0 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/hestia_earth/utils/pivot/_shared.py +0 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/hestia_earth/utils/pivot/pivot_csv.py +0 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/hestia_earth/utils/pivot/pivot_json.py +0 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/hestia_earth/utils/request.py +0 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/hestia_earth/utils/stats.py +0 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/hestia_earth/utils/storage/__init__.py +0 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/hestia_earth/utils/storage/_azure_client.py +0 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/hestia_earth/utils/storage/_local_client.py +0 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/hestia_earth/utils/storage/_s3_client.py +0 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/hestia_earth/utils/storage/_sns_client.py +0 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/hestia_earth/utils/table.py +0 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/hestia_earth/utils/term.py +0 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/hestia_earth_utils.egg-info/SOURCES.txt +0 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/hestia_earth_utils.egg-info/dependency_links.txt +0 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/hestia_earth_utils.egg-info/requires.txt +0 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/hestia_earth_utils.egg-info/top_level.txt +0 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/setup.cfg +0 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/setup.py +0 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/tests/test_api.py +0 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/tests/test_calculation_status.py +0 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/tests/test_cycle.py +0 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/tests/test_date.py +0 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/tests/test_descriptive_stats.py +0 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/tests/test_emission.py +0 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/tests/test_lookup.py +0 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/tests/test_lookup_utils.py +0 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/tests/test_model.py +0 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/tests/test_pipeline.py +0 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/tests/test_request.py +0 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/tests/test_stats.py +0 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/tests/test_table.py +0 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/tests/test_term.py +0 -0
- {hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/tests/test_tools.py +0 -0
|
@@ -8,9 +8,14 @@ from hestia_earth.schema import NodeType
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
def to_precision(number: float, digits: int = 3) -> float:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
try:
|
|
12
|
+
return (
|
|
13
|
+
0
|
|
14
|
+
if not number
|
|
15
|
+
else round(number, digits - int(floor(log10(abs(number)))) - 1)
|
|
16
|
+
)
|
|
17
|
+
except ValueError:
|
|
18
|
+
return number
|
|
14
19
|
|
|
15
20
|
|
|
16
21
|
def non_empty_value(value) -> bool:
|
|
@@ -156,7 +161,8 @@ def is_number(value):
|
|
|
156
161
|
"""
|
|
157
162
|
return all(
|
|
158
163
|
[
|
|
159
|
-
|
|
164
|
+
# True is apparently considered an `int`
|
|
165
|
+
not isinstance(value, bool),
|
|
160
166
|
any([isinstance(value, int), isinstance(value, float)]),
|
|
161
167
|
]
|
|
162
168
|
)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
VERSION = "0.16.12"
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
# import json
|
|
4
|
+
# from pytest import mark
|
|
5
|
+
# from hestia_earth.schema import TermTermType
|
|
6
|
+
|
|
7
|
+
from tests.utils import fixtures_path
|
|
8
|
+
from hestia_earth.utils.blank_node import (
|
|
9
|
+
get_node_value,
|
|
10
|
+
ArrayTreatment,
|
|
11
|
+
# get_blank_nodes_calculation_status,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
fixtures_folder = os.path.join(fixtures_path, "blank_node")
|
|
15
|
+
calculation_status_folder = os.path.join(fixtures_folder, "calculation_status")
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def test_get_node_value():
|
|
19
|
+
assert get_node_value(None) == 0
|
|
20
|
+
|
|
21
|
+
blank_node = {"term": {"termType": "crop", "@id": "wheatGrain"}, "value": [10]}
|
|
22
|
+
assert get_node_value(blank_node, "value", default=None) == 10
|
|
23
|
+
|
|
24
|
+
blank_node = {"term": {"termType": "crop", "@id": "wheatGrain"}, "value": [0]}
|
|
25
|
+
assert get_node_value(blank_node, "value", default=None) == 0
|
|
26
|
+
|
|
27
|
+
blank_node = {"term": {"termType": "crop", "@id": "wheatGrain"}}
|
|
28
|
+
assert get_node_value(blank_node, "value", default=None) is None
|
|
29
|
+
|
|
30
|
+
blank_node = {"term": {"termType": "crop", "@id": "wheatGrain"}, "value": [10, 20]}
|
|
31
|
+
assert get_node_value(blank_node, "value", default=None) == 30
|
|
32
|
+
|
|
33
|
+
blank_node = {"term": {"termType": "crop", "@id": "wheatGrain"}, "value": True}
|
|
34
|
+
assert get_node_value(blank_node, "value", default=None) is True
|
|
35
|
+
|
|
36
|
+
blank_node = {"term": {"termType": "crop", "@id": "wheatGrain"}, "value": 10}
|
|
37
|
+
assert get_node_value(blank_node, "value", default=None) == 10
|
|
38
|
+
|
|
39
|
+
blank_node = {"term": {"termType": "crop", "@id": "wheatGrain"}, "value": None}
|
|
40
|
+
assert get_node_value(blank_node, "value", default=None) is None
|
|
41
|
+
|
|
42
|
+
blank_node = {"term": {"termType": "crop", "@id": "wheatGrain"}, "value": None}
|
|
43
|
+
assert get_node_value(blank_node, "value", default=0) == 0
|
|
44
|
+
|
|
45
|
+
blank_node = {
|
|
46
|
+
"term": {"termType": "crop", "@id": "wheatGrain"},
|
|
47
|
+
"value": [10, None, 20],
|
|
48
|
+
}
|
|
49
|
+
assert (
|
|
50
|
+
get_node_value(blank_node, "value", array_treatment=ArrayTreatment.MEAN) == 15
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
blank_node = {
|
|
54
|
+
"term": {"termType": "crop", "@id": "wheatGrain"},
|
|
55
|
+
"value": [10, None, 20],
|
|
56
|
+
}
|
|
57
|
+
assert get_node_value(blank_node, "value", array_treatment=ArrayTreatment.SUM) == 30
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
# @mark.parametrize(
|
|
61
|
+
# 'folder,list_key,termType',
|
|
62
|
+
# [
|
|
63
|
+
# ('cycle', 'emissions', TermTermType.EMISSION),
|
|
64
|
+
# ]
|
|
65
|
+
# )
|
|
66
|
+
# def test_get_blank_nodes_calculation_status(folder: str, list_key: str, termType: TermTermType):
|
|
67
|
+
# with open(f"{calculation_status_folder}/{folder}/node.jsonld", encoding='utf-8') as f:
|
|
68
|
+
# node = json.load(f)
|
|
69
|
+
|
|
70
|
+
# with open(f"{calculation_status_folder}/{folder}/{list_key}-{termType.value}.json", encoding='utf-8') as f:
|
|
71
|
+
# expected = json.load(f)
|
|
72
|
+
|
|
73
|
+
# result = get_blank_nodes_calculation_status(node, list_key=list_key, termType=termType)
|
|
74
|
+
# assert result == expected, folder
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
VERSION = "0.16.10"
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
# import os
|
|
2
|
-
# import json
|
|
3
|
-
# from pytest import mark
|
|
4
|
-
# from hestia_earth.schema import TermTermType
|
|
5
|
-
|
|
6
|
-
# from tests.utils import fixtures_path
|
|
7
|
-
# from hestia_earth.utils.blank_node import get_node_value, ArrayTreatment, get_blank_nodes_calculation_status
|
|
8
|
-
|
|
9
|
-
# fixtures_folder = os.path.join(fixtures_path, 'blank_node')
|
|
10
|
-
# calculation_status_folder = os.path.join(fixtures_folder, 'calculation_status')
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
# def test_get_node_value():
|
|
14
|
-
# blank_node = {'term': {'termType': 'crop', '@id': 'wheatGrain'}, 'value': [10]}
|
|
15
|
-
# assert get_node_value(blank_node, 'value', default=None) == 10
|
|
16
|
-
|
|
17
|
-
# blank_node = {'term': {'termType': 'crop', '@id': 'wheatGrain'}, 'value': [0]}
|
|
18
|
-
# assert get_node_value(blank_node, 'value', default=None) == 0
|
|
19
|
-
|
|
20
|
-
# blank_node = {'term': {'termType': 'crop', '@id': 'wheatGrain'}}
|
|
21
|
-
# assert get_node_value(blank_node, 'value', default=None) is None
|
|
22
|
-
|
|
23
|
-
# blank_node = {'term': {'termType': 'crop', '@id': 'wheatGrain'}, 'value': [10, 20]}
|
|
24
|
-
# assert get_node_value(blank_node, 'value', default=None) == 15
|
|
25
|
-
|
|
26
|
-
# blank_node = {'term': {'termType': 'crop', '@id': 'wheatGrain'}, 'value': True}
|
|
27
|
-
# assert get_node_value(blank_node, 'value', default=None) is True
|
|
28
|
-
|
|
29
|
-
# blank_node = {'term': {'termType': 'crop', '@id': 'wheatGrain'}, 'value': 10}
|
|
30
|
-
# assert get_node_value(blank_node, 'value', default=None) == 10
|
|
31
|
-
|
|
32
|
-
# blank_node = {'term': {'termType': 'crop', '@id': 'wheatGrain'}, 'value': None}
|
|
33
|
-
# assert get_node_value(blank_node, 'value', default=None) is None
|
|
34
|
-
|
|
35
|
-
# blank_node = {'term': {'termType': 'crop', '@id': 'wheatGrain'}, 'value': None}
|
|
36
|
-
# assert get_node_value(blank_node, 'value', default=0) == 0
|
|
37
|
-
|
|
38
|
-
# blank_node = {'term': {'termType': 'crop', '@id': 'wheatGrain'}, 'value': [10, None, 20]}
|
|
39
|
-
# assert get_node_value(blank_node, 'value', default=None) == 15
|
|
40
|
-
|
|
41
|
-
# blank_node = {'term': {'termType': 'crop', '@id': 'wheatGrain'}, 'value': [10, None, 20]}
|
|
42
|
-
# assert get_node_value(blank_node, 'value', array_treatment=ArrayTreatment.SUM) == 30
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
# @mark.parametrize(
|
|
46
|
-
# 'folder,list_key,termType',
|
|
47
|
-
# [
|
|
48
|
-
# ('cycle', 'emissions', TermTermType.EMISSION),
|
|
49
|
-
# ]
|
|
50
|
-
# )
|
|
51
|
-
# def test_get_blank_nodes_calculation_status(folder: str, list_key: str, termType: TermTermType):
|
|
52
|
-
# with open(f"{calculation_status_folder}/{folder}/node.jsonld", encoding='utf-8') as f:
|
|
53
|
-
# node = json.load(f)
|
|
54
|
-
|
|
55
|
-
# with open(f"{calculation_status_folder}/{folder}/{list_key}-{termType.value}.json", encoding='utf-8') as f:
|
|
56
|
-
# expected = json.load(f)
|
|
57
|
-
|
|
58
|
-
# result = get_blank_nodes_calculation_status(node, list_key=list_key, termType=termType)
|
|
59
|
-
# assert result == expected, folder
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/hestia_earth/utils/calculation_status.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/hestia_earth/utils/descriptive_stats.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/hestia_earth/utils/lookup_utils.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/hestia_earth/utils/pivot/__init__.py
RENAMED
|
File without changes
|
{hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/hestia_earth/utils/pivot/_shared.py
RENAMED
|
File without changes
|
{hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/hestia_earth/utils/pivot/pivot_csv.py
RENAMED
|
File without changes
|
{hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/hestia_earth/utils/pivot/pivot_json.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/hestia_earth/utils/storage/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/hestia_earth/utils/storage/_s3_client.py
RENAMED
|
File without changes
|
{hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/hestia_earth/utils/storage/_sns_client.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/hestia_earth_utils.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/hestia_earth_utils.egg-info/requires.txt
RENAMED
|
File without changes
|
{hestia_earth_utils-0.16.10 → hestia_earth_utils-0.16.12}/hestia_earth_utils.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|