test(stage-2): add proptest + linalg edge cases (#393) - #410
Conversation
Stage 2 of #391. +14 tests (474 -> 488 unit), all gates green. Added proptest = "1.5" dev-dependency and property-based invariant tests + edge cases across linalg, sort, and distance: - linalg/basic/arrays.rs (5 proptest + 5 edge): - transpose involution (A^T)^T == A - matmul with identity A*I == A - matmul associativity (AB)C ≈ A(BC) (approximate for FP) - (AB)^T == B^T * A^T - reshape preserves element count - 1x1 matmul, row×col matmul, shape-mismatch panic, reshape-incompatible panic, 1xN transpose - algorithm/sort/quick_sort.rs (1 proptest): - quick_argsort produces a valid permutation (indices unique, non-decreasing in perm order) - metrics/distance/euclidian.rs (3 proptest): - d(a,a) == 0, symmetry d(a,b)==d(b,a), triangle inequality d(a,c) <= d(a,b)+d(b,c) Bump 0.6.3 -> 0.6.4.
Summary of Actionable Notes
The |
Fix wasm32 build failure: proptest pulls in wait-timeout (Unix syscalls unavailable on wasm32). Move proptest to a target-specific dev-dependency block [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] and add #[cfg(not(target_arch = "wasm32"))] to all proptest test functions. Review feedback (PR #410 comment): - proptest_matmul_transpose_identity: switch from exact prop_assert_eq! to approximate comparison (1e-10) — FP accumulation can exceed exact PartialEq, which could cause spurious CI failures under future matmul implementation changes. - arb_small_matrix: widen input range from 0.0..100.0 to -50.0..50.0 to include negative values for stronger coverage. - associativity comment: fix typo 'matmils' -> 'matmuls'. - quick_argsort_is_valid_permutation: remove unreachable n==0 guard (min length is 1, so the guard was dead code). Verified: fmt=0, clippy=0 (with -2024-compatibility), test=0 (488 unit + 68+3 doctests), wasm32 build --all-features=0.
|
Pushed wasm32 build fix: proptest pulls in Review feedback:
Verified: fmt=0, clippy=0 (with |
Summary
Stage 2 of #391, tracked in #393. Adds
proptestas a dev-dependency and writes property-based invariant tests + edge cases for core linalg, sort, and distance. +14 tests (474 → 488 unit), all gates green.Changes
proptest = "1.5"added to[dev-dependencies]linalg/basic/arrays.rs— 5 proptest invariants + 5 edge cases(A^T)^T == AA * I == A(AB)C ≈ A(BC)(approximate comparison — FP accumulation across three matmuls can exceed exactPartialEq)(AB)^T == B^T * A^T(rows, cols)shapealgorithm/sort/quick_sort.rs— 1 proptest invariantquick_argsortproduces a permutation where all indices appear exactly once and values are non-decreasing in permutation ordermetrics/distance/euclidian.rs— 3 proptest invariantsd(a, a) == 0d(a, b) == d(b, a)d(a, c) ≤ d(a, b) + d(b, c)Verification (run, not guessed)
cargo fmt --all -- --checkcargo clippy --all-features -- -Drust-2018-idioms -Drust-2024-compatibility -Dwarningscargo test --all-featuresNotes
PartialEqto fail — discovered by running, not guessing.lenparameter (thedistancefunction panics on size mismatch).Version bumped
0.6.3→0.6.4; CHANGELOG updated under[0.6.4].Closes #393.