Skip to content

Stage 2: Edge cases + proptest invariants on core linalg/sort/distance (tracking #391) #393

Description

@Mec-iS

Tracking issue: #391 — Improve test coverage significantly (staged plan).

Scope

Edge cases and property-based invariant tests on core linalg and related primitives. Introduces proptest as a dev-dependency.

Tasks

  • Add proptest to [dev-dependencies] in Cargo.toml.
  • src/linalg/basic/arrays.rs (2,174 LOC, 49 existing tests but huge surface) and src/linalg/basic/matrix.rs: add #[should_panic] tests for shape mismatches and edge-case tests for empty arrays, single-element, 1×N / N×1, mismatched concat, out-of-bounds take, degenerate matmul.
  • Property-based invariant tests with proptest:
    • matmul: associativity (AB)C = A(BC) where shapes allow, distributivity over addition, (AB)ᵀ = BᵀAᵀ, A·I = A.
    • transpose: involution (Aᵀ)ᵀ = A.
    • reshape: preserves total element count.
    • dot: symmetry of dot product.
  • src/algorithm/sort/: property tests — quick_argsort and heap_select yield valid permutations, sorting is idempotent, sorted order holds.
  • src/metrics/distance/: property tests — symmetry d(a,b) = d(b,a), triangle inequality (Minkowski/Euclidean/Manhattan), d(a,a) = 0, Hamming invariance under permutation.

Verification

  • cargo test --all-features
  • cargo fmt --all -- --check
  • cargo clippy --all-features -- -Drust-2018-idioms -Dwarnings

Do you want to work on this issue?

yes — PR will target development.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions