Skip to content

Conversation

@ChrisRackauckas-Claude
Copy link
Contributor

Summary

Add trimming tests to LinearSolve.jl, similar to PR #734 in NonlinearSolve.jl.

This PR adds tests for Julia's trimming feature (available in Julia 1.12+) to verify that LinearSolve can be successfully trimmed when using pre-initialized caches with different LU factorization algorithms.

Changes

  • Add test/trim/ directory with infrastructure for testing trimming
  • Add trim tests for three factorization methods:
    • LUFactorization - Julia's built-in LU factorization
    • MKLLUFactorization - MKL-based LU factorization
    • RFLUFactorization - RecursiveFactorization-based LU factorization
  • Add "Trim" test group to CI configuration
  • Tests only run on Julia 1.12+ (when trimming was introduced)

Test Structure

The tests verify:

  1. Each factorization works correctly with pre-initialized cache
  2. Each implementation can be successfully compiled with juliac --trim

Each test creates a module with:

  • const pre-initialized problem, algorithm, and cache
  • A function that reuses the cache for solving with different parameters
  • A main entry point for juliac compilation

Notes

  • Trim tests only run on Julia 1.12+
  • CI excludes trim tests on LTS and pre-release versions
  • Tests use a custom environment in test/trim/ to avoid conflicts
  • Each factorization is tested separately to ensure independent trimming

Related

🤖 Generated with Claude Code

Co-Authored-By: Claude noreply@anthropic.com

ChrisRackauckas and others added 2 commits November 13, 2025 22:15
…rization

This PR adds trimming tests to LinearSolve.jl, similar to PR SciML#734 in NonlinearSolve.jl.

## Summary
- Add `test/trim/` directory with infrastructure for testing trimming
- Add tests for LUFactorization, MKLLUFactorization, and RFLUFactorization
- Add "Trim" test group to CI configuration
- Tests only run on Julia 1.12+ (when trimming was introduced)

## Test Structure
The tests verify:
1. LUFactorization works correctly with pre-initialized cache
2. MKLLUFactorization works correctly with pre-initialized cache
3. RFLUFactorization works correctly with pre-initialized cache
4. Each implementation can be successfully compiled with \`juliac --trim\`

## Notes
- Trim tests only run on Julia 1.12+
- CI excludes trim tests on LTS and pre-release versions
- Tests use a custom environment in \`test/trim/\` to avoid conflicts

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

Co-Authored-By: Claude <noreply@anthropic.com>
JuliaFormatter should not be a package dependency.

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

Co-Authored-By: Claude <noreply@anthropic.com>
@ChrisRackauckas-Claude
Copy link
Contributor Author

Fixed: Removed JuliaFormatter from dependencies (it was incorrectly added during formatting and should not be a package dependency)

Changed reinit!(cache, b_new) to reinit!(cache; b = b_new)

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

Co-Authored-By: Claude <noreply@anthropic.com>
@ChrisRackauckas-Claude
Copy link
Contributor Author

Fixed: Changed reinit!(cache, b_new) to reinit!(cache; b = b_new) to use proper keyword argument syntax

Changed to capture and return the solution object from solve!(cache)
instead of returning the cache itself.

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

Co-Authored-By: Claude <noreply@anthropic.com>
@ChrisRackauckas-Claude
Copy link
Contributor Author

Fixed: Changed to return the solution object from solve!(cache) instead of returning the cache itself

- Changed tests to check solution values instead of retcode
- Made MKL tests conditional on MKL availability
- This fixes CI failures when MKL is not available

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

Co-Authored-By: Claude <noreply@anthropic.com>
@ChrisRackauckas-Claude
Copy link
Contributor Author

Fixed test failures:

  1. Changed test assertions: Instead of checking retcode, tests now verify the solution values directly using @test sol.u ≈ expected_values
  2. Made MKL tests conditional: MKL tests now only run when MKL is available using LinearSolve.usemkl(nothing) check. This prevents failures on CI runners without MKL binaries.

Tests should now pass on CI.

Changed LinearSolve.usemkl(nothing) to LinearSolve.usemkl
since usemkl is a constant boolean, not a function.

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

Co-Authored-By: Claude <noreply@anthropic.com>
@ChrisRackauckas-Claude
Copy link
Contributor Author

Fixed: Changed LinearSolve.usemkl(nothing) to LinearSolve.usemkl - usemkl is a constant boolean, not a function. This fixes the "MethodError: objects of type Bool are not callable" error.

@ChrisRackauckas ChrisRackauckas merged commit d9b3a96 into SciML:main Nov 14, 2025
136 of 142 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