hestia-earth-aggregation 0.21.8__tar.gz → 0.21.9__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.8/hestia_earth_aggregation.egg-info → hestia_earth_aggregation-0.21.9}/PKG-INFO +1 -1
  2. {hestia_earth_aggregation-0.21.8 → hestia_earth_aggregation-0.21.9}/hestia_earth/aggregation/__init__.py +11 -1
  3. {hestia_earth_aggregation-0.21.8 → hestia_earth_aggregation-0.21.9}/hestia_earth/aggregation/aggregate_cycles.py +16 -2
  4. {hestia_earth_aggregation-0.21.8 → hestia_earth_aggregation-0.21.9}/hestia_earth/aggregation/utils/aggregate_country_nodes.py +13 -3
  5. {hestia_earth_aggregation-0.21.8 → hestia_earth_aggregation-0.21.9}/hestia_earth/aggregation/utils/covariance.py +1 -1
  6. hestia_earth_aggregation-0.21.9/hestia_earth/aggregation/version.py +1 -0
  7. {hestia_earth_aggregation-0.21.8 → hestia_earth_aggregation-0.21.9/hestia_earth_aggregation.egg-info}/PKG-INFO +1 -1
  8. hestia_earth_aggregation-0.21.8/hestia_earth/aggregation/version.py +0 -1
  9. {hestia_earth_aggregation-0.21.8 → hestia_earth_aggregation-0.21.9}/LICENSE +0 -0
  10. {hestia_earth_aggregation-0.21.8 → hestia_earth_aggregation-0.21.9}/MANIFEST.in +0 -0
  11. {hestia_earth_aggregation-0.21.8 → hestia_earth_aggregation-0.21.9}/README.md +0 -0
  12. {hestia_earth_aggregation-0.21.8 → hestia_earth_aggregation-0.21.9}/hestia_earth/aggregation/config/Cycle/processedFood.json +0 -0
  13. {hestia_earth_aggregation-0.21.8 → hestia_earth_aggregation-0.21.9}/hestia_earth/aggregation/log.py +0 -0
  14. {hestia_earth_aggregation-0.21.8 → hestia_earth_aggregation-0.21.9}/hestia_earth/aggregation/recalculate_cycles.py +0 -0
  15. {hestia_earth_aggregation-0.21.8 → hestia_earth_aggregation-0.21.9}/hestia_earth/aggregation/utils/__init__.py +0 -0
  16. {hestia_earth_aggregation-0.21.8 → hestia_earth_aggregation-0.21.9}/hestia_earth/aggregation/utils/aggregate_weighted.py +0 -0
  17. {hestia_earth_aggregation-0.21.8 → hestia_earth_aggregation-0.21.9}/hestia_earth/aggregation/utils/blank_node.py +0 -0
  18. {hestia_earth_aggregation-0.21.8 → hestia_earth_aggregation-0.21.9}/hestia_earth/aggregation/utils/combine.py +0 -0
  19. {hestia_earth_aggregation-0.21.8 → hestia_earth_aggregation-0.21.9}/hestia_earth/aggregation/utils/completeness.py +0 -0
  20. {hestia_earth_aggregation-0.21.8 → hestia_earth_aggregation-0.21.9}/hestia_earth/aggregation/utils/cycle.py +0 -0
  21. {hestia_earth_aggregation-0.21.8 → hestia_earth_aggregation-0.21.9}/hestia_earth/aggregation/utils/distribution.py +0 -0
  22. {hestia_earth_aggregation-0.21.8 → hestia_earth_aggregation-0.21.9}/hestia_earth/aggregation/utils/emission.py +0 -0
  23. {hestia_earth_aggregation-0.21.8 → hestia_earth_aggregation-0.21.9}/hestia_earth/aggregation/utils/group.py +0 -0
  24. {hestia_earth_aggregation-0.21.8 → hestia_earth_aggregation-0.21.9}/hestia_earth/aggregation/utils/input.py +0 -0
  25. {hestia_earth_aggregation-0.21.8 → hestia_earth_aggregation-0.21.9}/hestia_earth/aggregation/utils/lookup.py +0 -0
  26. {hestia_earth_aggregation-0.21.8 → hestia_earth_aggregation-0.21.9}/hestia_earth/aggregation/utils/management.py +0 -0
  27. {hestia_earth_aggregation-0.21.8 → hestia_earth_aggregation-0.21.9}/hestia_earth/aggregation/utils/measurement.py +0 -0
  28. {hestia_earth_aggregation-0.21.8 → hestia_earth_aggregation-0.21.9}/hestia_earth/aggregation/utils/practice.py +0 -0
  29. {hestia_earth_aggregation-0.21.8 → hestia_earth_aggregation-0.21.9}/hestia_earth/aggregation/utils/product.py +0 -0
  30. {hestia_earth_aggregation-0.21.8 → hestia_earth_aggregation-0.21.9}/hestia_earth/aggregation/utils/property.py +0 -0
  31. {hestia_earth_aggregation-0.21.8 → hestia_earth_aggregation-0.21.9}/hestia_earth/aggregation/utils/quality_score.py +0 -0
  32. {hestia_earth_aggregation-0.21.8 → hestia_earth_aggregation-0.21.9}/hestia_earth/aggregation/utils/queries.py +0 -0
  33. {hestia_earth_aggregation-0.21.8 → hestia_earth_aggregation-0.21.9}/hestia_earth/aggregation/utils/site.py +0 -0
  34. {hestia_earth_aggregation-0.21.8 → hestia_earth_aggregation-0.21.9}/hestia_earth/aggregation/utils/source.py +0 -0
  35. {hestia_earth_aggregation-0.21.8 → hestia_earth_aggregation-0.21.9}/hestia_earth/aggregation/utils/term.py +0 -0
  36. {hestia_earth_aggregation-0.21.8 → hestia_earth_aggregation-0.21.9}/hestia_earth/aggregation/utils/weights.py +0 -0
  37. {hestia_earth_aggregation-0.21.8 → hestia_earth_aggregation-0.21.9}/hestia_earth_aggregation.egg-info/SOURCES.txt +0 -0
  38. {hestia_earth_aggregation-0.21.8 → hestia_earth_aggregation-0.21.9}/hestia_earth_aggregation.egg-info/dependency_links.txt +0 -0
  39. {hestia_earth_aggregation-0.21.8 → hestia_earth_aggregation-0.21.9}/hestia_earth_aggregation.egg-info/requires.txt +0 -0
  40. {hestia_earth_aggregation-0.21.8 → hestia_earth_aggregation-0.21.9}/hestia_earth_aggregation.egg-info/top_level.txt +0 -0
  41. {hestia_earth_aggregation-0.21.8 → hestia_earth_aggregation-0.21.9}/setup.cfg +0 -0
  42. {hestia_earth_aggregation-0.21.8 → hestia_earth_aggregation-0.21.9}/setup.py +0 -0
  43. {hestia_earth_aggregation-0.21.8 → hestia_earth_aggregation-0.21.9}/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.8
