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 a function to retrieve years in which a series crosses a threshold #101
Conversation
this looks good @danielhuppmann, but it's a little confusing because the crossing could be in the positive (below to above) or negative (above to below). I think that information should be included in what is returned. Also, maybe add a test for one that does not cross a threshold? |
thanks @gidden! Added a test where On returning the direction of crossing, not sure what would be suitable return format - any ideas? Alternatively, the function could take an additional optional |
Yes, I would add a kwarg like |
I was thinking of |
tests/test_timeseries.py
Outdated
|
||
def test_cross_treshold_direction_error(): | ||
y = pd.Series(data=[np.nan, 1, 3, 1], index=[2002, 2005, 2007, 2013]) | ||
pytest.raises(ValueError, cross_threshold, x = y, threshold=2, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E251 unexpected spaces around keyword / parameter equals
tests/test_timeseries.py
Outdated
def test_cross_treshold_direction_error(): | ||
y = pd.Series(data=[np.nan, 1, 3, 1], index=[2002, 2005, 2007, 2013]) | ||
pytest.raises(ValueError, cross_threshold, x = y, threshold=2, | ||
direction='up') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
W292 no newline at end of file
@gidden, added a kwarg Should be good to go once the tests pass |
perfect, thanks! |
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:
Description of PR
This PR adds a
pyam.cross_threshold()
function to retrieve a list of years in which apd.Series
(e.g., a timeseries row) crosses a given threshold.