Skip to content

Add SciML test setup and correctness tests#2

Merged
ChrisRackauckas merged 2 commits into
mainfrom
sciml-test-setup-and-correctness
May 27, 2026
Merged

Add SciML test setup and correctness tests#2
ChrisRackauckas merged 2 commits into
mainfrom
sciml-test-setup-and-correctness

Conversation

@ChrisRackauckas-Claude
Copy link
Copy Markdown
Collaborator

Please ignore until reviewed by @ChrisRackauckas.

Summary

  • Restructures test/ around a GROUP env split (Core/QA, plus per-factorization subgroups QR/LU/Cholesky/Cross)
  • Adds the standard SciML QA tests: Aqua + ExplicitImports, gated behind GROUP=QA
  • Adds SafeTestsets isolation for each test file
  • Adds a GitHub Actions CI matrix (Julia 1.11 + 1, Linux/Mac/Windows, Core + QA groups, codecov)
  • Substantially expands correctness coverage for cs_qr, cs_lu, cs_cholesky
  • Test count: 245 → 626 passing

New correctness tests

For each factorization and each (Tv, Ti) ∈ {Float64, ComplexF64} × {Int32, Int64}:

  • Known-answer hand-computed matrices (e.g. [2 1; 0 3] \ [4; 6] = [1; 2])
  • Identity / diagonal / tridiagonal test matrices
  • n = 1 trivial case
  • Input matrix immutability: A.colptr/rowval/nzval snapshot equals post-factorization and post-solve state
  • RHS immutability: b is unchanged after F \ b and ldiv!(x, F, b)
  • Multiple solves on one factorization: 5 different RHS, all match dense backslash
  • ldiv! returns the destination (identity test)
  • Explicit finalize(F) is safe and idempotent (no double-free)
  • Cross-factorization consistency: on a square non-singular matrix cs_qr ≈ cs_lu ≈ dense\; on an SPD matrix cs_qr ≈ cs_lu ≈ cs_cholesky ≈ dense\ to rtol=1e-9

Factorization-specific:

  • QR: overdetermined least-squares now compared coefficient-wise to dense Adense \ b (the existing test only compared residual norms)
  • LU: requires-pivoting matrix (zero on diagonal), singular matrix rejected, upper-triangular hand-check
  • Cholesky: zero-diagonal rejection, Hermitian (not just real-symmetric) test with non-trivial complex off-diagonals, small known-answer matrix

QA-driven source/compat fixes

  • src/CXSparse.jl: using LinearAlgebrausing LinearAlgebra: LinearAlgebra, ldiv! (ExplicitImports flagged the implicit import; the qualified LinearAlgebra.ldiv! calls in the body still work).
  • Project.toml:
    • Added compat for Random and Test (Aqua flagged them as extras-without-compat)
    • Bumped julia compat 1.101.11. The package's actual minimum is 1.11: CXSparse_jll@4 requires SuiteSparse_jll ≥ 7.7, but Julia 1.10 stdlib pins SuiteSparse_jll 7.2.1. Resolver fails on 1.10 (confirmed locally), so the previous claim was incorrect.

Test plan

  • Pkg.test() passes locally on Julia 1.11 (626 tests, no failures)
  • GROUP=Core runs only factorization tests
  • GROUP=QA runs only Aqua + ExplicitImports
  • GROUP=QR / LU / Cholesky / Cross subset selectors work
  • CI passes on the matrix (Linux/Mac/Windows × Julia 1.11/1)

🤖 Generated with Claude Code

Restructure test/ around a GROUP env split (Core/QA, plus per-factorization
subgroups), add Aqua + ExplicitImports QA, SafeTestsets isolation, and a
GitHub Actions CI matrix.

Substantially expands correctness coverage for cs_qr, cs_lu, cs_cholesky:
known-answer matrices, identity / diagonal / tridiagonal cases, n=1 trivial
case, input-matrix immutability, rhs immutability, multiple solves on one
factorization, idempotent explicit finalize, cross-factorization consistency
(QR vs LU on non-singular, QR vs LU vs Cholesky on SPD), LU pivoting on a
zero-diagonal matrix, Hermitian (non-symmetric) Cholesky with complex
off-diagonals, and overdetermined least-squares coefficient match against
dense backslash.

Two QA-driven source/compat fixes:
- src/CXSparse.jl: `using LinearAlgebra` -> explicit `using LinearAlgebra:
  LinearAlgebra, ldiv!` (ExplicitImports).
- Project.toml: add compat for Random and Test (Aqua). Bump julia compat
  1.10 -> 1.11 to match the actual CXSparse_jll v4 SuiteSparse_jll
  requirement (resolver fails on 1.10).

626 tests pass on Julia 1.11.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 27, 2026

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

CXSparse_jll has two distinct version series in the General registry:
- 4.4.x — uses the upstream CXSparse 4.4 release version directly
- 400.400.200 — uses the SuiteSparse-bundle version scheme (4.4.0 → 400.400.200)
  with looser SuiteSparse_jll compat that admits 7.7 and 7.8

The previous compat `"4"` selected only the 4.4.x series, which pins
SuiteSparse_jll ~7.7. Julia 1.12 ships SuiteSparse_jll 7.8.3 in its stdlib,
so resolution fails on 1.12 (CI was red on every Julia 1 / 1.12 job).

Allowing both series ("4, 400") lets the resolver pick the appropriate one
per Julia version. Tests pass on Julia 1.11 (v4.4.0) and Julia 1.12
(v400.400.200), 626 tests each.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
@ChrisRackauckas ChrisRackauckas marked this pull request as ready for review May 27, 2026 16:48
@ChrisRackauckas ChrisRackauckas merged commit 3028659 into main May 27, 2026
8 checks passed
@ChrisRackauckas ChrisRackauckas deleted the sciml-test-setup-and-correctness branch May 27, 2026 16:48
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.

3 participants