Skip to content

Add JET.jl static analysis tests and fix Kriging type stability#529

Merged
ChrisRackauckas merged 1 commit intoSciML:masterfrom
ChrisRackauckas-Claude:static-improvements-20251229-004624
Dec 29, 2025
Merged

Add JET.jl static analysis tests and fix Kriging type stability#529
ChrisRackauckas merged 1 commit intoSciML:masterfrom
ChrisRackauckas-Claude:static-improvements-20251229-004624

Conversation

@ChrisRackauckas-Claude
Copy link
Copy Markdown
Contributor

Summary

  • Fix Kriging eigenvalue computation for type stability: The eigen(R).values call could theoretically return complex eigenvalues due to floating point errors, even though R is a symmetric correlation matrix. JET.jl detected this could lead to isless(::Int, ::ComplexF64) errors when comparing eigenvalue differences. Fixed by using eigvals(Symmetric(R)) which guarantees real eigenvalues.

  • Add JET.jl test suite: Added test/jet.jl to test core surrogate constructors for static analysis issues. This catches type instabilities and potential runtime errors at test time.

Changes

  1. src/Kriging.jl:

    • Use eigvals(Symmetric(R)) instead of eigen(R).values to ensure real eigenvalues
    • Use zero(λdiff) instead of hardcoded 0.0 for better type stability/generic precision support
  2. test/jet.jl: New test file with JET analysis for:

    • LinearSurrogate
    • RadialBasis
    • Kriging
    • InverseDistanceSurrogate
    • SecondOrderPolynomialSurrogate
    • LobachevskySurrogate
  3. Project.toml: Added JET as a test dependency

Test plan

  • All existing tests pass (Pkg.test() completed successfully - 317 tests)
  • JET analysis of Kriging now passes without errors
  • Kriging surrogate still produces correct predictions

cc @ChrisRackauckas

🤖 Generated with Claude Code

- Fix Kriging eigenvalue computation to use Symmetric wrapper
  - `eigen(R).values` replaced with `eigvals(Symmetric(R))` to guarantee
    real eigenvalues for symmetric correlation matrices
  - JET previously reported potential `isless(::Int, ::ComplexF64)` errors
  - Also use `zero(λdiff)` instead of hardcoded `0.0` for better type stability

- Add JET.jl test suite (test/jet.jl)
  - Tests core surrogate constructors for static analysis issues
  - Added JET to test dependencies in Project.toml

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@ChrisRackauckas
Copy link
Copy Markdown
Member

JET tests should be in a nopre group!

@ChrisRackauckas ChrisRackauckas merged commit bd7bd25 into SciML:master Dec 29, 2025
5 of 8 checks passed
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.

2 participants