Skip to content

Validate forecast batch metadata and covariate shapes - #517

Open
ayoubchikri wants to merge 2 commits into
google-research:masterfrom
ayoubchikri:fix/query-validation
Open

ayoubchikri wants to merge 2 commits into
google-research:masterfrom
ayoubchikri:fix/query-validation

Conversation

@ayoubchikri

@ayoubchikri ayoubchikri commented Sep 16, 2026 •

Copy link
Copy Markdown

predict_batch currently accepts inconsistent metadata lengths, malformed context/covariate shapes, and invalid horizons until they fail later in preprocessing or decoding with less useful errors. Validate batch counts, time lengths, context rank, a nonempty context time axis, and a positive integer horizon at the API boundary.

The regression tests cover invalid counts and shapes, including empty 1D and 2D contexts, as well as validation before leading-NaN trimming. All 23 targeted tests pass, and Ruff passes for both changed files.

@sylvesterkaczmarek sylvesterkaczmarek 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.

The new context-shape check still accepts a zero-length time axis. np.array([]) passes because it is 1-D, and np.empty((1, 0)) passes because the 2-D guard only checks shape[0]. Both are unusable contexts but continue into trimming/padding/model preprocessing. Please require shape[-1] > 0 for both 1-D and 2-D contexts and cover both empty shapes.

@ayoubchikri

Copy link
Copy Markdown
Author

Thanks for catching this. Context validation now requires a non-empty time axis for both 1D and 2D inputs. I added regression cases for np.array([]) and np.empty((1, 0)); all 23 targeted tests pass.

@sylvesterkaczmarek sylvesterkaczmarek 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.

Rechecked b92e02e. Context validation now rejects a zero-length time axis for both 1-D and 2-D inputs, with regressions for np.array([]) and shape (1, 0). This closes the empty-context gap I raised.

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.

2 participants