Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@ SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
[compat]
OrdinaryDiffEq = "6, 7"
RecursiveArrayTools = "3, 4"
SafeTestsets = "0.0.1, 0.1"
SciMLBase = "2.152, 3"
SciMLTesting = "1"
Test = "1"
julia = "1.10"

[extras]
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
SciMLTesting = "09d9d899-5365-40a9-917a-5f67fddea283"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"

[targets]
test = ["Test", "OrdinaryDiffEq", "Aqua", "JET"]
test = ["Test", "OrdinaryDiffEq", "SafeTestsets", "SciMLTesting"]
15 changes: 15 additions & 0 deletions test/inplace_ode.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using SciMLIterators, OrdinaryDiffEq, Test

f!(du, u, p, t) = (du .= -u)
prob_ip = ODEProblem(f!, [1.0, 2.0], (0.0, 1.0))
sol = solve(prob_ip, Tsit5())

tups = tuples(sol)
@test length(tups) == length(sol.u)
@test tups[1][1] == sol.u[1]

integrator = init(prob_ip, Tsit5())
ts = [0.0, 0.5, 1.0]
iter = TimeChoiceIterator(integrator, ts)
results = collect(iter)
@test length(results) == 3
13 changes: 13 additions & 0 deletions test/integrator_intervals.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using SciMLIterators, OrdinaryDiffEq, Test

f(u, p, t) = -u
prob = ODEProblem(f, 1.0, (0.0, 1.0))

integrator = init(prob, Tsit5())
count = 0
for (uprev, tprev, u, t) in intervals(integrator)
global count += 1
@test t > tprev || count == 1 # first step tprev == t == 0
@test t >= 0.0
end
@test count > 0
13 changes: 13 additions & 0 deletions test/integrator_tuples.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using SciMLIterators, OrdinaryDiffEq, Test

f(u, p, t) = -u
prob = ODEProblem(f, 1.0, (0.0, 1.0))

integrator = init(prob, Tsit5())
count = 0
for (u, t) in tuples(integrator)
global count += 1
@test t >= 0.0
@test t <= 1.0 + eps()
end
@test count > 0
4 changes: 4 additions & 0 deletions test/qa/Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
[deps]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
SciMLIterators = "efe4dcdd-3aed-4391-894d-a9dbd16a2f14"
SciMLTesting = "09d9d899-5365-40a9-917a-5f67fddea283"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[sources]
Expand All @@ -10,5 +12,7 @@ SciMLIterators = {path = "../.."}
[compat]
Aqua = "0.8"
JET = "0.9,0.10,0.11"
SafeTestsets = "0.0.1, 0.1"
SciMLTesting = "1"
Test = "1"
julia = "1.10"
77 changes: 2 additions & 75 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,75 +1,2 @@
using Test
using SciMLIterators
using OrdinaryDiffEq

const GROUP = get(ENV, "GROUP", "All")

if GROUP == "All" || GROUP == "Core"
@testset "SciMLIterators.jl" begin
# Simple ODE: du/dt = -u
f(u, p, t) = -u
prob = ODEProblem(f, 1.0, (0.0, 1.0))

@testset "Solution tuples" begin
sol = solve(prob, Tsit5())
tups = tuples(sol)
@test length(tups) == length(sol.u)
@test tups[1] == (sol.u[1], sol.t[1])
@test tups[end] == (sol.u[end], sol.t[end])
end

@testset "Integrator tuples" begin
integrator = init(prob, Tsit5())
count = 0
for (u, t) in tuples(integrator)
count += 1
@test t >= 0.0
@test t <= 1.0 + eps()
end
@test count > 0
end

@testset "Integrator intervals" begin
integrator = init(prob, Tsit5())
count = 0
for (uprev, tprev, u, t) in intervals(integrator)
count += 1
@test t > tprev || count == 1 # first step tprev == t == 0
@test t >= 0.0
end
@test count > 0
end

@testset "TimeChoiceIterator" begin
integrator = init(prob, Tsit5())
ts = 0.0:0.25:1.0
iter = TimeChoiceIterator(integrator, ts)
@test length(iter) == length(ts)
results = collect(iter)
@test length(results) == length(ts)
for ((u, t), t_expected) in zip(results, ts)
@test t == t_expected
end
end

@testset "Inplace ODE" begin
f!(du, u, p, t) = (du .= -u)
prob_ip = ODEProblem(f!, [1.0, 2.0], (0.0, 1.0))
sol = solve(prob_ip, Tsit5())

tups = tuples(sol)
@test length(tups) == length(sol.u)
@test tups[1][1] == sol.u[1]

integrator = init(prob_ip, Tsit5())
ts = [0.0, 0.5, 1.0]
iter = TimeChoiceIterator(integrator, ts)
results = collect(iter)
@test length(results) == 3
end
end
end

if GROUP == "QA"
include(joinpath(@__DIR__, "qa", "qa.jl"))
end
using SciMLTesting
run_tests()
10 changes: 10 additions & 0 deletions test/solution_tuples.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using SciMLIterators, OrdinaryDiffEq, Test

f(u, p, t) = -u
prob = ODEProblem(f, 1.0, (0.0, 1.0))

sol = solve(prob, Tsit5())
tups = tuples(sol)
@test length(tups) == length(sol.u)
@test tups[1] == (sol.u[1], sol.t[1])
@test tups[end] == (sol.u[end], sol.t[end])
14 changes: 14 additions & 0 deletions test/time_choice_iterator.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using SciMLIterators, OrdinaryDiffEq, Test

f(u, p, t) = -u
prob = ODEProblem(f, 1.0, (0.0, 1.0))

integrator = init(prob, Tsit5())
ts = 0.0:0.25:1.0
iter = TimeChoiceIterator(integrator, ts)
@test length(iter) == length(ts)
results = collect(iter)
@test length(results) == length(ts)
for ((u, t), t_expected) in zip(results, ts)
@test t == t_expected
end
Loading