IAMconsortium / pyam

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

Implement an `apply()` function #533

Closed pjuergens closed 3 years ago

pjuergens commented 3 years ago

Please confirm that this PR has done the following:

Description of PR

Implemented an apply() function, closes #528

codecov[bot] commented 3 years ago

Codecov Report

Merging #533 (66a0106) into main (63bbea8) will increase coverage by 0.0%. The diff coverage is 100.0%.

Impacted file tree graph

@@          Coverage Diff          @@
##            main    #533   +/-   ##
=====================================
  Coverage   93.4%   93.4%           
=====================================
  Files         45      47    +2     
  Lines       5074    5123   +49     
=====================================
+ Hits        4740    4789   +49     
  Misses       334     334           
Impacted Files Coverage Δ
pyam/_ops.py 100.0% <100.0%> (ø)
pyam/core.py 92.6% <100.0%> (+<0.1%) :arrow_up:
tests/test_ops.py 100.0% <100.0%> (ø)
tests/test_feature_debiasing.py 100.0% <0.0%> (ø)
pyam/_debiasing.py 100.0% <0.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 63bbea8...66a0106. Read the comment docs.

pjuergens commented 3 years ago

It should be similar now to pandas apply with the possibility of both args (in my implementation before components) and **kwargs (in pandas-style however **kwds)

danielhuppmann commented 3 years ago

FYI, I added the description of this PR to directly close the related issue when this PR gets merged

pjuergens commented 3 years ago

Should be ready to go now :) I had to put the _get_values function inside _ops.py, because I could load get_index_levels from withing utils.py.

danielhuppmann commented 3 years ago

Should be ready to go now :) I had to put the _get_values function inside _ops.py, because I could load get_index_levels from withing utils.py.

Yeah, one has to be careful about circular dependencies... But it's fine to have that close to the actual use case.