Add explicit error for Simple algorithms iterator interface #714
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #712
This PR adds a clear error message when users attempt to use the iterator interface (
init
/step!
) with Simple algorithms from SimpleNonlinearSolve.jl.Problem
Previously, when users tried to use Simple algorithms with the iterator interface, they received a confusing error about a missing
force_stop
field. This made it unclear what the actual problem was.Solution
Added an override of
SciMLBase.init()
forAbstractSimpleNonlinearSolveAlgorithm
that throws a descriptive error message explaining:NewtonRaphson()
,TrustRegion()
, etc., or usesolve(prob, alg)
directlyChanges
lib/SimpleNonlinearSolve/src/SimpleNonlinearSolve.jl
: AddedSciMLBase.init()
override with clear error message (lines 127-148)lib/SimpleNonlinearSolve/test/core/iterator_interface_tests.jl
: Added tests to verify error behavior using@test_throws
patternTesting
The test file uses the
@testitem
macro withtags=[:core]
, which means it's automatically discovered and run by@run_package_tests
inruntests.jl
.All Simple algorithms tested:
Tests verify:
init(prob, alg)
using@test_throws
err.value
)solve(prob, alg)
still works correctlyExample Error Message
Test Plan
Run the core tests:
julia --project=lib/SimpleNonlinearSolve -e 'using Pkg; Pkg.test(test_args=["GROUP=core"])'
🤖 Generated with Claude Code