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

[WIP] Fix Ensemble indexing when output_func is used #607

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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: 7 additions & 3 deletions src/ensemble/ensemble_analysis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
using SciMLBase, Statistics, RecursiveArrayTools, StaticArraysCore

# Getters
get_timestep(sim, i) = (sol.u[i] for sol in sim)
function get_timestep(sim::EnsembleSolution{T, N, S},

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

View check run for this annotation

Codecov / codecov/patch

src/ensemble/ensemble_analysis.jl#L6

Added line #L6 was not covered by tests
i) where {T, N, S <: AbstractVectorOfArray}
(sol.u[i] for sol in sim)

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

View check run for this annotation

Codecov / codecov/patch

src/ensemble/ensemble_analysis.jl#L8

Added line #L8 was not covered by tests
end
get_timestep(sim, i) = (sol[i] for sol in sim)

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

View check run for this annotation

Codecov / codecov/patch

src/ensemble/ensemble_analysis.jl#L10

Added line #L10 was not covered by tests
get_timepoint(sim, t) = (sol(t) for sol in sim)
function componentwise_vectors_timestep(sim, i)
arr = [get_timestep(sim, i)...]
Expand All @@ -28,7 +32,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].u[i])...)
return reshape([median(x) for x in arr], size(sim[1, i])...)

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

View check run for this annotation

Codecov / codecov/patch

src/ensemble/ensemble_analysis.jl#L35

Added line #L35 was not covered by tests
else
return median(arr)
end
Expand All @@ -37,7 +41,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].u[i])...)
return reshape([quantile(x, q) for x in arr], size(sim[1, i])...)

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

View check run for this annotation

Codecov / codecov/patch

src/ensemble/ensemble_analysis.jl#L44

Added line #L44 was not covered by tests
else
return quantile(arr, q)
end
Expand Down
Loading