Skip to content

Commit ca78852

Browse files
committed
Format
1 parent 94576db commit ca78852

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

src/debugging.jl

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ struct LoggedFun{F}
66
args::Any
77
error_nonfinite::Bool
88
end
9-
LoggedFunctionException(lf::LoggedFun, args, msg) = LoggedFunctionException(
10-
"Function $(lf.f)($(join(lf.args, ", "))) " * msg * " with input" *
11-
join("\n " .* string.(lf.args .=> args)) # one line for each "var => val" for readability
12-
)
9+
function LoggedFunctionException(lf::LoggedFun, args, msg)
10+
LoggedFunctionException(
11+
"Function $(lf.f)($(join(lf.args, ", "))) " * msg * " with input" *
12+
join("\n " .* string.(lf.args .=> args)) # one line for each "var => val" for readability
13+
)
14+
end
1315
Base.showerror(io::IO, err::LoggedFunctionException) = print(io, err.msg)
1416
Base.nameof(lf::LoggedFun) = nameof(lf.f)
1517
SymbolicUtils.promote_symtype(::LoggedFun, Ts...) = Real
@@ -30,7 +32,9 @@ function logged_fun(f, args...; error_nonfinite = true) # remember to update err
3032
term(LoggedFun(f, args, error_nonfinite), args..., type = Real)
3133
end
3234

33-
debug_sub(eq::Equation, funcs; kw...) = debug_sub(eq.lhs, funcs; kw...) ~ debug_sub(eq.rhs, funcs; kw...)
35+
function debug_sub(eq::Equation, funcs; kw...)
36+
debug_sub(eq.lhs, funcs; kw...) ~ debug_sub(eq.rhs, funcs; kw...)
37+
end
3438
function debug_sub(ex, funcs; kw...)
3539
iscall(ex) || return ex
3640
f = operation(ex)

src/systems/abstractsystem.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2278,7 +2278,8 @@ ERROR: Function /(1, sin(P(t))) output non-finite value Inf with input
22782278
sin(P(t)) => 0.0
22792279
```
22802280
"""
2281-
function debug_system(sys::AbstractSystem; functions = [log, sqrt, (^), /, inv, asin, acos], kw...)
2281+
function debug_system(
2282+
sys::AbstractSystem; functions = [log, sqrt, (^), /, inv, asin, acos], kw...)
22822283
if !(functions isa Set)
22832284
functions = Set(functions) # more efficient "in" lookup
22842285
end

test/odesystem.jl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -931,11 +931,9 @@ testdict = Dict([:name => "test"])
931931
@named sys = ODESystem(eqs, t, metadata = testdict)
932932
@test get_metadata(sys) == testdict
933933

934-
@variables P(t) = NaN Q(t) = NaN
935-
@named sys = ODESystem([
936-
D(Q) ~ 1 / sin(P)
937-
D(P) ~ log(-cos(Q))
938-
], t, [P, Q], [])
934+
@variables P(t)=NaN Q(t)=NaN
935+
eqs = [D(Q) ~ 1 / sin(P), D(P) ~ log(-cos(Q))]
936+
@named sys = ODESystem(eqs, t, [P, Q], [])
939937
sys = complete(debug_system(sys))
940938
prob = ODEProblem(sys, [], (0.0, 1.0))
941939
@test_throws "log(-cos(Q(t))) errors" prob.f([1, 0], prob.p, 0.0)

0 commit comments

Comments
 (0)