Skip to content

fix: support factor timestamps and empty signal frames on Polars 2 - #99

Merged
stefan-jansen merged 4 commits into
mainfrom
codex/factor-timestamp-polars2
Oct 14, 2026
Merged

stefan-jansen merged 4 commits into
mainfrom
codex/factor-timestamp-polars2

Conversation

@stefan-jansen

Copy link
Copy Markdown
Contributor

String timestamps in FactorData fail under Polars 2 because its string-to-Date/Datetime casts were removed. Empty signal frames also fail outlier filtering when Polars infers a Null column. Parse timestamps explicitly and return empty frames unchanged.

The original parser proposed in #90 also rejected ISO datetime strings under locked Polars 1.43.2. This branch preserves time of day, supports both tested Polars versions, and rejects partially parsed timestamp columns rather than silently inserting nulls.

Refs #89. Keep that tracking issue open until all companion fixes land.

Current head: ea5022e, based on main ef02ad9. The focused diff is unchanged from the tested implementation below; fresh PR CI checks the security update and compatibility fix together.

Verification:

  • Base: 5f35459. Public FactorData.from_dataframe with ISO date strings raises InvalidOperationError on Polars 2.0.0; filter_outliers on an empty frame raises InvalidOperationError for Null.abs().
  • Reviewed head: 14f5171. Five timestamp/empty-frame cases pass with both locked Polars 1.43.2 and an isolated Polars 2.0.0 override.
  • Commands: uv run --locked pytest -n 0 tests/test_evaluation/test_factor_regressions.py::TestUtf8Timestamps tests/test_signal/test_utils.py::TestFilterOutliers::test_empty_dataframe -q, repeated with --with polars==2.0.0.
  • Full suite: 5474 passed, 7 skipped. Ruff lint/format, ty, pre-commit --all-files, strict MkDocs, and wheel/sdist build passed.
  • Cross-platform CI on this PR is still required before merge.

Compatibility: restores ISO date input on Polars 2 and retains datetime precision on Polars 1. No numerical metric definition changes.

Attribution: preserves original Git authorship for @quantum-like's PR #90 commits 84a452c and 947459a. Codex added the datetime regression repair and tests, split the branch, and ran the checks. AI assistance includes the original Cursor Agent commits and Codex's review, repair, tests, and this description. Maintainer review and accountability remain required.

cursoragent and others added 4 commits October 13, 2026 12:14
FactorData cast string timestamps with cast(Date), which Polars 2 rejects.
Parse ISO dates and datetimes explicitly and reject values that do not parse.

Co-authored-by: quantum-like <quantum-like@users.noreply.github.com>
An empty factor column is inferred as Null, and Polars 2 refuses abs() on
that dtype. Return the frame unchanged when there are no rows.

Co-authored-by: quantum-like <quantum-like@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 14, 2026 20:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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