feature: add apply() and timezone-awareness to AvailableAt#831
Merged
lschilders merged 7 commits intorelease/v4.0.0from Mar 9, 2026
Merged
feature: add apply() and timezone-awareness to AvailableAt#831lschilders merged 7 commits intorelease/v4.0.0from
lschilders merged 7 commits intorelease/v4.0.0from
Conversation
Signed-off-by: lschilders <lars.schilders@alliander.com>
|
fleur-petit
pushed a commit
to fleur-petit/openstef
that referenced
this pull request
Mar 26, 2026
) * feature: add apply() to AvailableAt and tz-aware option * feature: refactor AvailableAt to use day_offset and time_of_day rather than lag_from_day * feature: (de)serialization support for tz-aware AvailableAt * feature: improved docstring * feature: add tests for apply_index Signed-off-by: lschilders <lars.schilders@alliander.com> --------- Signed-off-by: lschilders <lars.schilders@alliander.com> Signed-off-by: Fleur Petit <fleur.petit@alliander.com>
fleur-petit
pushed a commit
to fleur-petit/openstef
that referenced
this pull request
Mar 26, 2026
) * feature: add apply() to AvailableAt and tz-aware option * feature: refactor AvailableAt to use day_offset and time_of_day rather than lag_from_day * feature: (de)serialization support for tz-aware AvailableAt * feature: improved docstring * feature: add tests for apply_index Signed-off-by: lschilders <lars.schilders@alliander.com> --------- Signed-off-by: lschilders <lars.schilders@alliander.com> Signed-off-by: Fleur Petit <fleur.petit@alliander.com>
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.



This pull request introduces a significant refactor and enhancement of the
AvailableAttype in theopenstef_core.typesmodule, transitioning from a timedelta-based API to a more expressive and robust representation using day offsets, time-of-day, and optional timezone support. The update improves clarity, enables precise timezone-aware calculations (including DST handling), and modernizes the API. Extensive new and updated tests ensure correctness and backward compatibility, including legacy string format support.Major enhancements to
AvailableAt:AvailableAtto use explicitday_offset,time_of_day, and optionaltzinfoinstead of atimedelta, with a new string format (DnTHHMM[tz]) and backward-compatible parsing for the legacy format. This allows for clear, direct specification of availability cutoffs and supports timezones via IANA names or UTC/Z notation.applyandapply_indexto compute availability cutoffs for single datetimes and PandasDatetimeIndex, with correct handling of timezones and DST transitions.Integration and usage updates:
TimeSeriesDataset.filter_by_available_atand related code to use the newAvailableAt.apply_indexmethod, ensuring correct cutoff calculations and simplifying the logic.AvailableAtconstructor and API, replacing legacytimedelta-based calls. [1] [2] [3] [4]Expanded and improved test coverage:
AvailableAtAPI, including round-trip string parsing, DST-aware cutoff handling, legacy format support, timezone parsing (including error cases), and edge cases like positive offsets and invalid input.Additional improvements:
AvailableAtdocstring, clarifying usage, parameters, and expected behavior.These changes collectively modernize the handling of data availability cutoffs in the codebase, making it more expressive, robust, and timezone-aware.
Change references: [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]