Skip to content

Commit cb23cdc

Browse files
Merge pull request #602 from SebastianM-C/ensemble_plot
update ensemble indexing in the plot recipe
2 parents df27cdc + b01a10d commit cb23cdc

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/ensemble/ensemble_analysis.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ timestep_mean(sim, ::Colon) = timeseries_steps_mean(sim)
2828
function timestep_median(sim, i)
2929
arr = componentwise_vectors_timestep(sim, i)
3030
if typeof(first(arr)) <: AbstractArray
31-
return reshape([median(x) for x in arr], size(sim.u[1][i])...)
31+
return reshape([median(x) for x in arr], size(sim.u[1].u[i])...)
3232
else
3333
return median(arr)
3434
end
@@ -37,7 +37,7 @@ timestep_median(sim, ::Colon) = timeseries_steps_median(sim)
3737
function timestep_quantile(sim, q, i)
3838
arr = componentwise_vectors_timestep(sim, i)
3939
if typeof(first(arr)) <: AbstractArray
40-
return reshape([quantile(x, q) for x in arr], size(sim.u[1][i])...)
40+
return reshape([quantile(x, q) for x in arr], size(sim.u[1].u[i])...)
4141
else
4242
return quantile(arr, q)
4343
end
@@ -97,15 +97,15 @@ timepoint_mean(sim, t) = componentwise_mean(get_timepoint(sim, t))
9797
function timepoint_median(sim, t)
9898
arr = componentwise_vectors_timepoint(sim, t)
9999
if typeof(first(arr)) <: AbstractArray
100-
return reshape([median(x) for x in arr], size(sim.u[1][1])...)
100+
return reshape([median(x) for x in arr], size(sim.u[1].u[1])...)
101101
else
102102
return median(arr)
103103
end
104104
end
105105
function timepoint_quantile(sim, q, t)
106106
arr = componentwise_vectors_timepoint(sim, t)
107107
if typeof(first(arr)) <: AbstractArray
108-
return reshape([quantile(x, q) for x in arr], size(sim.u[1][1])...)
108+
return reshape([quantile(x, q) for x in arr], size(sim.u[1].u[1])...)
109109
else
110110
return quantile(arr, q)
111111
end
@@ -122,7 +122,7 @@ function timepoint_weighted_meancov(sim, W, t1, t2)
122122
end
123123

124124
function SciMLBase.EnsembleSummary(sim::SciMLBase.AbstractEnsembleSolution{T, N},
125-
t = sim.u[1].t; quantiles = [0.05, 0.95]) where {T, N}
125+
t = sim.u[1].t; quantiles = [0.05, 0.95]) where {T, N}
126126
if sim.u[1] isa SciMLSolution
127127
m, v = timeseries_point_meanvar(sim, t)
128128
med = timeseries_point_median(sim, t)

src/ensemble/ensemble_solutions.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,14 @@ end
143143
nothing,
144144
trajectories = eachindex(sim))
145145
for i in trajectories
146-
size(sim[i].u, 1) == 0 && continue
146+
size(sim.u[i].u, 1) == 0 && continue
147147
@series begin
148148
legend := false
149149
xlims --> (-Inf, Inf)
150150
ylims --> (-Inf, Inf)
151151
zlims --> (-Inf, Inf)
152152
marker_z --> zcolors[i]
153-
sim[i]
153+
sim.u[i]
154154
end
155155
end
156156
end
@@ -170,12 +170,12 @@ end
170170
1.96 for i in 1:length(sim.v)]))
171171
ci_high = ci_low
172172
else
173-
ci_low = [[sqrt(sim.v[i] / length(sim.num_monte)) .* 1.96
173+
ci_low = [[sqrt(sim.v.u[i] / length(sim.num_monte)) .* 1.96
174174
for i in 1:length(sim.v)]]
175175
ci_high = ci_low
176176
end
177177
elseif ci_type == :quantile
178-
if sim.med[1] isa AbstractArray
178+
if sim.med.u[1] isa AbstractArray
179179
u = vecarr_to_vectors(sim.med)
180180
else
181181
u = [sim.med.u]

0 commit comments

Comments
 (0)