hestia-earth-aggregation 0.21.12__tar.gz → 0.21.13__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.
Files changed (43) hide show
  1. {hestia_earth_aggregation-0.21.12/hestia_earth_aggregation.egg-info → hestia_earth_aggregation-0.21.13}/PKG-INFO +1 -1
  2. {hestia_earth_aggregation-0.21.12 → hestia_earth_aggregation-0.21.13}/hestia_earth/aggregation/aggregate_cycles.py +15 -13
  3. {hestia_earth_aggregation-0.21.12 → hestia_earth_aggregation-0.21.13}/hestia_earth/aggregation/utils/aggregate_weighted.py +2 -12
  4. {hestia_earth_aggregation-0.21.12 → hestia_earth_aggregation-0.21.13}/hestia_earth/aggregation/utils/cycle.py +17 -2
  5. {hestia_earth_aggregation-0.21.12 → hestia_earth_aggregation-0.21.13}/hestia_earth/aggregation/utils/weights.py +16 -1
  6. hestia_earth_aggregation-0.21.13/hestia_earth/aggregation/version.py +1 -0
  7. {hestia_earth_aggregation-0.21.12 → hestia_earth_aggregation-0.21.13/hestia_earth_aggregation.egg-info}/PKG-INFO +1 -1
  8. hestia_earth_aggregation-0.21.12/hestia_earth/aggregation/version.py +0 -1
  9. {hestia_earth_aggregation-0.21.12 → hestia_earth_aggregation-0.21.13}/LICENSE +0 -0
  10. {hestia_earth_aggregation-0.21.12 → hestia_earth_aggregation-0.21.13}/MANIFEST.in +0 -0
  11. {hestia_earth_aggregation-0.21.12 → hestia_earth_aggregation-0.21.13}/README.md +0 -0
  12. {hestia_earth_aggregation-0.21.12 → hestia_earth_aggregation-0.21.13}/hestia_earth/aggregation/__init__.py +0 -0
  13. {hestia_earth_aggregation-0.21.12 → hestia_earth_aggregation-0.21.13}/hestia_earth/aggregation/config/Cycle/processedFood.json +0 -0
  14. {hestia_earth_aggregation-0.21.12 → hestia_earth_aggregation-0.21.13}/hestia_earth/aggregation/log.py +0 -0
  15. {hestia_earth_aggregation-0.21.12 → hestia_earth_aggregation-0.21.13}/hestia_earth/aggregation/recalculate_cycles.py +0 -0
  16. {hestia_earth_aggregation-0.21.12 → hestia_earth_aggregation-0.21.13}/hestia_earth/aggregation/utils/__init__.py +0 -0
  17. {hestia_earth_aggregation-0.21.12 → hestia_earth_aggregation-0.21.13}/hestia_earth/aggregation/utils/aggregate_country_nodes.py +0 -0
  18. {hestia_earth_aggregation-0.21.12 → hestia_earth_aggregation-0.21.13}/hestia_earth/aggregation/utils/blank_node.py +0 -0
  19. {hestia_earth_aggregation-0.21.12 → hestia_earth_aggregation-0.21.13}/hestia_earth/aggregation/utils/combine.py +0 -0
  20. {hestia_earth_aggregation-0.21.12 → hestia_earth_aggregation-0.21.13}/hestia_earth/aggregation/utils/completeness.py +0 -0
  21. {hestia_earth_aggregation-0.21.12 → hestia_earth_aggregation-0.21.13}/hestia_earth/aggregation/utils/covariance.py +0 -0
  22. {hestia_earth_aggregation-0.21.12 → hestia_earth_aggregation-0.21.13}/hestia_earth/aggregation/utils/distribution.py +0 -0
  23. {hestia_earth_aggregation-0.21.12 → hestia_earth_aggregation-0.21.13}/hestia_earth/aggregation/utils/emission.py +0 -0
  24. {hestia_earth_aggregation-0.21.12 → hestia_earth_aggregation-0.21.13}/hestia_earth/aggregation/utils/group.py +0 -0
  25. {hestia_earth_aggregation-0.21.12 → hestia_earth_aggregation-0.21.13}/hestia_earth/aggregation/utils/input.py +0 -0
  26. {hestia_earth_aggregation-0.21.12 → hestia_earth_aggregation-0.21.13}/hestia_earth/aggregation/utils/lookup.py +0 -0
  27. {hestia_earth_aggregation-0.21.12 → hestia_earth_aggregation-0.21.13}/hestia_earth/aggregation/utils/management.py +0 -0
  28. {hestia_earth_aggregation-0.21.12 → hestia_earth_aggregation-0.21.13}/hestia_earth/aggregation/utils/measurement.py +0 -0
  29. {hestia_earth_aggregation-0.21.12 → hestia_earth_aggregation-0.21.13}/hestia_earth/aggregation/utils/practice.py +0 -0
  30. {hestia_earth_aggregation-0.21.12 → hestia_earth_aggregation-0.21.13}/hestia_earth/aggregation/utils/product.py +0 -0
  31. {hestia_earth_aggregation-0.21.12 → hestia_earth_aggregation-0.21.13}/hestia_earth/aggregation/utils/property.py +0 -0
  32. {hestia_earth_aggregation-0.21.12 → hestia_earth_aggregation-0.21.13}/hestia_earth/aggregation/utils/quality_score.py +0 -0
  33. {hestia_earth_aggregation-0.21.12 → hestia_earth_aggregation-0.21.13}/hestia_earth/aggregation/utils/queries.py +0 -0
  34. {hestia_earth_aggregation-0.21.12 → hestia_earth_aggregation-0.21.13}/hestia_earth/aggregation/utils/site.py +0 -0
  35. {hestia_earth_aggregation-0.21.12 → hestia_earth_aggregation-0.21.13}/hestia_earth/aggregation/utils/source.py +0 -0
  36. {hestia_earth_aggregation-0.21.12 → hestia_earth_aggregation-0.21.13}/hestia_earth/aggregation/utils/term.py +0 -0
  37. {hestia_earth_aggregation-0.21.12 → hestia_earth_aggregation-0.21.13}/hestia_earth_aggregation.egg-info/SOURCES.txt +0 -0
  38. {hestia_earth_aggregation-0.21.12 → hestia_earth_aggregation-0.21.13}/hestia_earth_aggregation.egg-info/dependency_links.txt +0 -0
  39. {hestia_earth_aggregation-0.21.12 → hestia_earth_aggregation-0.21.13}/hestia_earth_aggregation.egg-info/requires.txt +0 -0
  40. {hestia_earth_aggregation-0.21.12 → hestia_earth_aggregation-0.21.13}/hestia_earth_aggregation.egg-info/top_level.txt +0 -0
  41. {hestia_earth_aggregation-0.21.12 → hestia_earth_aggregation-0.21.13}/setup.cfg +0 -0
  42. {hestia_earth_aggregation-0.21.12 → hestia_earth_aggregation-0.21.13}/setup.py +0 -0
  43. {hestia_earth_aggregation-0.21.12 → hestia_earth_aggregation-0.21.13}/tests/test_aggregation.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hestia_earth_aggregation
