IAMconsortium / pyam

Analysis & visualization of energy & climate scenarios
https://pyam-iamc.readthedocs.io/
Apache License 2.0
238 stars 120 forks source link

Support region-aggregation with weights-index as superset #754

Closed danielhuppmann closed 1 year ago

danielhuppmann commented 1 year ago

Please confirm that this PR has done the following:

Description of PR

Per a request by @bs538, this PR extends the aggregate_region() method such that the computation is done if the weights-index is a superset of the data-index. Previously, the computation was only done if the index was identical.

E.g., if (for whatever reasons), CO2-prices are only given until 2050 but CO2 emissions are given until 2100, the method will now be able to compute region-aggregated CO2-prices until 2050.

The relevant change is going from equals to isin when checking the consistency of the two data- and weight-index, plus adding an element to a test. All other changes are simply clean-up of the tests and docstrings.

codecov[bot] commented 1 year ago

Codecov Report

Merging #754 (89453f7) into main (5257aa9) will decrease coverage by 0.7%. The diff coverage is 100.0%.

@@           Coverage Diff           @@
##            main    #754     +/-   ##
=======================================
- Coverage   95.1%   94.5%   -0.7%     
=======================================
  Files         59      59             
  Lines       6014    6019      +5     
=======================================
- Hits        5723    5689     -34     
- Misses       291     330     +39     
Impacted Files Coverage Δ
pyam/core.py 95.4% <ø> (ø)
pyam/aggregation.py 99.1% <100.0%> (ø)
tests/test_feature_aggregate.py 98.9% <100.0%> (+<0.1%) :arrow_up:

... and 2 files with indirect coverage changes

danielhuppmann commented 1 year ago

Note that the reduction in test coverage is due to skipping the UNFCCC integration test in the unrelated and already-merged PR #753

danielhuppmann commented 1 year ago

Closing in favor of #792