Skip to content

Fix subsecond precision in array timestamp offsets - #307

Closed
farzaandalwai wants to merge 1 commit into
Nixtla:mainfrom
farzaandalwai:fix-offset-resolution
Closed

farzaandalwai wants to merge 1 commit into
Nixtla:mainfrom
farzaandalwai:fix-offset-resolution

Conversation

@farzaandalwai

Copy link
Copy Markdown

Array step counts currently lose subsecond non-Tick offsets when pandas timestamps use a coarser resolution. For example, a 500 ms DateOffset applied to datetime64[s] values is retained with scalar n but silently truncated with array n. This addresses the offset_times portion of #304; the separate time_ranges behavior remains outside this change.

The fix concatenates the computed runs without an empty input-resolution prefix or a final narrowing cast. Arrow-backed inputs retain their storage type with the computed timestamp resolution. It also adds a focused README example and an offset_times docstring.

Validation:

  • The new regression cases initially produced 14 failures and 14 passes without the fix.
  • The full suite passed locally on Python 3.10.21: 1,829 passed, eight skipped, 90.56% coverage. Spark required Java 21 and its worker Python to match the driver.
  • pre-commit checks for utilsforecast/*.py, the new test file and README passed: Ruff lint, Ruff format and mypy.
  • The tests cover mixed positive/negative/zero counts, second/millisecond/microsecond input resolutions, Series/Index metadata, timezone-aware values, Arrow storage and empty inputs.

AI assistance: OpenAI Codex assisted with the implementation, tests, documentation and this description. The validation results above were executed locally. No changes are proposed to time_ranges or the existing Arrow-date pull request #303.

Co-authored-by: OpenAI Codex <noreply@openai.com>
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@jmoralez

Copy link
Copy Markdown
Contributor

Superseded by #308

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.

3 participants