Skip to content

fix: report short series in cross_validation for polars inputs - #1273

Open
Moury Bachina (MouryB) wants to merge 1 commit into
Nixtla:mainfrom
MouryB:fix/cv-short-series-polars
Open

Moury Bachina (MouryB) wants to merge 1 commit into
Nixtla:mainfrom
MouryB:fix/cv-short-series-polars

Conversation

@MouryB

Copy link
Copy Markdown

Fixes #1272

Summary

When cross_validation finds series that are too short for the requested windows, it builds the error message with self.uids[short_series]. That boolean-mask __getitem__ works for pandas but raises TypeError: selecting rows by passing a boolean mask to __getitem__ is not supported for polars, which hides the intended ValueError.

The mask is now applied with utilsforecast.processing.filter_with_mask, which core.py already uses (via ufp) to handle pandas and polars the same way. Behavior for pandas is unchanged.

Tests

Added test_cross_validation_short_series_message, parametrized over pandas and polars, with two short series so the message lists more than one id. The polars case fails on the current main and passes with this change; the pandas case passes on both.

uv run pytest tests/test_core.py -q          # 50 passed
uv run pre-commit run --files python/statsforecast/core.py tests/test_core.py   # ruff, mypy passed

Note

This PR was written with an AI coding assistant (Claude Code).

@CLAassistant

CLAassistant commented Oct 12, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

This branch has not been deployed

No deployments
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.

Using polars with cross_validation hits pandas-only syntax in an error resolution

2 participants