test(stage-1): fill untested modules + revive serde tests (#392) - #405
Conversation
Stage 1 of #391. +29 tests (444 -> 473 unit), all gates green. New tests for previously-untested substantive files: - linalg/traits/high_order.rs: implement the TODO mod tests covering all 4 ab() transpose-flag branches, non-square inputs, and matmul/transpose equivalence. - linear/lasso_optimizer.rs: direct tests for InteriorPointOptimizer (new() builds ata with correct shape; lambda->0 recovers least squares). - error/mod.rs: tests for all 6 Failed constructors, all 8 FailedError variants, both Display impls, both PartialEq impls, Error trait impl. - rand_custom.rs: seeded-RNG determinism and None-seed usability. Revived 6 commented-out serde round-trip tests (migrated serde_json -> postcard, the post-#390 backend) for LinearRegression, RidgeRegression, Lasso, ElasticNet, PCA, SVD. Renamed two copy-paste-misnamed tests: - dataset::diabetes::boston_dataset -> diabetes_dataset - algorithm::sort::quick_sort::with_capacity -> quick_argsort Bump version 0.6.0 -> 0.6.1.
Overall AssessmentPR #405 is clean, well-scoped, and delivers exactly what Stage 1 / #392 promised: +29 unit tests (444→473), 0 test regressions, all gates green . The commit message is precise and the verification table is honest — including the deliberately-dropped File-by-file Review
|
| Location | Severity | Note |
|---|---|---|
high_order.rs::ab_true_true |
🟡 Minor | Comment "(b * a)^T" is algebraically correct but should be (B·A)ᵀ to match ab(a_transposed=true, b_transposed=true) semantics |
high_order.rs |
✅ Bonus fix | Missing #[cfg(test)] on existing empty mod tests was silently compiling dead code into release — correctly fixed |
rand_custom.rs::none_seed_returns_usable_rng |
🟡 Minor | Add inline comment explaining the #[cfg(not(wasm32))] exclusion (OS entropy unavailable) |
rand_custom.rs |
🟠 Scope gap | std_rand feature path (StdRng) not tested — partial miss vs 392 spec |
svd.rs::serde |
✅ Silent fix | Corrected original commented test's wrong f32 deserialization type to f64 — worth noting in CHANGELOG |
The std_rand gap is the only item worth tracking before closing 392; everything else is minor polish. The PR is ready to merge as-is, with the std_rand test deferrable to a follow-up.
Sources
[1] test(stage-1): fill untested modules + revive serde tests (#392) by Mec-iS · Pull Request #405 · smartcorelib/smartcore #405
- rand_custom.rs: add std_rand_none_seed_uses_os_entropy test gated #[cfg(feature = "std_rand")] to cover the StdRg/OS-entropy branch of get_rng_impl(None) — closes the std_rand scope gap from #392. - rand_custom.rs: add inline comment on none_seed_returns_usable_rng explaining the #[cfg(not(wasm32))] exclusion (OS entropy unavailable on bare wasm). - high_order.rs: fix ab_true_true comment to (B·A)^T referencing the (AB)^T = B^T A^T identity, clarifying ab(true,true) semantics. - CHANGELOG: note the silent SVD serde-test fix (f32 -> f64 type).
|
Pushed
Verified: |
Summary
Stage 1 of the staged test-coverage plan (#391), tracked in #392. Fills the untested substantive files and revives the disabled serde round-trip tests.
Changes
New tests for previously-untested files
linalg/traits/high_order.rs: implemented the/* TODO: Add tests */module — all 4ab()transpose-flag branches, non-square inputs, and a matmul/transpose equivalence check. (7 tests)linear/lasso_optimizer.rs: direct tests forInteriorPointOptimizer—new()buildsatawith the correct shape and values;optimizewithlambda → 0recovers the least-squares solution on a known system. (2 tests, previously only exercised transitively vialasso.rs.)error/mod.rs: tests for all 6Failedconstructors, all 8FailedErrorvariants, bothDisplayimpls, bothPartialEqimpls, and thestd::error::Errortrait impl. (10 tests)rand_custom.rs: seeded-RNG determinism, distinct seeds diverge, andNone-seed returns a usable RNG. (3 tests)Revived 6 commented-out serde round-trip tests
Migrated
serde_json→postcard(the serialization backend since #390 replaced bincode) for:LinearRegression,RidgeRegression,Lasso,ElasticNet(src/linear/)PCA,SVD(src/decomposition/)All 6 pass — the
// TODO: implement serialization for new DenseMatrixblockers are no longer relevant.Renamed two copy-paste-misnamed tests
dataset::diabetes::boston_dataset→diabetes_datasetalgorithm::sort::quick_sort::with_capacity→quick_argsortVerification (run, not guessed)
cargo fmt --all -- --checkcargo clippy --all-features -- -Drust-2018-idioms -Dwarningscargo test --all-featurescargo test --all-features --lib serde)Each batch was verified by running before moving to the next; the
optimize_with_fit_interceptknown-answer test was dropped after running proved the optimizer's intercept path doesn't yield the naive slope weights.Version bumped
0.6.0→0.6.1; CHANGELOG updated under[0.6.1].Checklist
developmentbranchcargo fmt --all -- --checkcargo clippy --all-features -- -Drust-2018-idioms -Dwarningscargo test --all-featuresCloses #392.