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

Ensemble depwarn fixes #586

Merged
merged 1 commit into from
Jan 4, 2024
Merged
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
34 changes: 17 additions & 17 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[1][i])...)
return reshape([median(x) for x in arr], size(sim.u[1][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[1][i])...)
return reshape([quantile(x, q) for x in arr], size(sim.u[1][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 All @@ -61,51 +61,51 @@
end

function timeseries_steps_mean(sim)
DiffEqArray([timestep_mean(sim, i) for i in 1:length(sim[1])], sim[1].t)
DiffEqArray([timestep_mean(sim, i) for i in 1:length(sim.u[1])], sim.u[1].t)

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

View check run for this annotation

Codecov / codecov/patch

src/ensemble/ensemble_analysis.jl#L64

Added line #L64 was not covered by tests
end
function timeseries_steps_median(sim)
DiffEqArray([timestep_median(sim, i) for i in 1:length(sim[1])], sim[1].t)
DiffEqArray([timestep_median(sim, i) for i in 1:length(sim.u[1])], sim.u[1].t)

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

View check run for this annotation

Codecov / codecov/patch

src/ensemble/ensemble_analysis.jl#L67

Added line #L67 was not covered by tests
end
function timeseries_steps_quantile(sim, q)
DiffEqArray([timestep_quantile(sim, q, i) for i in 1:length(sim[1])], sim[1].t)
DiffEqArray([timestep_quantile(sim, q, i) for i in 1:length(sim.u[1])], sim.u[1].t)

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

View check run for this annotation

Codecov / codecov/patch

src/ensemble/ensemble_analysis.jl#L70

Added line #L70 was not covered by tests
end
function timeseries_steps_meanvar(sim)
m, v = timestep_meanvar(sim, 1)
means = [m]
vars = [v]
for i in 2:length(sim[1])
for i in 2:length(sim.u[1])

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

View check run for this annotation

Codecov / codecov/patch

src/ensemble/ensemble_analysis.jl#L76

Added line #L76 was not covered by tests
m, v = timestep_meanvar(sim, i)
push!(means, m)
push!(vars, v)
end
DiffEqArray(means, sim[1].t), DiffEqArray(vars, sim[1].t)
DiffEqArray(means, sim.u[1].t), DiffEqArray(vars, sim.u[1].t)

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

View check run for this annotation

Codecov / codecov/patch

src/ensemble/ensemble_analysis.jl#L81

Added line #L81 was not covered by tests
end
function timeseries_steps_meancov(sim)
reshape([timestep_meancov(sim, i, j) for i in 1:length(sim[1])
for j in 1:length(sim[1])], length(sim[1]), length(sim[1]))
reshape([timestep_meancov(sim, i, j) for i in 1:length(sim.u[1])

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

View check run for this annotation

Codecov / codecov/patch

src/ensemble/ensemble_analysis.jl#L84

Added line #L84 was not covered by tests
for j in 1:length(sim.u[1])], length(sim.u[1]), length(sim.u[1]))
end
function timeseries_steps_meancor(sim)
reshape([timestep_meancor(sim, i, j) for i in 1:length(sim[1])
for j in 1:length(sim[1])], length(sim[1]), length(sim[1]))
reshape([timestep_meancor(sim, i, j) for i in 1:length(sim.u[1])

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

View check run for this annotation

Codecov / codecov/patch

src/ensemble/ensemble_analysis.jl#L88

Added line #L88 was not covered by tests
for j in 1:length(sim.u[1])], length(sim.u[1]), length(sim.u[1]))
end
function timeseries_steps_weighted_meancov(sim, W)
reshape([timestep_meancov(sim, W, i, j) for i in 1:length(sim[1])
for j in 1:length(sim[1])], length(sim[1]), length(sim[1]))
reshape([timestep_meancov(sim, W, i, j) for i in 1:length(sim.u[1])

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

View check run for this annotation

Codecov / codecov/patch

src/ensemble/ensemble_analysis.jl#L92

Added line #L92 was not covered by tests
for j in 1:length(sim.u[1])], length(sim.u[1]), length(sim.u[1]))
end

timepoint_mean(sim, t) = componentwise_mean(get_timepoint(sim, t))
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[1][1])...)
return reshape([median(x) for x in arr], size(sim.u[1][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[1][1])...)
return reshape([quantile(x, q) for x in arr], size(sim.u[1][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,8 +122,8 @@
end

function SciMLBase.EnsembleSummary(sim::SciMLBase.AbstractEnsembleSolution{T, N},
t = sim[1].t; quantiles = [0.05, 0.95]) where {T, N}
if sim[1] isa SciMLSolution
t = sim.u[1].t; quantiles = [0.05, 0.95]) where {T, N}
if sim.u[1] isa SciMLSolution

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

View check run for this annotation

Codecov / codecov/patch

src/ensemble/ensemble_analysis.jl#L126

Added line #L126 was not covered by tests
m, v = timeseries_point_meanvar(sim, t)
med = timeseries_point_median(sim, t)
qlow = timeseries_point_quantile(sim, quantiles[1], t)
Expand Down
Loading