Skip to content

test(split): add edge-case tests for val_frac=0, n=1, n=2, and invalid fracs#42

Merged
protosphinx merged 1 commit into
mainfrom
bot/test-split-edge-cases
May 28, 2026
Merged

test(split): add edge-case tests for val_frac=0, n=1, n=2, and invalid fracs#42
protosphinx merged 1 commit into
mainfrom
bot/test-split-edge-cases

Conversation

@protosphinx

Copy link
Copy Markdown
Member

Why

case_chrono_split supports val_frac=0 (documented as valid by the
[0, 1) bound check), a train_frac=0 guard, and a
train_frac + val_frac >= 1 guard. None of these paths had a test. The
function 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 that
    val_frac=0.0 is accepted and produces an empty val list.
  • test_split_single_case_goes_entirely_to_test: n=1 floors both
    n_train and n_val to 0, so the sole case lands in test.
  • test_split_two_cases_val_rounds_to_zero: n=2 with default fracs
    gives int(2*0.1)=0 val; confirms train/test boundary.
  • test_split_train_frac_zero_raises: asserts train_frac=0 triggers
    the (0, 1) open-interval ValueError.
  • test_split_fracs_sum_to_one_raises: asserts
    train_frac + val_frac == 1.0 triggers the >= 1 ValueError.

Tests

  • All 5 additions are in tests/test_split.py.
  • They exercise pm_bench/split.py directly with no mocking.
  • Pure CPython, no network, no filesystem.

Self-merge gate

  • all CI checks pass
  • LOC delta < 250 (added + removed)
  • no public-API surface change
  • no runtime-dependency additions
  • no workflow file changes
  • tests added or extended

Generated by Claude Code

…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)
@protosphinx protosphinx merged commit 01d1bff into main May 28, 2026
6 checks passed
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.

1 participant