Skip to content

Commit f84ae68

Browse files
test: add DynamicQuantities+Measurements downstream test
Adds `test/downstream/dynamicquantities_measurements.jl` covering a Tsit5 solve of a problem whose state type combines DynamicQuantities units with Measurements uncertainty propagation. Wires it into the existing `Downstream` CI group so the extra deps (DynamicQuantities, plus the existing Measurements) stay in `test/downstream/Project.toml` and don't leak into `OrdinaryDiffEqCore`'s own test deps. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
1 parent 3a8856e commit f84ae68

3 files changed

Lines changed: 24 additions & 0 deletions

File tree

test/downstream/Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[deps]
22
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
33
DifferentiationInterface = "a0c0ee7d-e4b9-4e03-894e-1c5f64a51d63"
4+
DynamicQuantities = "06fc5a27-2a28-4c7c-a15d-362465fb6821"
45
Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9"
56
FiniteDiff = "6a86dc24-6348-571c-b903-95158fe2bd41"
67
Measurements = "eff96d63-e80a-5855-80a2-b1b0885c5ab7"
@@ -11,6 +12,7 @@ StochasticDiffEq = "789caeaf-c7a9-5a7d-9973-96adeb23e2a0"
1112
[compat]
1213
ADTypes = "1.16"
1314
DifferentiationInterface = "0.6.54, 0.7"
15+
DynamicQuantities = "1.8"
1416
Enzyme = "0.13"
1517
FiniteDiff = "2.27"
1618
Measurements = "2.9"
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using OrdinaryDiffEq
2+
using DynamicQuantities
3+
using Measurements
4+
using Test
5+
6+
@testset "DynamicQuantities units + Measurements uncertainty" begin
7+
u0 = (1.0 ± 0.1) * (1.0u"m")
8+
tspan = (0.0u"s", 1.0u"s")
9+
10+
f(u, p, t) = u / (1u"s")
11+
prob = ODEProblem(f, u0, tspan)
12+
13+
sol = solve(prob, Tsit5(); abstol = 1.0e-9, reltol = 1.0e-9)
14+
15+
@test sol.u[end] isa typeof(u0)
16+
@test eltype(sol.u) == typeof(u0)
17+
18+
uend_m = ustrip(u"m", sol.u[end])
19+
@test isapprox(Measurements.value(uend_m), exp(1); atol = 1.0e-6)
20+
@test Measurements.uncertainty(uend_m) > 0
21+
end

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ end
190190
activate_downstream_env()
191191
@time @safetestset "Measurements Tests" include("downstream/measurements.jl")
192192
@time @safetestset "Time derivative Tests" include("downstream/time_derivative_test.jl")
193+
@time @safetestset "DynamicQuantities + Measurements Tests" include("downstream/dynamicquantities_measurements.jl")
193194
end
194195

195196
# AD tests - Enzyme/Zygote only on Julia <= 1.11 (see https://github.com/EnzymeAD/Enzyme.jl/issues/2699)

0 commit comments

Comments
 (0)