test(split): add edge-case tests for val_frac=0, n=1, n=2, and invalid fracs#42
Merged
Conversation
…d fracs Cover five paths not exercised by the existing test_split.py suite: - val_frac=0.0 is valid and produces an empty val partition (pure train/test) - n=1 rounds both train and val to 0, so the sole case lands in test - n=2 rounds val to 0 (int(2*0.1)=0), confirming the train/test boundary - train_frac=0 is explicitly rejected by the open-interval guard - train_frac + val_frac == 1.0 exactly is rejected (no room for a test set)
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.
Why
case_chrono_splitsupportsval_frac=0(documented as valid by the[0, 1)bound check), atrain_frac=0guard, and atrain_frac + val_frac >= 1guard. None of these paths had a test. Thefunction also has non-obvious integer-flooring behavior for small
n(n=1 always goes entirely to test; n=2 produces an empty val partition)
that is worth locking down explicitly so future refactors don't
silently regress the documented boundary.
What
test_split_val_frac_zero_gives_two_way_partition: verifies thatval_frac=0.0is accepted and produces an empty val list.test_split_single_case_goes_entirely_to_test:n=1floors bothn_trainandn_valto 0, so the sole case lands in test.test_split_two_cases_val_rounds_to_zero:n=2with default fracsgives
int(2*0.1)=0val; confirms train/test boundary.test_split_train_frac_zero_raises: assertstrain_frac=0triggersthe
(0, 1)open-interval ValueError.test_split_fracs_sum_to_one_raises: assertstrain_frac + val_frac == 1.0triggers the >= 1 ValueError.Tests
tests/test_split.py.pm_bench/split.pydirectly with no mocking.Self-merge gate
Generated by Claude Code