Skip to content

Add CLI/edge-case tests and small robustness fixes - #1

Merged
Wickstrom merged 1 commit into
mainfrom
harden/tests-and-fixes
Oct 10, 2026
Merged

Wickstrom merged 1 commit into
mainfrom
harden/tests-and-fixes

Conversation

@Wickstrom

Copy link
Copy Markdown
Owner

What

Small hardening pass: tests for the previously-uncovered CLI plus a few real robustness fixes. No behavior change for normal use.

Changes

  • Tests (coverage 71% → 99%): cli.py was 0% covered. Added tests/test_cli.py (parser defaults, history CSV round-trip/error, main via fakes) plus extra data.py/trainer.py edge cases (Series input, empty frames, label ordering, verbose logging).
  • _encode_labels: use np.unique(..., return_inverse=True) so numeric labels keep numeric order (the old LabelEncoder on stringified labels reordered e.g. 1,2,10).
  • to_numpy3d: raise a clear ValueError on empty DataFrames instead of IndexError.
  • _save_history: report write errors via SystemExit instead of a raw traceback.
  • mixup_batch: draw lam from torch.distributions.Beta so a single torch.manual_seed makes runs reproducible.
  • CI: add pytest-cov with --cov-fail-under=90.

Verification

pytest --cov=mcl → 42 passed, 2 skipped, 98.7% coverage; ruff check/format --check clean.

- Cover mcl.cli (was 0%): parser defaults, history CSV round-trip/error, main via fakes
- _encode_labels: use np.unique(..., return_inverse=True).ravel() so numeric labels keep numeric order (LabelEncoder on stringified labels reordered e.g. 1,2,10)
- to_numpy3d: clear ValueError on empty DataFrames instead of IndexError
- _save_history: report write errors via SystemExit instead of a raw traceback
- mixup_batch: draw lam from torch.distributions.Beta so a single torch.manual_seed makes runs reproducible
- CI: add pytest-cov with --cov-fail-under=90
@Wickstrom
Wickstrom merged commit da26af4 into main Oct 10, 2026
2 checks passed
@Wickstrom
Wickstrom deleted the harden/tests-and-fixes branch October 10, 2026 17:07
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