hestia-earth-utils 0.16.2__tar.gz → 0.16.3__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.2/hestia_earth_utils.egg-info → hestia_earth_utils-0.16.3}/PKG-INFO +1 -1
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/hestia_earth/utils/lookup.py +4 -2
- hestia_earth_utils-0.16.3/hestia_earth/utils/version.py +1 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3/hestia_earth_utils.egg-info}/PKG-INFO +1 -1
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/tests/test_lookup.py +10 -4
- hestia_earth_utils-0.16.2/hestia_earth/utils/version.py +0 -1
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/MANIFEST.in +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/README.md +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/bin/hestia-format-upload +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/bin/hestia-pivot-csv +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/hestia_earth/utils/__init__.py +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/hestia_earth/utils/api.py +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/hestia_earth/utils/blank_node.py +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/hestia_earth/utils/calculation_status.py +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/hestia_earth/utils/csv_utils.py +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/hestia_earth/utils/cycle.py +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/hestia_earth/utils/date.py +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/hestia_earth/utils/descriptive_stats.py +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/hestia_earth/utils/emission.py +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/hestia_earth/utils/lookup_utils.py +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/hestia_earth/utils/model.py +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/hestia_earth/utils/pipeline.py +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/hestia_earth/utils/pivot/__init__.py +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/hestia_earth/utils/pivot/_shared.py +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/hestia_earth/utils/pivot/pivot_csv.py +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/hestia_earth/utils/pivot/pivot_json.py +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/hestia_earth/utils/request.py +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/hestia_earth/utils/stats.py +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/hestia_earth/utils/storage/__init__.py +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/hestia_earth/utils/storage/_azure_client.py +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/hestia_earth/utils/storage/_local_client.py +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/hestia_earth/utils/storage/_s3_client.py +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/hestia_earth/utils/storage/_sns_client.py +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/hestia_earth/utils/table.py +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/hestia_earth/utils/term.py +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/hestia_earth/utils/tools.py +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/hestia_earth_utils.egg-info/SOURCES.txt +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/hestia_earth_utils.egg-info/dependency_links.txt +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/hestia_earth_utils.egg-info/requires.txt +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/hestia_earth_utils.egg-info/top_level.txt +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/setup.cfg +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/setup.py +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/tests/test_api.py +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/tests/test_blank_node.py +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/tests/test_calculation_status.py +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/tests/test_cycle.py +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/tests/test_date.py +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/tests/test_descriptive_stats.py +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/tests/test_emission.py +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/tests/test_lookup_utils.py +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/tests/test_model.py +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/tests/test_pipeline.py +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/tests/test_request.py +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/tests/test_stats.py +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/tests/test_table.py +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/tests/test_term.py +0 -0
- {hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/tests/test_tools.py +0 -0
|
@@ -142,7 +142,7 @@ def _get_multiple_table_values(data: Union[dict, numpy.recarray], col_match: str
|
|
|
142
142
|
return reduce(reducer, enumerate(col_match), data)[col_val][0]
|
|
143
143
|
|
|
144
144
|
|
|
145
|
-
def get_table_value(lookup: Union[dict, numpy.recarray], col_match: str, col_match_with, col_val):
|
|
145
|
+
def get_table_value(lookup: Union[dict, numpy.recarray], col_match: str, col_match_with, col_val, default_value=''):
|
|
146
146
|
"""
|
|
147
147
|
Get a value matched by one or more columns from a `numpy.recarray`.
|
|
148
148
|
|
|
@@ -158,6 +158,8 @@ def get_table_value(lookup: Union[dict, numpy.recarray], col_match: str, col_mat
|
|
|
158
158
|
Can be a single `str` or a list of `str`. If a list is used, must be the same length as `col_match`.
|
|
159
159
|
col_val: str
|
|
160
160
|
The column which contains the value to look for.
|
|
161
|
+
default_value : Any
|
|
162
|
+
A value to return when none if found in the data.
|
|
161
163
|
|
|
162
164
|
Returns
|
|
163
165
|
-------
|
|
@@ -170,7 +172,7 @@ def get_table_value(lookup: Union[dict, numpy.recarray], col_match: str, col_mat
|
|
|
170
172
|
_get_single_table_value(lookup, col_match, col_match_with, col_val) if single else
|
|
171
173
|
_get_multiple_table_values(lookup, col_match, col_match_with, col_val)
|
|
172
174
|
)
|
|
173
|
-
return
|
|
175
|
+
return default_value if is_missing_value(value) else _parse_value(value)
|
|
174
176
|
except Exception:
|
|
175
177
|
return None
|
|
176
178
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
VERSION = '0.16.3'
|
|
@@ -56,11 +56,11 @@ def test_get_table_value():
|
|
|
56
56
|
|
|
57
57
|
def test_get_table_value_empty():
|
|
58
58
|
lookup = load_lookup(f"{fixtures_path}/lookup.csv")
|
|
59
|
-
assert get_table_value(lookup, column_name('Col1'), 'val10', column_name('Col4')) is None
|
|
60
|
-
assert get_table_value(lookup, column_name('Col2'), 'val22', column_name('Col1'))
|
|
59
|
+
assert get_table_value(lookup, column_name('Col1'), 'val10', column_name('Col4'), default_value=None) is None
|
|
60
|
+
assert get_table_value(lookup, column_name('Col2'), 'val22', column_name('Col1')) == ''
|
|
61
61
|
|
|
62
62
|
lookup = download_lookup('crop.csv')
|
|
63
|
-
assert get_table_value(lookup, 'termid', 'genericCropSeed', column_name('Plantation_density'))
|
|
63
|
+
assert get_table_value(lookup, 'termid', 'genericCropSeed', column_name('Plantation_density')) == ''
|
|
64
64
|
|
|
65
65
|
|
|
66
66
|
def test_find_term_ids_by():
|
|
@@ -83,7 +83,7 @@ def test_download_lookup_without_index():
|
|
|
83
83
|
def test_handle_missing_float_value():
|
|
84
84
|
filename = 'measurement.csv'
|
|
85
85
|
lookup = download_lookup(filename)
|
|
86
|
-
assert get_table_value(lookup, 'termid', 'rainfallPeriod', 'maximum')
|
|
86
|
+
assert get_table_value(lookup, 'termid', 'rainfallPeriod', 'maximum') == ''
|
|
87
87
|
|
|
88
88
|
|
|
89
89
|
def test_handle_missing_string_value():
|
|
@@ -148,3 +148,9 @@ def test_lookup_term_ids():
|
|
|
148
148
|
|
|
149
149
|
def test_lookup_columns():
|
|
150
150
|
assert 'termid' in lookup_columns(download_lookup('crop.csv'))
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def test_get_data_advanced():
|
|
154
|
+
lookup = download_lookup('liveAnimal.csv')
|
|
155
|
+
value = get_table_value(lookup, 'termid', 'sheepRam', column_name('ratioCPregnancyNetEnergyPregnancyIpcc2019'))
|
|
156
|
+
assert value == ''
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
VERSION = '0.16.2'
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/hestia_earth/utils/calculation_status.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/hestia_earth/utils/descriptive_stats.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/hestia_earth/utils/pivot/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/hestia_earth/utils/pivot/pivot_csv.py
RENAMED
|
File without changes
|
{hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/hestia_earth/utils/pivot/pivot_json.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/hestia_earth/utils/storage/__init__.py
RENAMED
|
File without changes
|
{hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/hestia_earth/utils/storage/_azure_client.py
RENAMED
|
File without changes
|
{hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/hestia_earth/utils/storage/_local_client.py
RENAMED
|
File without changes
|
{hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/hestia_earth/utils/storage/_s3_client.py
RENAMED
|
File without changes
|
{hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/hestia_earth/utils/storage/_sns_client.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/hestia_earth_utils.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/hestia_earth_utils.egg-info/requires.txt
RENAMED
|
File without changes
|
{hestia_earth_utils-0.16.2 → hestia_earth_utils-0.16.3}/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
|