Skip to content

FIX Covariates: enforce length invariant, fix slice() indexing#49

Open
felixdivo wants to merge 1 commit into
benchopt:mainfrom
felixdivo:fix/covariates-length-invariant
Open

FIX Covariates: enforce length invariant, fix slice() indexing#49
felixdivo wants to merge 1 commit into
benchopt:mainfrom
felixdivo:fix/covariates-length-invariant

Conversation

@felixdivo

Copy link
Copy Markdown
Contributor

Covariates fields defaulted to empty lists, so len(covariates) == 0 while
len(x) == N — which is why the length check in ForecastInput was disabled
(it would fire for every covariate-free dataset).

Now each field defaults to None ("absent for every series"), so the invariant
holds without boilerplate: a field is either None or has one entry per series.

  • ForecastInput.__post_init__: covariates must be absent (len 0) or cover every
    series (len(x)).
  • Covariates.__post_init__: present fields must share one length — fixes a
    chained-comparison bug (a != b != c) that silently skipped the check.
  • slice() now takes series_idx and slices the time axis of the selected
    series, instead of slicing the series axis; updated the sole caller.
  • Enedis drops the redundant static_covars=[]; docstrings updated.

Leakage tests pass; the pre-existing encoder-shape test failures are unrelated.

Covariates fields now default to None (explicit "absent for every series")
instead of empty lists, so the length invariant can always hold without
boilerplate: each field is either None or has one entry per series (len(x)).

- ForecastInput.__post_init__ now validates each present covariate field has
  length len(x) (resolves the disabled TODO).
- Covariates.__post_init__ validates non-None fields share one length, fixing
  a chained-comparison bug (a != b != c) that silently skipped checks.
- slice() now takes series_idx and slices the time axis of the selected
  series, instead of incorrectly slicing the series axis; updated the sole
  caller in BaseTSFMSolver.forecast.
- Enedis drops the redundant static_covars=[]; docstrings updated.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@felixdivo felixdivo requested a review from rtavenar June 13, 2026 22:14
@felixdivo felixdivo self-assigned this Jun 13, 2026
@felixdivo felixdivo added the bug Something isn't working label Jun 13, 2026
@felixdivo

Copy link
Copy Markdown
Contributor Author

CI Needs #50

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant