From 505baee0b3ff12d739512e6c2b85cbddfd3c40cb Mon Sep 17 00:00:00 2001 From: Claude Code Date: Sun, 4 Jan 2026 07:25:56 -0500 Subject: [PATCH] Switch from JuliaFormatter to Runic.jl for code formatting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Update CI workflow to use fredrikekre/runic-action@v1 - Remove .JuliaFormatter.toml configuration - Format all source files with Runic.jl 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .JuliaFormatter.toml | 1 - .github/workflows/FormatCheck.yml | 14 +- src/ODEInterfaceDiffEq.jl | 36 ++--- src/integrator_types.jl | 16 +- src/integrator_utils.jl | 52 ++++--- src/solve.jl | 239 +++++++++++++++++++----------- test/algorithm_tests.jl | 2 +- test/callbacks.jl | 8 +- test/jac_tests.jl | 4 +- 9 files changed, 227 insertions(+), 145 deletions(-) delete mode 100644 .JuliaFormatter.toml diff --git a/.JuliaFormatter.toml b/.JuliaFormatter.toml deleted file mode 100644 index 453925c..0000000 --- a/.JuliaFormatter.toml +++ /dev/null @@ -1 +0,0 @@ -style = "sciml" \ No newline at end of file diff --git a/.github/workflows/FormatCheck.yml b/.github/workflows/FormatCheck.yml index c240796..6762c6f 100644 --- a/.github/workflows/FormatCheck.yml +++ b/.github/workflows/FormatCheck.yml @@ -1,13 +1,19 @@ -name: "Format Check" +name: format-check on: push: branches: - 'master' + - 'main' + - 'release-' tags: '*' pull_request: jobs: - format-check: - name: "Format Check" - uses: "SciML/.github/.github/workflows/format-check.yml@v1" + runic: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: fredrikekre/runic-action@v1 + with: + version: '1' diff --git a/src/ODEInterfaceDiffEq.jl b/src/ODEInterfaceDiffEq.jl index 1360886..dd86b18 100644 --- a/src/ODEInterfaceDiffEq.jl +++ b/src/ODEInterfaceDiffEq.jl @@ -2,29 +2,31 @@ __precompile__() module ODEInterfaceDiffEq -using Reexport -@reexport using DiffEqBase + using Reexport + @reexport using DiffEqBase -using ODEInterface, Compat, DataStructures, FunctionWrappers -using LinearAlgebra + using ODEInterface, Compat, DataStructures, FunctionWrappers + using LinearAlgebra -import DiffEqBase: solve + import DiffEqBase: solve -const warnkeywords = (:save_idxs, :d_discontinuities, :unstable_check, :tstops, - :calck, :progress, :dense, :save_start) + const warnkeywords = ( + :save_idxs, :d_discontinuities, :unstable_check, :tstops, + :calck, :progress, :dense, :save_start, + ) -function __init__() - global warnlist = Set(warnkeywords) -end + function __init__() + return global warnlist = Set(warnkeywords) + end -const KW = Dict{Symbol, Any} + const KW = Dict{Symbol, Any} -include("algorithms.jl") -include("integrator_types.jl") -include("integrator_utils.jl") -include("solve.jl") + include("algorithms.jl") + include("integrator_types.jl") + include("integrator_utils.jl") + include("solve.jl") -export ODEInterfaceAlgorithm, dopri5, dop853, odex, seulex, radau, radau5, rodas, - ddeabm, ddebdf + export ODEInterfaceAlgorithm, dopri5, dop853, odex, seulex, radau, radau5, rodas, + ddeabm, ddebdf end # module diff --git a/src/integrator_types.jl b/src/integrator_types.jl index 0ff7135..ce28b33 100644 --- a/src/integrator_types.jl +++ b/src/integrator_types.jl @@ -5,9 +5,11 @@ mutable struct DEOptions{SType, CType} callback::CType end -mutable struct ODEInterfaceIntegrator{F, algType, uType, uPrevType, oType, SType, solType, - P, CallbackCacheType} <: - DiffEqBase.AbstractODEIntegrator{algType, true, uType, Float64} +mutable struct ODEInterfaceIntegrator{ + F, algType, uType, uPrevType, oType, SType, solType, + P, CallbackCacheType, + } <: + DiffEqBase.AbstractODEIntegrator{algType, true, uType, Float64} f::F u::uType uprev::uPrevType @@ -27,9 +29,11 @@ mutable struct ODEInterfaceIntegrator{F, algType, uType, uPrevType, oType, SType last_event_error::Float64 end -@inline function (integrator::ODEInterfaceIntegrator)(t, deriv::Type{Val{N}} = Val{0}; - idxs = nothing) where {N} - @assert N==0 "ODEInterface does not support dense derivative" +@inline function (integrator::ODEInterfaceIntegrator)( + t, deriv::Type{Val{N}} = Val{0}; + idxs = nothing + ) where {N} + @assert N == 0 "ODEInterface does not support dense derivative" sol = integrator.eval_sol_fcn(t) return idxs == nothing ? sol : sol[idxs] end diff --git a/src/integrator_utils.jl b/src/integrator_utils.jl index 27552f1..1bb31bc 100644 --- a/src/integrator_utils.jl +++ b/src/integrator_utils.jl @@ -9,19 +9,23 @@ function handle_callbacks!(integrator, eval_sol_fcn) saved_in_cb = false if !(continuous_callbacks isa Tuple{}) time, upcrossing, - event_occurred, - event_idx, - idx, - counter = DiffEqBase.find_first_continuous_callback(integrator, - continuous_callbacks...) + event_occurred, + event_idx, + idx, + counter = DiffEqBase.find_first_continuous_callback( + integrator, + continuous_callbacks... + ) if event_occurred integrator.event_last_time = idx integrator.vector_event_last_time = event_idx continuous_modified, - saved_in_cb = DiffEqBase.apply_callback!(integrator, + saved_in_cb = DiffEqBase.apply_callback!( + integrator, continuous_callbacks[idx], time, upcrossing, - event_idx) + event_idx + ) else integrator.event_last_time = 0 integrator.vector_event_last_time = 1 @@ -29,18 +33,22 @@ function handle_callbacks!(integrator, eval_sol_fcn) end if !(discrete_callbacks isa Tuple{}) discrete_modified, - saved_in_cb = DiffEqBase.apply_discrete_callback!(integrator, - discrete_callbacks...) + saved_in_cb = DiffEqBase.apply_discrete_callback!( + integrator, + discrete_callbacks... + ) end if !saved_in_cb savevalues!(integrator) end - integrator.u_modified = continuous_modified || discrete_modified + return integrator.u_modified = continuous_modified || discrete_modified end -function DiffEqBase.savevalues!(integrator::ODEInterfaceIntegrator, - force_save = false)::Tuple{Bool, Bool} +function DiffEqBase.savevalues!( + integrator::ODEInterfaceIntegrator, + force_save = false + )::Tuple{Bool, Bool} saved, savedexactly = false, false !integrator.opts.save_on && return saved, savedexactly uType = eltype(integrator.sol.u) @@ -52,7 +60,7 @@ function DiffEqBase.savevalues!(integrator::ODEInterfaceIntegrator, end while !isempty(integrator.opts.saveat) && - integrator.tdir * first(integrator.opts.saveat) < integrator.tdir * integrator.t + integrator.tdir * first(integrator.opts.saveat) < integrator.tdir * integrator.t saved = true curt = pop!(integrator.opts.saveat) tmp = integrator(curt)::Vector{Float64} @@ -63,9 +71,11 @@ function DiffEqBase.savevalues!(integrator::ODEInterfaceIntegrator, return saved, savedexactly end -function DiffEqBase.change_t_via_interpolation!(integrator::ODEInterfaceIntegrator, t, +function DiffEqBase.change_t_via_interpolation!( + integrator::ODEInterfaceIntegrator, t, modify_save_endpoint::Type{Val{T}} = Val{false}, - reinitialize_alg = nothing) where {T} + reinitialize_alg = nothing + ) where {T} integrator.t = t tmp = integrator(integrator.t)::Vector{Float64} if eltype(integrator.sol.u) <: Vector @@ -73,7 +83,7 @@ function DiffEqBase.change_t_via_interpolation!(integrator::ODEInterfaceIntegrat else integrator.u .= reshape(tmp, integrator.sizeu) end - nothing + return nothing end DiffEqBase.get_tmp_cache(i::ODEInterfaceIntegrator, args...) = nothing @@ -86,7 +96,7 @@ DiffEqBase.get_tmp_cache(i::ODEInterfaceIntegrator, args...) = nothing end @inline function DiffEqBase.u_modified!(integrator::ODEInterfaceIntegrator, bool::Bool) - integrator.u_modified = bool + return integrator.u_modified = bool end function initialize_callbacks!(integrator, initialize_save = true) @@ -100,14 +110,16 @@ function initialize_callbacks!(integrator, initialize_save = true) # if the user modifies u, we need to fix current values if u_modified if initialize_save && - (any((c) -> c.save_positions[2], callbacks.discrete_callbacks) || - any((c) -> c.save_positions[2], callbacks.continuous_callbacks)) + ( + any((c) -> c.save_positions[2], callbacks.discrete_callbacks) || + any((c) -> c.save_positions[2], callbacks.continuous_callbacks) + ) savevalues!(integrator, true) end end # reset this as it is now handled so the integrators should proceed as normal - integrator.u_modified = false + return integrator.u_modified = false end DiffEqBase.set_proposed_dt!(integrator::ODEInterfaceIntegrator, dt) = nothing diff --git a/src/solve.jl b/src/solve.jl index aaea6d0..addd940 100644 --- a/src/solve.jl +++ b/src/solve.jl @@ -6,12 +6,13 @@ function DiffEqBase.__solve( verbose = true, save_everystep = isempty(saveat), save_on = true, save_start = save_everystep || isempty(saveat) || - saveat isa Number ? true : - prob.tspan[1] in saveat, + saveat isa Number ? true : + prob.tspan[1] in saveat, timeseries_errors = true, dense_errors = false, callback = nothing, alias_u0 = false, - kwargs...) where - {uType, tuptType, isinplace, AlgType <: ODEInterfaceAlgorithm} + kwargs... + ) where + {uType, tuptType, isinplace, AlgType <: ODEInterfaceAlgorithm} tType = eltype(tuptType) isstiff = alg isa ODEInterfaceImplicitAlgorithm @@ -30,8 +31,10 @@ function DiffEqBase.__solve( max_len_cb = DiffEqBase.max_vector_callback_length(callbacks_internal) if max_len_cb isa VectorContinuousCallback - callback_cache = DiffEqBase.CallbackCache(max_len_cb.len, uBottomEltype, - uBottomEltype) + callback_cache = DiffEqBase.CallbackCache( + max_len_cb.len, uBottomEltype, + uBottomEltype + ) else callback_cache = nothing end @@ -70,29 +73,38 @@ function DiffEqBase.__solve( uprev = similar(u) - sol = DiffEqBase.build_solution(prob, alg, ts, _timeseries, + sol = DiffEqBase.build_solution( + prob, alg, ts, _timeseries, timeseries_errors = timeseries_errors, calculate_error = false, stats = DiffEqBase.Stats(0), - retcode = ReturnCode.Default) + retcode = ReturnCode.Default + ) opts = DEOptions(saveat_internal, save_on, save_everystep, callbacks_internal) if !isinplace && u isa AbstractArray f! = ( - t, u, du) -> (du[:] = vec(prob.f(reshape(u, sizeu), integrator.p, t)); nothing) + t, u, du, + ) -> (du[:] = vec(prob.f(reshape(u, sizeu), integrator.p, t)); nothing) elseif !(u isa Vector{Float64}) - f! = (t, + f! = ( + t, u, - du) -> (prob.f(reshape(du, sizeu), reshape(u, sizeu), integrator.p, t); + du, + ) -> ( + prob.f(reshape(du, sizeu), reshape(u, sizeu), integrator.p, t); du = vec(du); - nothing) + nothing + ) else f! = (t, u, du) -> prob.f(du, u, integrator.p, t) end - integrator = ODEInterfaceIntegrator(prob.f, u, uprev, tspan[1], tspan[1], prob.p, opts, + integrator = ODEInterfaceIntegrator( + prob.f, u, uprev, tspan[1], tspan[1], prob.p, opts, false, tdir, sizeu, sol, - (t) -> [t], 0, 1, callback_cache, alg, 0.0) + (t) -> [t], 0, 1, callback_cache, alg, 0.0 + ) initialize_callbacks!(integrator) outputfcn = OutputFunction(integrator) @@ -108,10 +120,12 @@ function DiffEqBase.__solve( o[:OUTPUTMODE] = ODEInterface.OUTPUTFCN_WODENSE end - dict = buildOptions(o, + dict = buildOptions( + o, ODEINTERFACE_OPTION_LIST, ODEINTERFACE_ALIASES, - ODEINTERFACE_ALIASES_REVERSED) + ODEINTERFACE_ALIASES_REVERSED + ) if prob.f.mass_matrix != I if prob.f.mass_matrix isa Matrix && isstiff dict[:MASSMATRIX] = prob.f.mass_matrix @@ -134,46 +148,64 @@ function DiffEqBase.__solve( if alg isa dopri5 tend, uend, - retcode, - stats = ODEInterface.dopri5(f!, tspan[1], tspan[2], - vec(integrator.u), opts) + retcode, + stats = ODEInterface.dopri5( + f!, tspan[1], tspan[2], + vec(integrator.u), opts + ) elseif alg isa dop853 tend, uend, - retcode, - stats = ODEInterface.dop853(f!, tspan[1], tspan[2], - vec(integrator.u), opts) + retcode, + stats = ODEInterface.dop853( + f!, tspan[1], tspan[2], + vec(integrator.u), opts + ) elseif alg isa odex tend, uend, - retcode, stats = ODEInterface.odex(f!, tspan[1], tspan[2], - vec(integrator.u), opts) + retcode, stats = ODEInterface.odex( + f!, tspan[1], tspan[2], + vec(integrator.u), opts + ) elseif alg isa seulex tend, uend, - retcode, - stats = ODEInterface.seulex(f!, tspan[1], tspan[2], - vec(integrator.u), opts) + retcode, + stats = ODEInterface.seulex( + f!, tspan[1], tspan[2], + vec(integrator.u), opts + ) elseif alg isa radau tend, uend, - retcode, stats = ODEInterface.radau(f!, tspan[1], tspan[2], - vec(integrator.u), opts) + retcode, stats = ODEInterface.radau( + f!, tspan[1], tspan[2], + vec(integrator.u), opts + ) elseif alg isa radau5 tend, uend, - retcode, - stats = ODEInterface.radau5(f!, tspan[1], tspan[2], - vec(integrator.u), opts) + retcode, + stats = ODEInterface.radau5( + f!, tspan[1], tspan[2], + vec(integrator.u), opts + ) elseif alg isa rodas tend, uend, - retcode, stats = ODEInterface.rodas(f!, tspan[1], tspan[2], - vec(integrator.u), opts) + retcode, stats = ODEInterface.rodas( + f!, tspan[1], tspan[2], + vec(integrator.u), opts + ) elseif alg isa ddeabm tend, uend, - retcode, - stats = ODEInterface.ddeabm(f!, tspan[1], tspan[2], - vec(integrator.u), opts) + retcode, + stats = ODEInterface.ddeabm( + f!, tspan[1], tspan[2], + vec(integrator.u), opts + ) elseif alg isa ddebdf tend, uend, - retcode, - stats = ODEInterface.ddebdf(f!, tspan[1], tspan[2], - vec(integrator.u), opts) + retcode, + stats = ODEInterface.ddebdf( + f!, tspan[1], tspan[2], + vec(integrator.u), opts + ) end if !save_everystep @@ -200,9 +232,11 @@ function DiffEqBase.__solve( end if DiffEqBase.has_analytic(prob.f) - DiffEqBase.calculate_solution_errors!(integrator.sol; + DiffEqBase.calculate_solution_errors!( + integrator.sol; timeseries_errors = timeseries_errors, - dense_errors = dense_errors) + dense_errors = dense_errors + ) end destats = sol.stats @@ -217,19 +251,19 @@ function DiffEqBase.__solve( if haskey(stats, "no_lu_decomp") destats.nw = stats["no_lu_decomp"] end - DiffEqBase.solution_new_retcode(sol, return_retcode) + return DiffEqBase.solution_new_retcode(sol, return_retcode) end function save_value!(_timeseries, u, ::Type{T}, sizeu) where {T <: Number} - push!(_timeseries, first(u)) + return push!(_timeseries, first(u)) end function save_value!(_timeseries, u, ::Type{T}, sizeu) where {T <: Vector} - push!(_timeseries, u) + return push!(_timeseries, u) end function save_value!(_timeseries, u, ::Type{T}, sizeu) where {T <: Array} - push!(_timeseries, reshape(u, sizeu)) + return push!(_timeseries, reshape(u, sizeu)) end function buildOptions(o, optionlist, aliases, aliases_reversed) @@ -241,23 +275,35 @@ function buildOptions(o, optionlist, aliases, aliases_reversed) result[aliases_reversed[k]] = v end end - result + return result end function saveat_disc_handling(saveat, tdir, tspan, tType) if saveat isa Number if (tspan[1]:saveat:tspan[end])[end] == tspan[end] - saveat_vec = convert(Vector{tType}, - collect(tType, (tspan[1] + saveat):saveat:tspan[end])) + saveat_vec = convert( + Vector{tType}, + collect(tType, (tspan[1] + saveat):saveat:tspan[end]) + ) else - saveat_vec = convert(Vector{tType}, - collect(tType, - (tspan[1] + saveat):saveat:(tspan[end] - saveat))) + saveat_vec = convert( + Vector{tType}, + collect( + tType, + (tspan[1] + saveat):saveat:(tspan[end] - saveat) + ) + ) end else - saveat_vec = vec(collect(tType, - Iterators.filter(x -> tdir * tspan[1] < tdir * x < - tdir * tspan[end], saveat))) + saveat_vec = vec( + collect( + tType, + Iterators.filter( + x -> tdir * tspan[1] < tdir * x < + tdir * tspan[end], saveat + ) + ) + ) end if tdir > 0 @@ -266,45 +312,55 @@ function saveat_disc_handling(saveat, tdir, tspan, tType) saveat_internal = BinaryMaxHeap(saveat_vec) end - saveat_internal + return saveat_internal end -const ODEINTERFACE_OPTION_LIST = Set([:RTOL, :ATOL, :OUTPUTFCN, :OUTPUTMODE, :MAXSTEPS, - :STEST, :EPS, :RHO, :SSMINSEL, - :SSMAXSEL, :SSBETA, :MAXSS, :INITIALSS, - :MAXEXCOLUMN, :STEPSIZESEQUENCE, - :MAXSTABCHECKS, :MAXSTABCHECKLINE, - :DENSEOUTPUTWOEE, :INTERPOLDEGRE, - :SSREDUCTION, :SSSELECTPAR1, :SSSELECTPAR2, - :ORDERDECFRAC, :ORDERINCFRAC, - :OPT_RHO, :OPT_RHO2, :RHSAUTONOMOUS, :M1, :M2, - :LAMBDADENSE, :TRANSJTOH, - :STEPSIZESEQUENCE, :JACRECOMPFACTOR, :MASSMATRIX, - :JACOBIMATRIX, :JACOBIBANDSSTRUCT, - :WORKFORRHS, :WORKFORJAC, :WORKFORDEC, :WORKFORSOL, - :MAXNEWTONITER, :NEWTONSTARTZERO, :NEWTONSTOPCRIT, - :DIMFIND1VAR, - :MAXSTAGES, :MINSTAGES, :INITSTAGES, - :STEPSIZESTRATEGY, - :FREEZESSLEFT, :FREEZESSRIGHT, :ORDERDECFACTOR, - :ORDERINCFACTOR, :ORDERDECCSTEPFAC1, - :ORDERDECSTEPFAC2, :RHS_CALLMODE -]) - -const ODEINTERFACE_ALIASES = Dict{Symbol, Symbol}(:RTOL => :reltol, +const ODEINTERFACE_OPTION_LIST = Set( + [ + :RTOL, :ATOL, :OUTPUTFCN, :OUTPUTMODE, :MAXSTEPS, + :STEST, :EPS, :RHO, :SSMINSEL, + :SSMAXSEL, :SSBETA, :MAXSS, :INITIALSS, + :MAXEXCOLUMN, :STEPSIZESEQUENCE, + :MAXSTABCHECKS, :MAXSTABCHECKLINE, + :DENSEOUTPUTWOEE, :INTERPOLDEGRE, + :SSREDUCTION, :SSSELECTPAR1, :SSSELECTPAR2, + :ORDERDECFRAC, :ORDERINCFRAC, + :OPT_RHO, :OPT_RHO2, :RHSAUTONOMOUS, :M1, :M2, + :LAMBDADENSE, :TRANSJTOH, + :STEPSIZESEQUENCE, :JACRECOMPFACTOR, :MASSMATRIX, + :JACOBIMATRIX, :JACOBIBANDSSTRUCT, + :WORKFORRHS, :WORKFORJAC, :WORKFORDEC, :WORKFORSOL, + :MAXNEWTONITER, :NEWTONSTARTZERO, :NEWTONSTOPCRIT, + :DIMFIND1VAR, + :MAXSTAGES, :MINSTAGES, :INITSTAGES, + :STEPSIZESTRATEGY, + :FREEZESSLEFT, :FREEZESSRIGHT, :ORDERDECFACTOR, + :ORDERINCFACTOR, :ORDERDECCSTEPFAC1, + :ORDERDECSTEPFAC2, :RHS_CALLMODE, + ] +) + +const ODEINTERFACE_ALIASES = Dict{Symbol, Symbol}( + :RTOL => :reltol, :ATOL => :abstol, :MAXSTEPS => :maxiters, :MAXSS => :dtmax, :INITIALSS => :dt, #:SSMINSEL=>:qmin, :SSBETA => :beta2, - :SSMAXSEL => :qmax) - -const ODEINTERFACE_ALIASES_REVERSED = Dict{Symbol, Symbol}([(v, k) - for (k, v) in - ODEINTERFACE_ALIASES]) - -const ODEINTERFACE_STRINGS = Dict{Symbol, String}(:LOGIO => "logio", + :SSMAXSEL => :qmax +) + +const ODEINTERFACE_ALIASES_REVERSED = Dict{Symbol, Symbol}( + [ + (v, k) + for (k, v) in + ODEINTERFACE_ALIASES + ] +) + +const ODEINTERFACE_STRINGS = Dict{Symbol, String}( + :LOGIO => "logio", :LOGLEVEL => "loglevel", :RHS_CALLMODE => "RightHandSideCallMode", :RTOL => "RelTol", @@ -362,15 +418,18 @@ const ODEINTERFACE_STRINGS = Dict{Symbol, String}(:LOGIO => "logio", :WORKFORSOL => "WorkForSubstitution", :BVPCLASS => "BoundaryValueProblemClass", :SOLMETHOD => "SolutionMethod", - :IVPOPT => "OptionsForIVPsolver") + :IVPOPT => "OptionsForIVPsolver" +) struct OutputFunction{T} <: Function integrator::T end -function (f::OutputFunction)(reason::ODEInterface.OUTPUTFCN_CALL_REASON, +function (f::OutputFunction)( + reason::ODEInterface.OUTPUTFCN_CALL_REASON, tprev::Float64, t::Float64, u::Vector{Float64}, - eval_sol_fcn, extra_data::Dict) + eval_sol_fcn, extra_data::Dict + ) if reason == ODEInterface.OUTPUTFCN_CALL_STEP integrator = f.integrator @@ -402,5 +461,5 @@ function (f::OutputFunction)(reason::ODEInterface.OUTPUTFCN_CALL_REASON, end - ODEInterface.OUTPUTFCN_RET_CONTINUE + return ODEInterface.OUTPUTFCN_RET_CONTINUE end diff --git a/test/algorithm_tests.jl b/test/algorithm_tests.jl index fa35c89..cb2dd76 100644 --- a/test/algorithm_tests.jl +++ b/test/algorithm_tests.jl @@ -1,6 +1,6 @@ using ODEInterfaceDiffEq, DiffEqBase, Test import ODEProblemLibrary: prob_ode_linear, - prob_ode_2Dlinear, prob_ode_vanderpol + prob_ode_2Dlinear, prob_ode_vanderpol prob = prob_ode_linear sol = solve(prob, dopri5(), dt = 1 // 2^(4)) diff --git a/test/callbacks.jl b/test/callbacks.jl index e52c256..30964aa 100644 --- a/test/callbacks.jl +++ b/test/callbacks.jl @@ -2,16 +2,16 @@ using ODEInterfaceDiffEq, Test callback_f = function (du, u, p, t) du[1] = u[2] - du[2] = -9.81 + return du[2] = -9.81 end condition = function (u, t, integrator) # Event when event_f(u,t,k) == 0 - u[1] + return u[1] end affect! = nothing affect_neg! = function (integrator) - integrator.u[2] = -integrator.u[2] + return integrator.u[2] = -integrator.u[2] end callback = ContinuousCallback(condition, affect!, affect_neg!) @@ -23,4 +23,4 @@ prob = ODEProblem(callback_f, u0, tspan) sol = solve(prob, dopri5(), callback = callback, dtmax = 0.5) @test sol(4.0)[1] > 0 sol = solve(prob, dopri5(), callback = callback, save_everystep = true) -@test sol(4.0)[1] > -1e-12 +@test sol(4.0)[1] > -1.0e-12 diff --git a/test/jac_tests.jl b/test/jac_tests.jl index ec8b786..916d5d1 100644 --- a/test/jac_tests.jl +++ b/test/jac_tests.jl @@ -6,7 +6,7 @@ jac_called = false function Lotka(du, u, p, t) du[1] = u[1] - u[1] * u[2] # REPL[7], line 3: du[2] = -3 * u[2] + 1 * u[1] * u[2] - nothing + return nothing end function Lotka_jac(J, u, p, t) @@ -16,7 +16,7 @@ function Lotka_jac(J, u, p, t) J[1, 2] = -u[1] J[2, 1] = 1 * u[2] J[2, 2] = -3 + u[1] - nothing + return nothing end prob = ODEProblem(ODEFunction(Lotka, jac = Lotka_jac), ones(2), (0.0, 2.0))