Skip to content

fix: preserve timezone-aware timestamps during dataframe normalization - #535

Open
Iams4kura wants to merge 1 commit into
amazon-science:mainfrom
Iams4kura:bugfix/preserve-timezone-aware-timestamps-20260911t040159z
Open

Iams4kura wants to merge 1 commit into
amazon-science:mainfrom
Iams4kura:bugfix/preserve-timezone-aware-timestamps-20260911t040159z

Conversation

@Iams4kura

Copy link
Copy Markdown

Issue #, if available:

No existing issue found for this timezone failure. The affected normalization helper is from #507; this is separate from the string-ID ordering fix in #470.

Description of changes:

predict_df currently raises TypeError: Cannot change data-type for array of references when the timestamp column is timezone-aware. Series.to_numpy() produces an object array for these timestamps, which cannot be viewed as int64.

Read the ordering keys from DatetimeIndex.asi8 instead. The returned DataFrame keeps its original timezone, while sorting uses absolute time, including repeated local hours during a daylight-saving transition. This also retains integer comparisons for NumPy 1.x.

The regression tests cover UTC, Asia/Shanghai and America/New_York; sorted and unsorted input; caller immutability; and actual CPU predict_df calls across the New York DST fold, with and without future covariates.

Validation on the same upstream base (4dbf163c2734c089cdf7da2b86fde48862ff9c6f):

  • python -m pytest test/test_df_utils.py test/test_chronos2.py -k preserves_timezone -q: 8 failures before, 8 passes after, using identical test files.
  • OMP_NUM_THREADS=1 python -m pytest -q: 564 passed, 20 xfailed, with no deselected tests, including public model and dataset downloads.
  • NumPy 1.26.4 / pandas 2.3.3 compatibility: 553 passed, 20 xfailed; the 11 external-download cases were excluded in this second environment.
  • python -m mypy src test and uv build: passed.

Environment: macOS arm64, Python 3.11.15, PyTorch 2.14.0, Transformers 5.17.0; primary suite used NumPy 2.4.6 and pandas 3.0.5. The suite emits its existing long-horizon warnings and a CloudFront deprecation warning. An additional Ruff 0.16.7 check reports the same 130 diagnostics on the unmodified base and patch, with no new diagnostics; no unrelated lint cleanup is included.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

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.

1 participant