3
+ Version: 0.21.9
4
4
  Summary: HESTIA's aggregation engine.
5
5
  Home-page: https://gitlab.com/hestia-earth/hestia-aggregation-engine
6
6
  Author: HESTIA Team
@@ -32,6 +32,7 @@ def aggregate(
32
32
  source: dict = None,
33
33
  include_distribution: bool = True,
34
34
  filter_by_country: bool = True,
35
+ include_covariance: bool = True,
35
36
  ):
36
37
  """
37
38
  Aggregates data from HESTIA.
@@ -54,6 +55,8 @@ def aggregate(
54
55
  filter_by_country : bool
55
56
  If set to `False`, Cycles from all countries will be used.
56
57
  When used with `Worl` or `Continent` aggregation, setting `False` will also use non-aggregated Cycles.
58
+ include_covariance : bool
59
+ Include the `covarianceMatrix`. Included by default.
57
60
 
58
61
  Returns
59
62
  -------
@@ -76,7 +79,14 @@ def aggregate(
76
79
  end_year,
77
80
  )
78
81
  aggregations, countries = aggregate_function(
79
- country, product, source, start_year, end_year, filter_by_country
82
+ country,
83
+ product,
84
+ source,
85
+ start_year,
86
+ end_year,
87
+ include_distribution=include_distribution,
88
+ filter_by_country=filter_by_country,
89
+ include_covariance=include_covariance,
80
90
  )
81
91
  logger.info("time=%s, unit=ms", current_time_ms() - now)
82
92
  aggregations = (
@@ -91,6 +91,9 @@ def aggregate_country(
91
91
  start_year: int,
92
92
  end_year: int,
93
93
  filter_by_country: bool = True,
94
+ include_covariance: bool = True,
95
+ *args,
96
+ **kwargs,
94
97
  ) -> Tuple[list, list]:
95
98
  """
