Skip to content

Commit

Permalink
handle different stats types, including nothing
Browse files Browse the repository at this point in the history
  • Loading branch information
Pepijn de Vos committed Oct 9, 2023
1 parent 947695f commit 71c6527
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/ensemble/basic_ensemble_solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,17 @@ $(TYPEDEF)
struct EnsembleSerial <: BasicEnsembleAlgorithm end

function merge_stats(us)
mapreduce(x -> x.stats, merge, us)
st = Iterators.filter(!isnothing, (x.stats for x in us))
try
return reduce(merge, st)
catch e
if isa(e, MethodError)
# there were no stats or they didn't have a merge method
return nothing
else
rethrow(e)
end
end
end

function __solve(prob::AbstractEnsembleProblem,
Expand Down

0 comments on commit 71c6527

Please sign in to comment.