Skip to content

fix: accept DatetimeIndex timestamp inputs - #412

Open
Aliciawque wants to merge 1 commit into
shiyu-coder:masterfrom
Aliciawque:fix/datetime-index-timestamps
Open

Aliciawque wants to merge 1 commit into
shiyu-coder:masterfrom
Aliciawque:fix/datetime-index-timestamps

Conversation

@Aliciawque

@Aliciawque Aliciawque commented Oct 20, 2026 •

Copy link
Copy Markdown

Summary

predict_batch documents pd.DatetimeIndex as a supported timestamp input, but calc_time_stamps always uses the Series-only .dt accessor. Passing a pd.date_range(...) directly therefore raises AttributeError: 'DatetimeIndex' object has no attribute 'dt' before generation.

This narrowly converts DatetimeIndex inputs to a Series before extracting calendar fields. Existing Series inputs, including their row labels and order, are unchanged. No timezone conversion, timestamp sorting, model behavior, or input-validation policy is introduced.

Reproduction

import pandas as pd
from model.kronos import calc_time_stamps
calc_time_stamps(pd.date_range("2026-10-20 09:30", periods=3, freq="min"))

This raises on base 67b630e and returns the five calendar-feature columns with this patch.

Tests

  • python -m pytest -q tests/test_timestamp_inputs.py: 4 passed, 3 subtests passed.
  • Tests cover naive/UTC/New York timestamps including the DST fallback, empty DatetimeIndex, preservation of Series labels/order, and actual single/batched predictor preprocessing and output assembly. Only generate is mocked; these are not model-inference tests.
  • Independently reproduced the baseline error and reran the focused tests, plus mixed Series/DatetimeIndex batches and duplicate/unsorted labels.
  • python -m compileall -q model tests/test_timestamp_inputs.py and git diff --check: passed.
  • Linux Python 3.12.14, pandas 2.2.2 (also tested 2.2.3), NumPy 2.3.5, torch 2.14.1+cpu, huggingface_hub 0.33.1.

Validation boundary

The full suite was attempted with Hugging Face offline mode. Its four pre-existing pretrained-model regression cases failed because the pinned model configurations/weights are not cached; the unmodified baseline reproduced the same four failures. No checkpoint downloads, GPU inference, forecasting-quality claims, or Windows/macOS verification.

Reviewed related PRs #335, #393, #404 and #410 to avoid duplicating their changes; none updates this timestamp helper.

Developed and tested with AI assistance. Ready for maintainer review; the validation boundaries above remain unchanged.

Normalize DatetimeIndex to Series before calendar feature extraction,
while preserving existing Series labels. Add offline regression coverage
for calendar fields and single/batched predictor preprocessing.

Developed and tested with AI assistance.
@Aliciawque
Aliciawque marked this pull request as ready for review October 22, 2026 05:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant