Skip to content

Commit 3380d65

Browse files
Merge pull request #45 from andreasnoack/an/nomap
Change map for a for loop
2 parents 3150439 + b3ea422 commit 3380d65

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/ensemble/basic_ensemble_solve.jl

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,16 @@ function solve_batch(prob,alg,ensemblealg::EnsembleDistributed,II,pmap_batch_siz
182182
tighten_container_eltype(batch_data)
183183
end
184184

185-
function solve_batch(prob,alg,::EnsembleSerial,II,pmap_batch_size;kwargs...)
186-
batch_data = map(II) do i
187-
batch_func(i,prob,alg;kwargs...)
185+
function solve_batch(prob, alg, ::EnsembleSerial, II, pmap_batch_size; kwargs...)
186+
if isempty(II)
187+
throw(ArgumentError("number of trajectories must be positive"))
188188
end
189-
tighten_container_eltype(batch_data)
189+
batch_data = [batch_func(first(II), prob, alg; kwargs...)]
190+
sizehint!(batch_data,length(II))
191+
for i in 2:length(II)
192+
@inbounds push!(batch_data, batch_func(II[i], prob, alg; kwargs...))
193+
end
194+
return tighten_container_eltype(batch_data)
190195
end
191196

192197
function solve_batch(prob,alg,ensemblealg::EnsembleThreads,II,pmap_batch_size;kwargs...)

0 commit comments

Comments
 (0)