IAMconsortium / pyam

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

Make `rename()` work with a custom index #561

Closed danielhuppmann closed 3 years ago

danielhuppmann commented 3 years ago

Please confirm that this PR has done the following:

Adding to RELEASE_NOTES.md (remove section after adding to RELEASE_NOTES.md)

Please add a single line in the release notes similar to the following:

- (#XX)[http://link-to-pr.com] Added feature which does something

Description of PR

This PR generalizes the rename() function so that it can be used on an IamDataFrame with a custom index (ie., other than ["model", "scenario"], see here.

Two use cases of the custom index:

To-Do

Rather than writing a single test just for this function, I'm thinking about how to redo test_df in the pytest-config so that a custom index can be tested across the entire pyam code base.

danielhuppmann commented 3 years ago

fyi @jh-RLI @christian-rli

codecov[bot] commented 3 years ago

Codecov Report

Merging #561 (e682d84) into main (7d77473) will not change coverage. The diff coverage is 100.0%.

Impacted file tree graph

@@          Coverage Diff          @@
##            main    #561   +/-   ##
=====================================
  Coverage   93.6%   93.6%           
=====================================
  Files         50      50           
  Lines       5313    5313           
=====================================
  Hits        4978    4978           
  Misses       335     335           
Impacted Files Coverage Δ
pyam/core.py 94.2% <100.0%> (+<0.1%) :arrow_up:
tests/conftest.py 100.0% <100.0%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 7d77473...e682d84. Read the comment docs.

danielhuppmann commented 3 years ago

Working on this further, I realized that restructuring the test suite and simultaneously fixing all issues where the custom-index-feature breaks is too much. Hence, I'm changing tactics - trusting that the existing tests cover all officially supported features, extending features to support custom-index IamDataFrame instances, then extending the test_df to also cover a case with a custom-index