diff --git a/src/integrator_utils.jl b/src/integrator_utils.jl index c018bb9..c3f78b7 100644 --- a/src/integrator_utils.jl +++ b/src/integrator_utils.jl @@ -103,11 +103,11 @@ function build_solution_array(integrator::DDEIntegrator) n = integrator.opts.save_everystep ? length(integrator.sol.t) : 2 n += saveat_length integrator.opts.save_start || (n -= 1) - t = Vector{typeof(integrator.t)}(n) + t = Vector{typeof(integrator.t)}(undef,n) if typeof(integrator.opts.save_idxs) <: Nothing - u = Vector{typeof(integrator.u)}(n) + u = Vector{typeof(integrator.u)}(undef,n) else - u = Vector{typeof(integrator.u[integrator.opts.save_idxs])}(n) + u = Vector{typeof(integrator.u[integrator.opts.save_idxs])}(undef,n) end # output initial time point if desired diff --git a/test/save_idxs.jl b/test/save_idxs.jl index 4af662a..e8ad1bf 100644 --- a/test/save_idxs.jl +++ b/test/save_idxs.jl @@ -52,8 +52,8 @@ @test sol.t == sol2.t && sol.u == sol2.u ## interpolation - @test sol(25:100, idxs=2) == sol2(25:100, idxs=2) - @test sol(25:100, idxs=[2]) == sol2(25:100, idxs=[2]) + @test sol(25:100, idxs=2) ≈ sol2(25:100, idxs=2) + @test sol(25:100, idxs=[2]) ≈ sol2(25:100, idxs=[2]) end end @@ -76,8 +76,8 @@ ## interpolation of solution equals second component of ## interpolation of complete solution - @test sol(25:100, idxs=2) == sol2(25:100, idxs=1) - @test sol(25:100, idxs=[2]) == sol2(25:100, idxs=[1]) + @test sol(25:100, idxs=2) ≈ sol2(25:100, idxs=1) + @test sol(25:100, idxs=[2]) ≈ sol2(25:100, idxs=[1]) end # scalar index @@ -93,7 +93,7 @@ @test length(dde_int2.sol.u[1]) == 2 ## solution equals second component of complete solution - @test sol.t == sol2.t && sol[2, :] == sol2.u + @test sol.t ≈ sol2.t && sol[2, :] ≈ sol2.u ## interpolation of solution equals second component of ## interpolation of complete solution