diff --git a/src/ensemble/basic_ensemble_solve.jl b/src/ensemble/basic_ensemble_solve.jl index 7d2618978..e4dd54fac 100644 --- a/src/ensemble/basic_ensemble_solve.jl +++ b/src/ensemble/basic_ensemble_solve.jl @@ -24,7 +24,8 @@ $(TYPEDEF) struct EnsembleSerial <: BasicEnsembleAlgorithm end function merge_stats(us) - st = Iterators.filter(!isnothing, (x.stats for x in us)) + st = Iterators.filter(!isnothing, (hasproperty(x, :stats) ? x.stats : nothing for x in us)) + isempty(st) && return nothing reduce(merge, st) end @@ -94,7 +95,7 @@ function __solve(prob::AbstractEnsembleProblem, end end _u = tighten_container_eltype(u) - stats = prob.reduction === DEFAULT_REDUCTION ? merge_stats(_u) : nothing + stats = merge_stats(_u) return EnsembleSolution(_u, elapsed_time, converged, stats) end diff --git a/src/ensemble/ensemble_solutions.jl b/src/ensemble/ensemble_solutions.jl index db3213289..145a2f37a 100644 --- a/src/ensemble/ensemble_solutions.jl +++ b/src/ensemble/ensemble_solutions.jl @@ -31,7 +31,7 @@ struct EnsembleSolution{T, N, S, U} <: AbstractEnsembleSolution{T, N, S} converged::Bool stats::U end -function EnsembleSolution(sim, dims::NTuple{N}, elapsedTime, converged, stats=nothing) where {N} +function EnsembleSolution(sim, dims::NTuple{N}, elapsedTime, converged, stats) where {N} EnsembleSolution{eltype(eltype(sim)), N, typeof(sim), typeof(stats)}(sim, elapsedTime, converged, stats) end function EnsembleSolution(sim, elapsedTime, converged, stats=nothing)