Skip to content

Commit

Permalink
add plot to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
odunbar committed Feb 28, 2023
1 parent 54346ca commit 96009f8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ julia = "1.5"
[extras]
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"

[targets]
test = ["StableRNGs", "Test"]
test = ["StableRNGs", "Test", "Plots"]
23 changes: 16 additions & 7 deletions test/ParameterDistributions/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ using EnsembleKalmanProcesses.ParameterDistributions

@testset "ParameterDistribution: over function spaces" begin

# create a Matern GRF with GaussianRandomFields.jl
# create a 1D Matern GRF with GaussianRandomFields.jl
dim = 1
smoothness = 3.0
corr_length = 1.0
smoothness = 1.0
corr_length = 0.1
dofs = 10
pts = repeat([collect(0:0.05:1)], dim)
pts = collect(0:0.05:1)
grf = GRF.GaussianRandomField(
GRF.CovarianceFunction(dim, GRF.Matern(corr_length, smoothness)),
GRF.KarhunenLoeve(dofs),
pts..., # i.e. collect(..),collect(..),collect(..) in 3D
pts,
)

#our wrapper:
Expand All @@ -56,14 +56,14 @@ using EnsembleKalmanProcesses.ParameterDistributions
@test mean(d) == grf.mean
@test eval_pts(d) == grf.pts
@test input_dims(d) == dim
@test ndims(d) == prod(length(pts[i]) for i in 1:dim)
@test ndims(d) == length(pts)
@test ndofs(d) == dofs

n_pts = ndims(d)

#sampling
s = 9211
n_sample = 5
n_sample = 6
tol = 10 * eps()
Random.seed!(s)
xi1 = rand(Normal(0, 1), (dofs, 1))
Expand Down Expand Up @@ -92,6 +92,15 @@ using EnsembleKalmanProcesses.ParameterDistributions
@test sample(copy(rng1), d) sample3 atol = tol
@test sample(copy(rng1), d, n_sample) sample4 atol = tol

if TEST_PLOT_OUTPUT
# plot the samples
plot(
pts,
sample(copy(rng1), d, n_sample),
)
savefig("GRF_samples.png")

end
end


Expand Down

0 comments on commit 96009f8

Please sign in to comment.