Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update ensemble indexing in the plot recipe #602

Merged
merged 1 commit into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/ensemble/ensemble_analysis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
function timestep_median(sim, i)
arr = componentwise_vectors_timestep(sim, i)
if typeof(first(arr)) <: AbstractArray
return reshape([median(x) for x in arr], size(sim.u[1][i])...)
return reshape([median(x) for x in arr], size(sim.u[1].u[i])...)

Check warning on line 31 in src/ensemble/ensemble_analysis.jl

View check run for this annotation

Codecov / codecov/patch

src/ensemble/ensemble_analysis.jl#L31

Added line #L31 was not covered by tests
else
return median(arr)
end
Expand All @@ -37,7 +37,7 @@
function timestep_quantile(sim, q, i)
arr = componentwise_vectors_timestep(sim, i)
if typeof(first(arr)) <: AbstractArray
return reshape([quantile(x, q) for x in arr], size(sim.u[1][i])...)
return reshape([quantile(x, q) for x in arr], size(sim.u[1].u[i])...)

Check warning on line 40 in src/ensemble/ensemble_analysis.jl

View check run for this annotation

Codecov / codecov/patch

src/ensemble/ensemble_analysis.jl#L40

Added line #L40 was not covered by tests
else
return quantile(arr, q)
end
Expand Down Expand Up @@ -97,15 +97,15 @@
function timepoint_median(sim, t)
arr = componentwise_vectors_timepoint(sim, t)
if typeof(first(arr)) <: AbstractArray
return reshape([median(x) for x in arr], size(sim.u[1][1])...)
return reshape([median(x) for x in arr], size(sim.u[1].u[1])...)

Check warning on line 100 in src/ensemble/ensemble_analysis.jl

View check run for this annotation

Codecov / codecov/patch

src/ensemble/ensemble_analysis.jl#L100

Added line #L100 was not covered by tests
else
return median(arr)
end
end
function timepoint_quantile(sim, q, t)
arr = componentwise_vectors_timepoint(sim, t)
if typeof(first(arr)) <: AbstractArray
return reshape([quantile(x, q) for x in arr], size(sim.u[1][1])...)
return reshape([quantile(x, q) for x in arr], size(sim.u[1].u[1])...)

Check warning on line 108 in src/ensemble/ensemble_analysis.jl

View check run for this annotation

Codecov / codecov/patch

src/ensemble/ensemble_analysis.jl#L108

Added line #L108 was not covered by tests
else
return quantile(arr, q)
end
Expand All @@ -122,7 +122,7 @@
end

function SciMLBase.EnsembleSummary(sim::SciMLBase.AbstractEnsembleSolution{T, N},
t = sim.u[1].t; quantiles = [0.05, 0.95]) where {T, N}
t = sim.u[1].t; quantiles = [0.05, 0.95]) where {T, N}
if sim.u[1] isa SciMLSolution
m, v = timeseries_point_meanvar(sim, t)
med = timeseries_point_median(sim, t)
Expand Down
8 changes: 4 additions & 4 deletions src/ensemble/ensemble_solutions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,14 @@
nothing,
trajectories = eachindex(sim))
for i in trajectories
size(sim[i].u, 1) == 0 && continue
size(sim.u[i].u, 1) == 0 && continue

Check warning on line 146 in src/ensemble/ensemble_solutions.jl

View check run for this annotation

Codecov / codecov/patch

src/ensemble/ensemble_solutions.jl#L146

Added line #L146 was not covered by tests
@series begin
legend := false
xlims --> (-Inf, Inf)
ylims --> (-Inf, Inf)
zlims --> (-Inf, Inf)
marker_z --> zcolors[i]
sim[i]
sim.u[i]

Check warning on line 153 in src/ensemble/ensemble_solutions.jl

View check run for this annotation

Codecov / codecov/patch

src/ensemble/ensemble_solutions.jl#L153

Added line #L153 was not covered by tests
end
end
end
Expand All @@ -170,12 +170,12 @@
1.96 for i in 1:length(sim.v)]))
ci_high = ci_low
else
ci_low = [[sqrt(sim.v[i] / length(sim.num_monte)) .* 1.96
ci_low = [[sqrt(sim.v.u[i] / length(sim.num_monte)) .* 1.96

Check warning on line 173 in src/ensemble/ensemble_solutions.jl

View check run for this annotation

Codecov / codecov/patch

src/ensemble/ensemble_solutions.jl#L173

Added line #L173 was not covered by tests
for i in 1:length(sim.v)]]
ci_high = ci_low
end
elseif ci_type == :quantile
if sim.med[1] isa AbstractArray
if sim.med.u[1] isa AbstractArray

Check warning on line 178 in src/ensemble/ensemble_solutions.jl

View check run for this annotation

Codecov / codecov/patch

src/ensemble/ensemble_solutions.jl#L178

Added line #L178 was not covered by tests
u = vecarr_to_vectors(sim.med)
else
u = [sim.med.u]
Expand Down
Loading