Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces time zone localization functionality to handle conversion of timezone-naive (TIMESTAMP_NTZ) timestamps to timezone-aware (TIMESTAMP_TZ) timestamps. The changes include new localizer classes, refactoring of time configuration models, updates to test utilities, and bug fixes.
Changes:
- Added
TimeZoneLocalizerandTimeZoneLocalizerByColumnclasses for localizing tz-naive timestamps to standard time zones - Refactored time configuration models to include
dtypefield and consolidatedIndexTimeRangeclasses - Updated test utilities and fixed API inconsistencies (
np.concat→np.concatenate)
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/chronify/time_zone_localizer.py | New module implementing time zone localization classes and functions |
| src/chronify/time_configs.py | Added dtype field to DatetimeRange classes and consolidated IndexTimeRange classes |
| src/chronify/time.py | Replaced DatetimeFormat with TimeDataType enum |
| src/chronify/store.py | Added localize_time_zone and localize_time_zone_by_column methods |
| src/chronify/time_zone_converter.py | Updated error messages and added dtype field usage |
| src/chronify/datetime_range_generator.py | Refactored timestamp generation to use pd.date_range and improved handling of time zones |
| src/chronify/sqlalchemy/functions.py | Updated to use dtype field instead of start_time_is_tz_naive() |
| src/chronify/time_series_mapper_index_time.py | Added dtype field assignment in mapping creation |
| src/chronify/time_series_checker.py | Fixed typo in docstring |
| tests/test_time_zone_localizer.py | Comprehensive test coverage for new localization functionality |
| tests/test_store.py | Integration tests for localize_time_zone methods |
| tests/test_time_zone_converter.py | Updated error message test and refactored test utilities |
| tests/test_mapper_*.py | Refactored to use list_timestamps() instead of _iter_timestamps() |
| tests/test_mapper_column_representative_to_datetime.py | Fixed np.concat → np.concatenate |
| src/chronify/init.py | Updated exports to remove deprecated IndexTimeRange classes |
| docs/how_tos/map_time_config.md | Fixed np.concat → np.concatenate in documentation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
daniel-thom
left a comment
There was a problem hiding this comment.
Looks good; just some minor comments to clean up.
| Note: Established time library already handles historical changes in time zone conversion to UTC. | ||
| (e.g. Algeria (Africa/Algiers) changed from UTC+0 to UTC+1 on April 25, 1980) | ||
| """ | ||
| for ts in self._list_timestamps(start=start): |
There was a problem hiding this comment.
If we are removing the feature of lazy iteration, we should remove this method.
There was a problem hiding this comment.
Isn't it needed for polymorism? All generators have this method and it is used by a mapper here:
chronify/src/chronify/time_series_mapper_column_representative_to_datetime.py
Lines 196 to 198 in 8db9fae
There was a problem hiding this comment.
Isn't it needed for polymorism? All generators have this method and it is used by a mapper here:
chronify/src/chronify/time_series_mapper_column_representative_to_datetime.py
Lines 196 to 198 in 8db9fae
The base class only requires this method:
@abc.abstractmethod
def list_timestamps(self) -> list[Any]:
This commit introduces time zone localization functionality to handle conversion of timezone-naive (TIMESTAMP_NTZ) timestamps to timezone-aware (TIMESTAMP_TZ) timestamps. The changes include new localizer classes, refactoring of time configuration models, updates to test utilities, and bug fixes. Changes: Added TimeZoneLocalizer and TimeZoneLocalizerByColumn classes for localizing tz-naive timestamps to standard time zones Refactored time configuration models to include dtype field and consolidated IndexTimeRange classes Updated test utilities and fixed API inconsistencies (np.concat → np.concatenate)
Provides time zone localization support.
Integration into dsgrid: dsgrid/dsgrid#406