3
- Version: 0.21.12
3
+ Version: 0.21.13
4
4
  Summary: HESTIA's aggregation engine.
5
5
  Home-page: https://gitlab.com/hestia-earth/hestia-aggregation-engine
6
6
  Author: HESTIA Team
@@ -1,38 +1,38 @@
1
1
  from typing import Tuple
2
2
  from hestia_earth.utils.tools import non_empty_list
3
3
 
4
- from hestia_earth.aggregation.log import logger, log_memory_usage
5
- from hestia_earth.aggregation.utils import CYCLE_AGGREGATION_KEYS, SITE_AGGREGATION_KEYS
6
- from hestia_earth.aggregation.utils.term import is_global
7
- from hestia_earth.aggregation.utils.queries import (
4
+ from .log import logger, log_memory_usage
5
+ from .utils import CYCLE_AGGREGATION_KEYS, SITE_AGGREGATION_KEYS
6
+ from .utils.term import is_global
7
+ from .utils.queries import (
8
8
  find_global_nodes,
9
9
  find_country_nodes,
10
10
  download_site,
11
11
  )
12
- from hestia_earth.aggregation.utils.group import group_blank_nodes
13
- from hestia_earth.aggregation.utils.blank_node import cleanup_node_blank_nodes
14
- from hestia_earth.aggregation.utils.aggregate_weighted import (
12
+ from .utils.group import group_blank_nodes
13
+ from .utils.blank_node import cleanup_node_blank_nodes
14
+ from .utils.aggregate_weighted import (
15
15
  aggregate as aggregate_weighted,
16
16
  )
17
- from hestia_earth.aggregation.utils.aggregate_country_nodes import aggregate_cycles
18
- from hestia_earth.aggregation.utils.weights import (
17
+ from .utils.aggregate_country_nodes import aggregate_cycles
18
+ from .utils.weights import (
19
19
  country_weights,
20
20
  country_weight_node_id,
21
21
  world_weights,
22
22
  world_weight_node_id,
23
23
  )
24
- from hestia_earth.aggregation.utils.site import (
24
+ from .utils.site import (
25
25
  format_site,
26
26
  format_site_description_weighted,
27
27
  )
28
- from hestia_earth.aggregation.utils.cycle import (
28
+ from .utils.cycle import (
29
29
  aggregate_with_matrix,
30
30
  format_for_grouping,
31
31
  format_terms_results,
32
32
  format_country_results,
33
33
  update_cycle,
34
34
  )
35
- from hestia_earth.aggregation.utils.covariance import (
35
+ from .utils.covariance import (
36
36
  init_covariance_files,
37
37
  remove_covariance_files,
38
38
  generate_covariance_country,
@@ -83,7 +83,9 @@ def _aggregate_country(
83
83
  sites, weights, use_description=not is_global(country)
84
84
  )
85
85
 
86
- cycle_data = format_country_results(cycle_data, product, country, aggregated_site)
86
+ cycle_data = format_country_results(
87
+ cycle_data, product, country, aggregated_site, weights
88
+ )
87
89
  aggregated_cycle = update_cycle(
88
90
  country, start_year, end_year, source, functional_unit, False
89
91
  )(cycle_data)
@@ -14,10 +14,7 @@ from .emission import get_method_tier, get_method_model
14
14
  from .property import aggregate_properties
15
15
  from .completeness import blank_node_completeness_key
16
16
  from .distribution import sample_weighted_distributions, _nb_iterations
17
-
18
-
19
- def _format_weight_key(key: str):
20
- return ", ".join(key.split("_")).capitalize()
17
+ from .weights import format_weights
21
18
 
22
19
 
23
20
  def _format_description(completeness_key: str, weights: dict):
@@ -26,14 +23,7 @@ def _format_description(completeness_key: str, weights: dict):
26
23
  for w in weights.values()
27
24
  if w.get("completeness", {}).get(completeness_key, False)
28
25
  ]
29
- total = list_sum(non_empty_list([w.get("weight") for w in complete_weights]))
30
- description = ";".join(
31
- [
32
- f"{_format_weight_key(weight.get('key'))}: {round(weight.get('weight') * 100 / total, 2)}"
33
- for weight in complete_weights
34
- if weight.get("key")
35
- ]
36
- )
26
+ description = format_weights(complete_weights)
37
27
  return {"description": description}
38
28
 
39
29
 
@@ -39,6 +39,7 @@ from .emission import new_emission
39
39
  from .input import new_input
40
40
  from .practice import new_practice, organic_practice
41
41
  from .product import new_product
42
+ from .weights import format_weights
42
43
 
43
44
  _MEAN_DATE_DESCRIPTION = (
44
45
  "Additional notes: the mean endDate of all aggregated Cycles is "
@@ -61,6 +62,11 @@ def _combine_mean_dates(cycles: list):
61
62
  return _mean_date(dates)
62
63
 
63
64
 
65
+ def _aggregated_weights(weights: dict):
66
+ description = format_weights(weights.values())
67
+ return ("Sub-aggregation weighting: " + description) if description else ""
68
+
69
+
64
70
  def is_organic(cycle: dict):
65
71
  term_type = TermTermType.STANDARDSLABELS
66
72
  practices = filter_list_term_type(cycle.get("practices", []), term_type)
@@ -234,7 +240,9 @@ def format_terms_results(data: dict, product: dict, country: dict):
234
240
  return None
235
241
 
236
242
 
237
- def format_country_results(data: dict, product: dict, country: dict, site: dict):
243
+ def format_country_results(
244
+ data: dict, product: dict, country: dict, site: dict, weights: dict
245
+ ):
238
246
  inputs = data.get("inputs", [])
239
247
  practices = data.get("practices", [])
240
248
  products = data.get("products", [])
@@ -247,7 +255,14 @@ def format_country_results(data: dict, product: dict, country: dict, site: dict)
247
255
  completeness = aggregate_completeness(data.get("node-completeness", []))
248
256
  return remove_empty_fields(
249
257
  {
250
- "description": _MEAN_DATE_DESCRIPTION + _combine_mean_dates(cycles),
258
+ "description": ". ".join(
259
+ non_empty_list(
260
+ [
261
+ _aggregated_weights(weights),
262
+ _MEAN_DATE_DESCRIPTION + _combine_mean_dates(cycles),
263
+ ]
264
+ )
265
+ ),
251
266
  "name": _cycle_name(cycle, primary_product, False, False, False),
252
267
  "id": _cycle_id(cycle, primary_product, False, False, False),
253
268
  **_format_results(
@@ -1,6 +1,6 @@
1
1
  from functools import reduce, lru_cache
2
2
  from hestia_earth.utils.lookup import download_lookup, get_table_value
3
- from hestia_earth.utils.tools import to_precision, non_empty_list
3
+ from hestia_earth.utils.tools import to_precision, non_empty_list, list_sum
4
4
 
5
5
  from hestia_earth.aggregation.log import debugWeights, debugRequirements
6
6
  from .lookup import (
@@ -16,6 +16,21 @@ from .term import (
16
16
  )
17
17
 
18
18
 
19
+ def _format_weight_key(key: str):
20
+ return ", ".join(key.split("_")).capitalize()
21
+
22
+
23
+ def format_weights(weights: list):
24
+ total = list_sum(non_empty_list([w.get("weight") for w in weights]))
25
+ return ";".join(
26
+ [
27
+ f"{_format_weight_key(weight.get('key'))}: {round(weight.get('weight') * 100 / total, 2)}"
28
+ for weight in weights
29
+ if weight.get("key")
30
+ ]
31
+ )
32
+
33
+
19
34
  def _country_organic_weight(country_id: str, start_year: int, end_year: int):
20
35
  lookup = download_lookup("region-standardsLabels-isOrganic.csv")
21
36
  data = get_table_value(lookup, "term.id", country_id, "organic")
@@ -0,0 +1 @@
1
+ VERSION = "0.21.13"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hestia_earth_aggregation
3
- Version: 0.21.12
3
+ Version: 0.21.13
4
4
  Summary: HESTIA's aggregation engine.
5
5
  Home-page: https://gitlab.com/hestia-earth/hestia-aggregation-engine
6
6
  Author: HESTIA Team
@@ -1 +0,0 @@
1
- VERSION = "0.21.12"