From 71c6527c9174115174af104c2483ff2588cdc934 Mon Sep 17 00:00:00 2001 From: Pepijn de Vos Date: Mon, 2 Oct 2023 14:08:04 +0200 Subject: [PATCH] handle different stats types, including nothing --- src/ensemble/basic_ensemble_solve.jl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/ensemble/basic_ensemble_solve.jl b/src/ensemble/basic_ensemble_solve.jl index a6da51f81..8db2f5065 100644 --- a/src/ensemble/basic_ensemble_solve.jl +++ b/src/ensemble/basic_ensemble_solve.jl @@ -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,