Skip to content

Commit 508a40b

Browse files
Standardize BDF test setup and remove SplitEuler from tests
1. Updated BDF allocation tests to match LowOrderRK pattern: - Single vector problem for standard BDF solvers - Separate SplitODEProblem for IMEX methods - Consolidated test structure for cleaner organization 2. Removed SplitEuler from LowOrderRK tests: - Removed from allocation_tests.jl solver list - Removed from jet.jl solver list and conditional checks - SplitEuler requires a SplitODEProblem, not compatible with standard ODEProblem 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 1dea2e4 commit 508a40b

File tree

3 files changed

+17
-70
lines changed

3 files changed

+17
-70
lines changed

lib/OrdinaryDiffEqBDF/test/allocation_tests.jl

Lines changed: 14 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,12 @@ Currently, many BDF solvers are allocating and marked with @test_broken.
1010
"""
1111

1212
@testset "BDF Allocation Tests" begin
13-
# Test problem - use a simple linear problem for standard BDF solvers
14-
linear_prob = ODEProblem((u, p, t) -> -u, 1.0, (0.0, 1.0))
15-
16-
# Vector problem for in-place methods
13+
# Test problem for BDF methods
1714
function simple_system!(du, u, p, t)
1815
du[1] = -0.5 * u[1]
1916
du[2] = -1.5 * u[2]
2017
end
21-
vector_prob = ODEProblem(simple_system!, [1.0, 1.0], (0.0, 1.0))
18+
prob = ODEProblem(simple_system!, [1.0, 1.0], (0.0, 1.0))
2219

2320
# Split problem for IMEX methods
2421
function f1!(du, u, p, t)
@@ -31,52 +28,25 @@ Currently, many BDF solvers are allocating and marked with @test_broken.
3128
end
3229
split_prob = SplitODEProblem(f1!, f2!, [1.0, 1.0], (0.0, 1.0))
3330

34-
# Group 1: Standard BDF methods (use linear problem)
35-
standard_bdf_solvers = [ABDF2(), QNDF1(), QBDF1(), QNDF2(), QBDF2(), QNDF(), QBDF(), FBDF(), MEBDF2()]
36-
37-
# Group 2: SBDF methods (use linear problem)
38-
sbdf_solvers = [SBDF(order=2), SBDF2(), SBDF3(), SBDF4()]
31+
# Test all exported BDF solvers for allocation-free behavior
32+
bdf_solvers = [ABDF2(), QNDF1(), QBDF1(), QNDF2(), QBDF2(), QNDF(), QBDF(), FBDF(),
33+
SBDF(order=2), SBDF2(), SBDF3(), SBDF4(), MEBDF2(),
34+
DABDF2(), DImplicitEuler(), DFBDF()]
3935

40-
# Group 3: IMEX methods (use split problem)
36+
# IMEX methods need special handling with split problem
4137
imex_solvers = [IMEXEuler(), IMEXEulerARK()]
4238

43-
# Group 4: Dual/DAE methods (use vector problem)
44-
dual_solvers = [DABDF2(), DImplicitEuler(), DFBDF()]
45-
46-
@testset "Standard BDF Solver Allocation Analysis" begin
47-
for solver in standard_bdf_solvers
39+
@testset "BDF Solver Allocation Analysis" begin
40+
for solver in bdf_solvers
4841
@testset "$(typeof(solver)) allocation check" begin
49-
integrator = init(linear_prob, solver, dt=0.1, save_everystep=false, abstol=1e-6, reltol=1e-6)
42+
integrator = init(prob, solver, dt=0.1, save_everystep=false, abstol=1e-6, reltol=1e-6)
5043
step!(integrator) # Setup step may allocate
5144

52-
# Use AllocCheck for accurate allocation detection
53-
allocs = check_allocs(step!, (typeof(integrator),))
54-
55-
# These solvers should be allocation-free, but mark as broken for now
56-
@test length(allocs) == 0 broken=true
57-
58-
if length(allocs) > 0
59-
println("AllocCheck found $(length(allocs)) allocation sites in $(typeof(solver)) step!:")
60-
for (i, alloc) in enumerate(allocs[1:min(3, end)]) # Show first 3
61-
println(" $i. $alloc")
62-
end
63-
else
64-
println("$(typeof(solver)) appears allocation-free with AllocCheck")
65-
end
66-
end
67-
end
68-
end
69-
70-
@testset "SBDF Solver Allocation Analysis" begin
71-
for solver in sbdf_solvers
72-
@testset "$(typeof(solver)) allocation check" begin
73-
integrator = init(linear_prob, solver, dt=0.1, save_everystep=false, abstol=1e-6, reltol=1e-6)
74-
step!(integrator) # Setup step may allocate
75-
76-
# Use AllocCheck for accurate allocation detection
45+
# Use AllocCheck to verify step! is allocation-free
7746
allocs = check_allocs(step!, (typeof(integrator),))
7847

7948
# These solvers should be allocation-free, but mark as broken for now
49+
# to verify with AllocCheck (more accurate than @allocated)
8050
@test length(allocs) == 0 broken=true
8151

8252
if length(allocs) > 0
@@ -97,34 +67,11 @@ Currently, many BDF solvers are allocating and marked with @test_broken.
9767
integrator = init(split_prob, solver, dt=0.1, save_everystep=false, abstol=1e-6, reltol=1e-6)
9868
step!(integrator) # Setup step may allocate
9969

100-
# Use AllocCheck for accurate allocation detection
101-
allocs = check_allocs(step!, (typeof(integrator),))
102-
103-
# These solvers should be allocation-free, but mark as broken for now
104-
@test length(allocs) == 0 broken=true
105-
106-
if length(allocs) > 0
107-
println("AllocCheck found $(length(allocs)) allocation sites in $(typeof(solver)) step!:")
108-
for (i, alloc) in enumerate(allocs[1:min(3, end)]) # Show first 3
109-
println(" $i. $alloc")
110-
end
111-
else
112-
println("$(typeof(solver)) appears allocation-free with AllocCheck")
113-
end
114-
end
115-
end
116-
end
117-
118-
@testset "Dual/DAE Solver Allocation Analysis" begin
119-
for solver in dual_solvers
120-
@testset "$(typeof(solver)) allocation check" begin
121-
integrator = init(vector_prob, solver, dt=0.1, save_everystep=false, abstol=1e-6, reltol=1e-6)
122-
step!(integrator) # Setup step may allocate
123-
124-
# Use AllocCheck for accurate allocation detection
70+
# Use AllocCheck to verify step! is allocation-free
12571
allocs = check_allocs(step!, (typeof(integrator),))
12672

12773
# These solvers should be allocation-free, but mark as broken for now
74+
# to verify with AllocCheck (more accurate than @allocated)
12875
@test length(allocs) == 0 broken=true
12976

13077
if length(allocs) > 0

lib/OrdinaryDiffEqLowOrderRK/test/allocation_tests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ These tests verify that the step! operation does not allocate during stepping.
1717
prob = ODEProblem(simple_system!, [1.0, 1.0], (0.0, 1.0))
1818

1919
# Test all exported LowOrderRK solvers for allocation-free behavior
20-
low_order_solvers = [Euler(), SplitEuler(), Heun(), Ralston(), Midpoint(), RK4(),
20+
low_order_solvers = [Euler(), Heun(), Ralston(), Midpoint(), RK4(),
2121
BS3(), OwrenZen3(), OwrenZen4(), OwrenZen5(), BS5(),
2222
DP5(), Anas5(), RKO65(), FRK65(), RKM(), MSRK5(), MSRK6(),
2323
PSRK4p7q6(), PSRK3p5q4(), PSRK3p6q5(), Stepanov5(), SIR54(),

lib/OrdinaryDiffEqLowOrderRK/test/jet.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ using Test
1919
prob = ODEProblem(simple_system!, [1.0, 1.0], (0.0, 1.0))
2020

2121
# Test all exported LowOrderRK solvers
22-
low_order_solvers = [Euler(), SplitEuler(), Heun(), Ralston(), Midpoint(), RK4(),
22+
low_order_solvers = [Euler(), Heun(), Ralston(), Midpoint(), RK4(),
2323
BS3(), OwrenZen3(), OwrenZen4(), OwrenZen5(), BS5(),
2424
DP5(), Anas5(), RKO65(), FRK65(), RKM(), MSRK5(), MSRK6(),
2525
PSRK4p7q6(), PSRK3p5q4(), PSRK3p6q5(), Stepanov5(), SIR54(),
@@ -29,7 +29,7 @@ using Test
2929
@testset "$(typeof(solver)) type stability" begin
3030
try
3131
# Some solvers need fixed timestep
32-
if solver isa Euler || solver isa SplitEuler || solver isa Midpoint || solver isa Heun
32+
if solver isa Euler || solver isa Midpoint || solver isa Heun
3333
@test_opt broken=true init(prob, solver, dt=0.1, save_everystep=false, adaptive=false)
3434
integrator = init(prob, solver, dt=0.1, save_everystep=false, adaptive=false)
3535
else

0 commit comments

Comments
 (0)