Skip to content

Commit 25fd000

Browse files
committed
Use trapezoidal rule comparison by default
1 parent c8b35f1 commit 25fd000

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/test/compare.jl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,19 @@ struct DefaultComparison
33
function DefaultComparison(field_cmp::Dict{Symbol, Function}=Dict{Symbol, Function}(); use_defaults=true)
44
if use_defaults
55
merge!(field_cmp, Dict{Symbol, Function}([
6-
:L∞ => (delta, t) -> norm.(delta, Inf),
7-
:L1 => (delta, t) -> norm.(delta, 1),
8-
:L2 => (delta, t) -> norm.(delta, 2),
9-
:rms => (delta, t) -> sqrt.(1/length(t) .* sum.(map(d-> d .^ 2, delta))),
10-
:final => (delta, t) -> last.(delta)]))
6+
:L∞ => (delta, dt_delta, t) -> norm.(dt_delta, Inf),
7+
:L1 => (delta, dt_delta, t) -> norm.(dt_delta, 1),
8+
:L2 => (delta, dt_delta, t) -> norm.(dt_delta, 2),
9+
:rms => (delta, dt_delta, t) -> sqrt.(1/length(t) .* sum.(map(d-> d .^ 2, dt_delta))),
10+
:final => (delta, dt_delta, t) -> last.(delta)]))
1111
end
1212
return new(field_cmp)
1313
end
1414
end
1515
function (d::DefaultComparison)(c, names, b, t, n, r)
1616
delta = map((o, re) -> o .- re, n, r)
17-
cmps = [name => cmper(delta, t) for (name, cmper) in d.field_cmp]
17+
dt_delta = map(d -> 0.5 * (d[1:end-1] .+ d[2:end]) .* (t[2:end] .- t[1:end-1]), delta)
18+
cmps = [name => cmper(delta, dt_delta, t) for (name, cmper) in d.field_cmp]
1819
return DataFrame([:var => names, cmps...,
1920
:observed => SymbolicIndexingInterface.is_observed.(c, b)])
2021
end

0 commit comments

Comments
 (0)