Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add offset method to compute offsets relative to base-year values #659

Merged
merged 6 commits into from
May 24, 2022

Conversation

gidden
Copy link
Member

@gidden gidden commented May 13, 2022

Please confirm that this PR has done the following:

  • Tests Added
  • Documentation Added
  • Name of contributors Added to AUTHORS.rst
  • Description in RELEASE_NOTES.md Added

Description of PR

This PR introduces an offset() method which allows a user to compute offsets relative to base-time-periods in the same style as normalize().

    For example, offsetting from `year=2005` will provide data
    *relative* to `year=2005` such that the value in 2005 is 0 and 
    all other values `value[year] - value[2005]`.

    Conceptually this operation performs as:
    ```
    df - df.filter(**kwargs) + padding
    ```

@codecov
Copy link

codecov bot commented May 13, 2022

Codecov Report

Merging #659 (b203f56) into main (c5e8f9c) will increase coverage by 0.0%.
The diff coverage is 100.0%.

@@          Coverage Diff          @@
##            main    #659   +/-   ##
=====================================
  Coverage   94.5%   94.6%           
=====================================
  Files         59      59           
  Lines       5742    5765   +23     
=====================================
+ Hits        5431    5454   +23     
  Misses       311     311           
Impacted Files Coverage Δ
pyam/core.py 94.6% <100.0%> (+<0.1%) ⬆️
tests/test_core.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 c5e8f9c...b203f56. Read the comment docs.

Copy link
Collaborator

@coroa coroa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not against including such a function, but it is also quite specific. Unsure, whether discoverability will become an issue at some point or already is.

pyam/core.py Outdated Show resolved Hide resolved
@danielhuppmann
Copy link
Member

Thanks @coroa for suggesting the high-performance implementation alternative!

I don't mind adding the function directly for now. If discoverability becomes an issue, we could delegate methods operating only on the timeseries data to a submodule, similar to what I did with the compute module...

@gidden
Copy link
Member Author

gidden commented May 20, 2022

Hi both - have updated based on your suggestions. Should be ready.

@coroa
Copy link
Collaborator

coroa commented May 24, 2022

LGTM

@gidden
Copy link
Member Author

gidden commented May 24, 2022

Given positive response here, will go ahead with merge. See #662 for an issue on expanding documentation further.

@gidden gidden merged commit de6b47b into IAMconsortium:main May 24, 2022
@gidden gidden deleted the offset branch May 24, 2022 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants