fix: close load_data_source validation gaps (#533) - #544
Open
Shashankss1205 wants to merge 1 commit into
Open
Conversation
Three related load defects: - NB-07: a non-numeric (object-dtype) target passed validation with valid=true and failed much later inside fit. validate() now warns when the target column is non-numeric, naming the column and dtype. The check is forwarded to file sources too (file_adapter passes target/exog config into the reused PandasAdapter validation). - NB-06: a 1-2 row series could not load at all — pd.infer_freq raises "Need at least 3 dates to infer frequency". Guarded all three infer_freq call sites behind a _safe_infer_freq helper that returns None for short series, so tiny series load with no frequency instead of crashing. - NB-11: a bad file time_column leaked a raw pandas "Missing column provided to 'parse_dates'" error. Check the time column exists up front (clean "not found, available: [...]" message) and stop wiring parse_dates=[col] into read_csv; the column is parsed to datetime in load() after the existence check. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #533.
Three related
load_data_sourcevalidation gaps, all verified in the sweeps:NB-07 — non-numeric target passed validation silently
An object-dtype target (
value: ["1","2","3"]) returnedvalid: trueand failed much later insidefit.validate()now warns when the target column is non-numeric, naming the column and dtype. The check is forwarded to file sources too —file_adapter.validatenow passes the target/exog config into the reusedPandasAdaptervalidation (previously it constructed one with{"data": data}only, so the target was unknown).NB-06 — 1–2 row series could not load
pd.infer_freqrequires ≥3 points and raises"Need at least 3 dates to infer frequency"; three call sites hit it unguarded. Added a_safe_infer_freqhelper that returnsNonefor short series, so a tiny (but valid) series loads with no frequency instead of crashing.NB-11 — file loader leaked pandas parse_dates internals
A bad
time_columnproduced"Missing column provided to 'parse_dates': 'index'". Now the time column's existence is checked up front with a clean "Time column 'x' not found in data. Available columns: [...]" message, andparse_dates=[col]is no longer wired intoread_csv— the column is parsed to datetime inload()after the existence check (matching the pandas-source path).Testing
tests/test_load_validation.py(6 tests): object-dtype target warns / numeric doesn't; 1- and 2-row series load; bad filetime_columngives a clean not-found withoutparse_datesin the message and lists available columns; badtarget_columnlists available.🤖 Generated with Claude Code