Repository navigation
Conversation
…cords
utils.annualize converted year floats to datetime objects, which fail
for years <= 0 ('year 0 is out of range'), so ProxyDatabase.annualize
silently dropped every record that starts at or before year 0 (the
warning was printed only with verbose=True). The time-axis path now bins
on numeric years, with the same month assignment as year_float2datetime;
its output is identical to the previous version for positive years
(checked on 24,000 random series and seasons). ProxyDatabase.annualize
now always warns, listing the dropped records. See fzhu2e#5.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TsdL1gpFWoD4LYexEPr6LD
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #15 (and the error in fzhu2e#5).
utils.annualize(). When given a time axis, it now bins on numeric years instead of converting to datetime objects, so it works for years at or before 0. A new helper,_year_float2year_month(), assigns months the same wayyear_float2datetime()does, including leap years, and a month after the last month of the season goes to the next year's season (December for[-12, 1, 2]), as with the previousresample. Thedapath (used byClimateField.annualize()) is unchanged.ProxyDatabase.annualize(). It now always warns when it drops records and lists them, instead of only withverbose=True.Same results for positive years. I compared the new and old
utils.annualize()on 24,000 random series (monthly, whole-year, mid-year, irregular sub-annual and multi-year, and times on month boundaries, some with NaNs) and 8 seasons. The output is identical in every case, including the NaN gaps, and both versions raise in the same cases (no data in the requested months). The new version differs in two edge cases where the old one was wrong or failed:index must be monotonic for resampling, and the new one averages them.Tests. New tests cover records starting at 1.5, 0.5, -4.5 and -1161, sub-annual data across year 0, DJF across year 0, missing months, and
ProxyDatabase.annualize()keeping records that start before year 0. All but the 1.5 case fail onmain. The full suite passes (225 tests).🤖 Generated with Claude Code
https://claude.ai/code/session_01TsdL1gpFWoD4LYexEPr6LD