hestia-earth-aggregation 0.21.13__tar.gz → 0.21.14__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_aggregation-0.21.13/hestia_earth_aggregation.egg-info → hestia_earth_aggregation-0.21.14}/PKG-INFO +1 -1
- {hestia_earth_aggregation-0.21.13 → hestia_earth_aggregation-0.21.14}/hestia_earth/aggregation/utils/aggregate_country_nodes.py +33 -1
- {hestia_earth_aggregation-0.21.13 → hestia_earth_aggregation-0.21.14}/hestia_earth/aggregation/utils/aggregate_weighted.py +8 -1
- {hestia_earth_aggregation-0.21.13 → hestia_earth_aggregation-0.21.14}/hestia_earth/aggregation/utils/completeness.py +0 -1
- hestia_earth_aggregation-0.21.14/hestia_earth/aggregation/version.py +1 -0
- {hestia_earth_aggregation-0.21.13 → hestia_earth_aggregation-0.21.14/hestia_earth_aggregation.egg-info}/PKG-INFO +1 -1
- hestia_earth_aggregation-0.21.13/hestia_earth/aggregation/version.py +0 -1
- {hestia_earth_aggregation-0.21.13 → hestia_earth_aggregation-0.21.14}/LICENSE +0 -0
- {hestia_earth_aggregation-0.21.13 → hestia_earth_aggregation-0.21.14}/MANIFEST.in +0 -0
- {hestia_earth_aggregation-0.21.13 → hestia_earth_aggregation-0.21.14}/README.md +0 -0
- {hestia_earth_aggregation-0.21.13 → hestia_earth_aggregation-0.21.14}/hestia_earth/aggregation/__init__.py +0 -0
- {hestia_earth_aggregation-0.21.13 → hestia_earth_aggregation-0.21.14}/hestia_earth/aggregation/aggregate_cycles.py +0 -0
- {hestia_earth_aggregation-0.21.13 → hestia_earth_aggregation-0.21.14}/hestia_earth/aggregation/config/Cycle/processedFood.json +0 -0
- {hestia_earth_aggregation-0.21.13 → hestia_earth_aggregation-0.21.14}/hestia_earth/aggregation/log.py +0 -0
- {hestia_earth_aggregation-0.21.13 → hestia_earth_aggregation-0.21.14}/hestia_earth/aggregation/recalculate_cycles.py +0 -0
- {hestia_earth_aggregation-0.21.13 → hestia_earth_aggregation-0.21.14}/hestia_earth/aggregation/utils/__init__.py +0 -0
- {hestia_earth_aggregation-0.21.13 → hestia_earth_aggregation-0.21.14}/hestia_earth/aggregation/utils/blank_node.py +0 -0
- {hestia_earth_aggregation-0.21.13 → hestia_earth_aggregation-0.21.14}/hestia_earth/aggregation/utils/combine.py +0 -0
- {hestia_earth_aggregation-0.21.13 → hestia_earth_aggregation-0.21.14}/hestia_earth/aggregation/utils/covariance.py +0 -0
- {hestia_earth_aggregation-0.21.13 → hestia_earth_aggregation-0.21.14}/hestia_earth/aggregation/utils/cycle.py +0 -0
- {hestia_earth_aggregation-0.21.13 → hestia_earth_aggregation-0.21.14}/hestia_earth/aggregation/utils/distribution.py +0 -0
- {hestia_earth_aggregation-0.21.13 → hestia_earth_aggregation-0.21.14}/hestia_earth/aggregation/utils/emission.py +0 -0
- {hestia_earth_aggregation-0.21.13 → hestia_earth_aggregation-0.21.14}/hestia_earth/aggregation/utils/group.py +0 -0
- {hestia_earth_aggregation-0.21.13 → hestia_earth_aggregation-0.21.14}/hestia_earth/aggregation/utils/input.py +0 -0
- {hestia_earth_aggregation-0.21.13 → hestia_earth_aggregation-0.21.14}/hestia_earth/aggregation/utils/lookup.py +0 -0
- {hestia_earth_aggregation-0.21.13 → hestia_earth_aggregation-0.21.14}/hestia_earth/aggregation/utils/management.py +0 -0
- {hestia_earth_aggregation-0.21.13 → hestia_earth_aggregation-0.21.14}/hestia_earth/aggregation/utils/measurement.py +0 -0
- {hestia_earth_aggregation-0.21.13 → hestia_earth_aggregation-0.21.14}/hestia_earth/aggregation/utils/practice.py +0 -0
- {hestia_earth_aggregation-0.21.13 → hestia_earth_aggregation-0.21.14}/hestia_earth/aggregation/utils/product.py +0 -0
- {hestia_earth_aggregation-0.21.13 → hestia_earth_aggregation-0.21.14}/hestia_earth/aggregation/utils/property.py +0 -0
- {hestia_earth_aggregation-0.21.13 → hestia_earth_aggregation-0.21.14}/hestia_earth/aggregation/utils/quality_score.py +0 -0
- {hestia_earth_aggregation-0.21.13 → hestia_earth_aggregation-0.21.14}/hestia_earth/aggregation/utils/queries.py +0 -0
- {hestia_earth_aggregation-0.21.13 → hestia_earth_aggregation-0.21.14}/hestia_earth/aggregation/utils/site.py +0 -0
- {hestia_earth_aggregation-0.21.13 → hestia_earth_aggregation-0.21.14}/hestia_earth/aggregation/utils/source.py +0 -0
- {hestia_earth_aggregation-0.21.13 → hestia_earth_aggregation-0.21.14}/hestia_earth/aggregation/utils/term.py +0 -0
- {hestia_earth_aggregation-0.21.13 → hestia_earth_aggregation-0.21.14}/hestia_earth/aggregation/utils/weights.py +0 -0
- {hestia_earth_aggregation-0.21.13 → hestia_earth_aggregation-0.21.14}/hestia_earth_aggregation.egg-info/SOURCES.txt +0 -0
- {hestia_earth_aggregation-0.21.13 → hestia_earth_aggregation-0.21.14}/hestia_earth_aggregation.egg-info/dependency_links.txt +0 -0
- {hestia_earth_aggregation-0.21.13 → hestia_earth_aggregation-0.21.14}/hestia_earth_aggregation.egg-info/requires.txt +0 -0
- {hestia_earth_aggregation-0.21.13 → hestia_earth_aggregation-0.21.14}/hestia_earth_aggregation.egg-info/top_level.txt +0 -0
- {hestia_earth_aggregation-0.21.13 → hestia_earth_aggregation-0.21.14}/setup.cfg +0 -0
- {hestia_earth_aggregation-0.21.13 → hestia_earth_aggregation-0.21.14}/setup.py +0 -0
- {hestia_earth_aggregation-0.21.13 → hestia_earth_aggregation-0.21.14}/tests/test_aggregation.py +0 -0
|
@@ -10,6 +10,7 @@ from hestia_earth.utils.tools import (
|
|
|
10
10
|
flatten,
|
|
11
11
|
is_number,
|
|
12
12
|
is_boolean,
|
|
13
|
+
current_time_ms,
|
|
13
14
|
)
|
|
14
15
|
from hestia_earth.utils.blank_node import (
|
|
15
16
|
ArrayTreatment,
|
|
@@ -292,6 +293,7 @@ def _group_cycle_blank_nodes(
|
|
|
292
293
|
end_year: int = None,
|
|
293
294
|
):
|
|
294
295
|
def grouper(group: dict, list_key: str) -> Dict[str, Dict[str, BlankNodeFormatted]]:
|
|
296
|
+
now = current_time_ms()
|
|
295
297
|
blank_nodes = _filter_blank_nodes(cycle, list_key, start_year, end_year)
|
|
296
298
|
values = reduce(
|
|
297
299
|
_group_cycle_blank_node(cycle, product, product_value), blank_nodes, {}
|
|
@@ -300,6 +302,11 @@ def _group_cycle_blank_nodes(
|
|
|
300
302
|
group[list_key] = {
|
|
301
303
|
k: v | _compute_blank_node_stats(v) for k, v in values.items()
|
|
302
304
|
}
|
|
305
|
+
logger.debug(
|
|
306
|
+
"function=_group_cycle_blank_nodes, list_key=%s, time=%s",
|
|
307
|
+
list_key,
|
|
308
|
+
current_time_ms() - now,
|
|
309
|
+
)
|
|
303
310
|
return group
|
|
304
311
|
|
|
305
312
|
return grouper
|
|
@@ -405,6 +412,7 @@ def _combine_cycle_blank_nodes(
|
|
|
405
412
|
cycles: List[CycleFormatted], completeness: Dict[str, int], cycle_count: int
|
|
406
413
|
):
|
|
407
414
|
def combine(group: dict, list_key: str):
|
|
415
|
+
now = current_time_ms()
|
|
408
416
|
# get all possible keys first, then group each key values into a single blank node
|
|
409
417
|
keys = set(flatten([list(cycle.get(list_key, {}).keys()) for cycle in cycles]))
|
|
410
418
|
group[list_key] = reduce(
|
|
@@ -412,6 +420,11 @@ def _combine_cycle_blank_nodes(
|
|
|
412
420
|
keys,
|
|
413
421
|
{},
|
|
414
422
|
)
|
|
423
|
+
logger.debug(
|
|
424
|
+
"function=_combine_cycle_blank_nodes, list_key=%s, time=%s",
|
|
425
|
+
list_key,
|
|
426
|
+
current_time_ms() - now,
|
|
427
|
+
)
|
|
415
428
|
return group
|
|
416
429
|
|
|
417
430
|
return combine
|
|
@@ -511,8 +524,14 @@ def _group_site_blank_nodes(
|
|
|
511
524
|
site: SiteJSONLD, start_year: int = None, end_year: int = None
|
|
512
525
|
):
|
|
513
526
|
def grouper(group: dict, list_key: str) -> Dict[str, BlankNodeFormatted]:
|
|
527
|
+
now = current_time_ms()
|
|
514
528
|
blank_nodes = _filter_blank_nodes(site, list_key, start_year, end_year)
|
|
515
529
|
group[list_key] = reduce(_group_site_blank_node(), blank_nodes, {})
|
|
530
|
+
logger.debug(
|
|
531
|
+
"function=_group_site_blank_nodes, list_key=%s, time=%s",
|
|
532
|
+
list_key,
|
|
533
|
+
current_time_ms() - now,
|
|
534
|
+
)
|
|
516
535
|
return group
|
|
517
536
|
|
|
518
537
|
return grouper
|
|
@@ -559,9 +578,15 @@ def _combine_site_blank_node(sites: List[SiteFormatted], list_key: str):
|
|
|
559
578
|
|
|
560
579
|
def _combine_site_blank_nodes(sites: List[SiteFormatted]):
|
|
561
580
|
def combine(group: dict, list_key: str):
|
|
581
|
+
now = current_time_ms()
|
|
562
582
|
# get all possible keys first, then group each key values into a single blank node
|
|
563
583
|
keys = set(flatten([list(site.get(list_key, {}).keys()) for site in sites]))
|
|
564
584
|
group[list_key] = reduce(_combine_site_blank_node(sites, list_key), keys, {})
|
|
585
|
+
logger.debug(
|
|
586
|
+
"function=_combine_site_blank_nodes, list_key=%s, time=%s",
|
|
587
|
+
list_key,
|
|
588
|
+
current_time_ms() - now,
|
|
589
|
+
)
|
|
565
590
|
return group
|
|
566
591
|
|
|
567
592
|
return combine
|
|
@@ -647,9 +672,16 @@ def _aggregate_formatted(
|
|
|
647
672
|
data: Union[CycleFormatted, SiteFormatted], aggregated_keys: List[str]
|
|
648
673
|
):
|
|
649
674
|
def aggregate(key: str):
|
|
675
|
+
now = current_time_ms()
|
|
650
676
|
values = data.get(key, {}).values()
|
|
651
677
|
logger.debug(f"Aggregating {len(values)} {key}...")
|
|
652
|
-
|
|
678
|
+
values = list(map(_aggregate_blank_node, values))
|
|
679
|
+
logger.debug(
|
|
680
|
+
"function=_aggregate_formatted, key=%s, time=%s",
|
|
681
|
+
key,
|
|
682
|
+
current_time_ms() - now,
|
|
683
|
+
)
|
|
684
|
+
return values
|
|
653
685
|
|
|
654
686
|
return reduce(lambda group, key: group | {key: aggregate(key)}, aggregated_keys, {})
|
|
655
687
|
|
|
@@ -6,9 +6,11 @@ from hestia_earth.utils.tools import (
|
|
|
6
6
|
list_sum,
|
|
7
7
|
list_average,
|
|
8
8
|
is_boolean,
|
|
9
|
+
current_time_ms,
|
|
9
10
|
)
|
|
10
11
|
from hestia_earth.utils.blank_node import get_node_value
|
|
11
12
|
|
|
13
|
+
from hestia_earth.aggregation.log import logger
|
|
12
14
|
from . import weighted_average, _min, _max, _sd, format_evs, pick
|
|
13
15
|
from .emission import get_method_tier, get_method_model
|
|
14
16
|
from .property import aggregate_properties
|
|
@@ -188,14 +190,19 @@ def _aggregate_nodes(
|
|
|
188
190
|
aggregate_keys: List[str], data: dict, weights: dict, missing_weights_node_id_func
|
|
189
191
|
):
|
|
190
192
|
def aggregate_single(key: str):
|
|
193
|
+
now = current_time_ms()
|
|
191
194
|
aggregates_map: dict = data.get(key)
|
|
192
195
|
terms = aggregates_map.keys()
|
|
193
|
-
|
|
196
|
+
values = non_empty_list(
|
|
194
197
|
map(
|
|
195
198
|
_aggregate_term(aggregates_map, weights, missing_weights_node_id_func),
|
|
196
199
|
terms,
|
|
197
200
|
)
|
|
198
201
|
)
|
|
202
|
+
logger.debug(
|
|
203
|
+
"function=_aggregate_nodes, key=%s, time=%s", key, current_time_ms() - now
|
|
204
|
+
)
|
|
205
|
+
return values
|
|
199
206
|
|
|
200
207
|
return reduce(
|
|
201
208
|
lambda prev, curr: prev | {curr: aggregate_single(curr)}, aggregate_keys, {}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
VERSION = "0.21.14"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
VERSION = "0.21.13"
|
|
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
|
|
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
|
{hestia_earth_aggregation-0.21.13 → hestia_earth_aggregation-0.21.14}/tests/test_aggregation.py
RENAMED
|
File without changes
|