96
99
  Create 1 to many country-level aggregations.
@@ -130,7 +133,11 @@ def aggregate_country(
130
133
 
131
134
  # combine cycles into a "master" cycle with multiple values
132
135
  cycles_aggregated = aggregate_cycles(
133
- cycles=cycles, product=product, start_year=start_year, end_year=end_year
136
+ cycles=cycles,
137
+ product=product,
138
+ start_year=start_year,
139
+ end_year=end_year,
140
+ include_covariance=include_covariance,
134
141
  )
135
142
  if not cycles_aggregated:
136
143
  logger.info("2 - No aggregated cycles.")
@@ -181,7 +188,14 @@ def aggregate_country(
181
188
  log_memory_usage()
182
189
 
183
190
  country_cycle = (
184
- (country_cycle | generate_covariance_country(weights=weights))
191
+ (
192
+ country_cycle
193
+ | (
194
+ generate_covariance_country(weights=weights)
195
+ if include_covariance
196
+ else {}
197
+ )
198
+ )
185
199
  if country_cycle
186
200
  else None
187
201
  )
@@ -720,7 +720,13 @@ def _aggregate_sites(site_ids: List[str], start_year: int, end_year: int) -> Sit
720
720
  return site
721
721
 
722
722
 
723
- def aggregate_cycles(cycles: list, product: dict, start_year: int, end_year: int):
723
+ def aggregate_cycles(
724
+ cycles: list,
725
+ product: dict,
726
+ start_year: int,
727
+ end_year: int,
728
+ include_covariance: bool = True,
729
+ ):
724
730
  batches = range(0, len(cycles), _BATCH_SIZE)
725
731
  logger.info(f"Processing {len(cycles)} cycles in {len(batches)} batches.")
726
732
 
@@ -742,13 +748,17 @@ def aggregate_cycles(cycles: list, product: dict, start_year: int, end_year: int
742
748
  logger.info("Finished processing batch, combining all cycles...")
743
749
  log_memory_usage()
744
750
  # generate covariance on sub cycles
745
- covariances = {key: generate_covariance_cycles(key) for key in all_cycles.keys()}
751
+ covariances = (
752
+ {key: generate_covariance_cycles(key) for key in all_cycles.keys()}
753
+ if include_covariance
754
+ else {}
755
+ )
746
756
  all_cycles = {
747
757
  key: _combine_formatted_cycles(cycles=values)
748
758
  for key, values in all_cycles.items()
749
759
  }
750
760
  # add covariances to cycles once they have been combined
751
- cycles = [cycle | covariances[key] for key, cycle in all_cycles.items()]
761
+ cycles = [cycle | covariances.get(key, {}) for key, cycle in all_cycles.items()]
752
762
  # discard memory
753
763
  all_cycles = {}
754
764
 
@@ -136,7 +136,7 @@ def add_covariance_cycles(cycles: list, suffix: str):
136
136
 
137
137
 
138
138
  def _format_covariance_value(value):
139
- return None if pd.isna(value) else value
139
+ return None if any([pd.isna(value), value == -np.inf, value == np.inf]) else value
140
140
 
141
141
 
142
142
  def _format_covariance_matrix(values):
@@ -0,0 +1 @@
1
+ VERSION = "0.21.9"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hestia_earth_aggregation
3
- Version: 0.21.8
3
+ Version: 0.21.9
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.8"