From 54355dec7a2481637fa15361215ca164517a4560 Mon Sep 17 00:00:00 2001 From: ST John Date: Tue, 24 Aug 2021 10:14:58 +0300 Subject: [PATCH 01/24] fix error message --- src/util/plotting.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/plotting.jl b/src/util/plotting.jl index b04d2e20..4707c4be 100644 --- a/src/util/plotting.jl +++ b/src/util/plotting.jl @@ -4,7 +4,7 @@ length(x) == length(gp.x) || throw(DimensionMismatch("length of `x` and `gp.x` has to be equal")) scale::Float64 = pop!(plotattributes, :ribbon_scale, 1.0) - scale > 0.0 || error("`bandwidth` keyword argument must be non-negative") + scale >= 0.0 || error("`ribbon_scale` keyword argument must be non-negative") # compute marginals μ, σ2 = mean_and_var(gp) From 8fccaaffb7787542cbf13180cfa69122b90b6258 Mon Sep 17 00:00:00 2001 From: ST John Date: Tue, 24 Aug 2021 10:15:28 +0300 Subject: [PATCH 02/24] pop! for custom-defined kwarg --- src/util/plotting.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/plotting.jl b/src/util/plotting.jl index 4707c4be..e7f71b9f 100644 --- a/src/util/plotting.jl +++ b/src/util/plotting.jl @@ -115,7 +115,7 @@ SamplePlot((f,)::Tuple{<:FiniteGP}) = SamplePlot((f.x, f)) SamplePlot((x, gp)::Tuple{<:AbstractVector,<:AbstractGP}) = SamplePlot((gp(x, 1e-9),)) @recipe function f(sp::SamplePlot) - nsamples::Int = get(plotattributes, :samples, 1) + nsamples::Int = pop!(plotattributes, :samples, 1) samples = rand(sp.f, nsamples) # Set default attributes From 2f1204b23f46325fa6044f1c337b1efa41b9a08b Mon Sep 17 00:00:00 2001 From: ST John Date: Tue, 24 Aug 2021 10:16:52 +0300 Subject: [PATCH 03/24] only single label for multiple samples by default --- src/util/plotting.jl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/util/plotting.jl b/src/util/plotting.jl index e7f71b9f..66afd54a 100644 --- a/src/util/plotting.jl +++ b/src/util/plotting.jl @@ -118,6 +118,12 @@ SamplePlot((x, gp)::Tuple{<:AbstractVector,<:AbstractGP}) = SamplePlot((gp(x, 1e nsamples::Int = pop!(plotattributes, :samples, 1) samples = rand(sp.f, nsamples) + col_label = pop!(plotattributes, :label, "") + if col_label isa String + # blank labels for all but first column, e.g. ["samples" "" "" ...] + col_label = [col_label fill("", nsamples - 1)...] + end + # Set default attributes seriestype --> :line linealpha --> 0.2 @@ -126,7 +132,7 @@ SamplePlot((x, gp)::Tuple{<:AbstractVector,<:AbstractGP}) = SamplePlot((gp(x, 1e markersize --> 0.5 markeralpha --> 0.3 seriescolor --> "red" - label --> "" + label := col_label return sp.x, samples end From 3f47368caf9e25fffc5e061ededd213945c53400 Mon Sep 17 00:00:00 2001 From: ST John Date: Tue, 24 Aug 2021 10:17:06 +0300 Subject: [PATCH 04/24] remove markers --- src/util/plotting.jl | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/util/plotting.jl b/src/util/plotting.jl index 66afd54a..53c61020 100644 --- a/src/util/plotting.jl +++ b/src/util/plotting.jl @@ -127,10 +127,6 @@ SamplePlot((x, gp)::Tuple{<:AbstractVector,<:AbstractGP}) = SamplePlot((gp(x, 1e # Set default attributes seriestype --> :line linealpha --> 0.2 - markershape --> :circle - markerstrokewidth --> 0.0 - markersize --> 0.5 - markeralpha --> 0.3 seriescolor --> "red" label := col_label From 98ec20bf35b393b7edf8977e16ab1cf8c7a0736b Mon Sep 17 00:00:00 2001 From: ST John Date: Tue, 24 Aug 2021 10:17:38 +0300 Subject: [PATCH 05/24] bump version --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index fe116e2e..583bd96e 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "AbstractGPs" uuid = "99985d1d-32ba-4be9-9821-2ec096f28918" authors = ["JuliaGaussianProcesses Team"] -version = "0.4.0" +version = "0.4.1" [deps] ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" From 0aff474417d17dc9873f88b981e7f8f0b3b74ec2 Mon Sep 17 00:00:00 2001 From: ST John Date: Tue, 24 Aug 2021 11:25:07 +0300 Subject: [PATCH 06/24] update docstring example --- src/util/plotting.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/util/plotting.jl b/src/util/plotting.jl index 53c61020..61d2c23c 100644 --- a/src/util/plotting.jl +++ b/src/util/plotting.jl @@ -88,10 +88,10 @@ Plot samples from the projection `f` of a Gaussian process versus `x`. using Plots gp = GP(SqExponentialKernel()) -sampleplot(gp(rand(5)); samples=10, markersize=5) +sampleplot(gp(rand(5)); samples=10, linealpha=1.0) ``` -The given example plots 10 samples from the projection of the GP `gp`. The `markersize` is modified -from default of 0.5 to 5. +The given example plots 10 samples from the projection of the GP `gp`. +The `linealpha` is modified from default of 0.2 to 1. --- sampleplot(x::AbstractVector, gp::AbstractGP; samples=1, kwargs...) From 71eeb1037ebc70a6106c405502689f5b415ae719 Mon Sep 17 00:00:00 2001 From: ST John Date: Tue, 24 Aug 2021 11:25:18 +0300 Subject: [PATCH 07/24] add explanation of `label` handling to docstring --- src/util/plotting.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/util/plotting.jl b/src/util/plotting.jl index 61d2c23c..87ff78c3 100644 --- a/src/util/plotting.jl +++ b/src/util/plotting.jl @@ -82,6 +82,8 @@ Plot samples from the projection `f` of a Gaussian process versus `x`. Make sure to load [Plots.jl](https://github.com/JuliaPlots/Plots.jl) before you use this function. +This recipe handles the `label` argument in a custom way: when plotting multiple samples and `label` is a string, only a single element is added to the legend. To give each sample the same legend entry, pass an explicit column matrix, e.g. `label=fill("sample", (1, samples))`. + # Example ```julia From cbeb5a89036e2ffe4ad0095173fd9805c9d7f815 Mon Sep 17 00:00:00 2001 From: ST John Date: Tue, 24 Aug 2021 11:47:47 +0300 Subject: [PATCH 08/24] demonstrate `label` handling in regression-1d example --- examples/regression-1d/script.jl | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/examples/regression-1d/script.jl b/examples/regression-1d/script.jl index fdd33b4c..12e5e405 100644 --- a/examples/regression-1d/script.jl +++ b/examples/regression-1d/script.jl @@ -212,19 +212,18 @@ mean(logpdf(gp_posterior(x_train, y_train, p)(x_test), y_test) for p in samples) # We sample 5 functions from each posterior GP given by the final 100 samples of kernel # parameters. -plt = scatter( - x_train, - y_train; - xlim=(0, 1), - xlabel="x", - ylabel="y", - title="posterior (AdvancedHMC)", - label="Train Data", -) -for p in samples[(end - 100):end] - sampleplot!(plt, 0:0.02:1, gp_posterior(x_train, y_train, p); samples=5) +plt = plot(; xlim=(0, 1), xlabel="x", ylabel="y", title="posterior (AdvancedHMC)") +for (i, p) in enumerate(samples[(end - 100):end]) + sampleplot!( + plt, + 0:0.02:1, + gp_posterior(x_train, y_train, p); + samples=5, + label=(i == 1 ? "samples" : nothing), + ) end -scatter!(plt, x_test, y_test; label="Test Data") +scatter!(plt, x_train, y_train; label="Train Data", markercolor=1) +scatter!(plt, x_test, y_test; label="Test Data", markercolor=2) plt # #### DynamicHMC From e4ddf18e84dbd50f71bbda6a9dbd30759c76477a Mon Sep 17 00:00:00 2001 From: ST John Date: Tue, 24 Aug 2021 12:56:31 +0300 Subject: [PATCH 09/24] formatting --- src/util/plotting.jl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/util/plotting.jl b/src/util/plotting.jl index 87ff78c3..ad77eb21 100644 --- a/src/util/plotting.jl +++ b/src/util/plotting.jl @@ -82,7 +82,10 @@ Plot samples from the projection `f` of a Gaussian process versus `x`. Make sure to load [Plots.jl](https://github.com/JuliaPlots/Plots.jl) before you use this function. -This recipe handles the `label` argument in a custom way: when plotting multiple samples and `label` is a string, only a single element is added to the legend. To give each sample the same legend entry, pass an explicit column matrix, e.g. `label=fill("sample", (1, samples))`. +This recipe handles the `label` argument in a custom way: when plotting +multiple samples and `label` is a string, only a single element is added to the +legend. To give each sample the same legend entry, pass an explicit column +matrix, e.g. `label=fill("sample", (1, samples))`. # Example From 58a8e710d6115d8d980c306653dc21c31d6240e2 Mon Sep 17 00:00:00 2001 From: ST John Date: Tue, 24 Aug 2021 14:24:31 +0300 Subject: [PATCH 10/24] treat multiple samples as single series --- src/util/plotting.jl | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/util/plotting.jl b/src/util/plotting.jl index ad77eb21..0772eb9f 100644 --- a/src/util/plotting.jl +++ b/src/util/plotting.jl @@ -82,10 +82,8 @@ Plot samples from the projection `f` of a Gaussian process versus `x`. Make sure to load [Plots.jl](https://github.com/JuliaPlots/Plots.jl) before you use this function. -This recipe handles the `label` argument in a custom way: when plotting -multiple samples and `label` is a string, only a single element is added to the -legend. To give each sample the same legend entry, pass an explicit column -matrix, e.g. `label=fill("sample", (1, samples))`. +When plotting multiple samples, these are treated as a _single_ series (i.e., +only a single entry will be added to the legend when providing a `label`). # Example @@ -123,17 +121,13 @@ SamplePlot((x, gp)::Tuple{<:AbstractVector,<:AbstractGP}) = SamplePlot((gp(x, 1e nsamples::Int = pop!(plotattributes, :samples, 1) samples = rand(sp.f, nsamples) - col_label = pop!(plotattributes, :label, "") - if col_label isa String - # blank labels for all but first column, e.g. ["samples" "" "" ...] - col_label = [col_label fill("", nsamples - 1)...] - end + flat_x = vcat(Iterators.flatten(zip(Iterators.repeated(sp.x), fill(NaN, nsamples)))...) + flat_f = vcat(Iterators.flatten(zip(eachcol(samples), Iterators.repeated([NaN])))...) # Set default attributes seriestype --> :line linealpha --> 0.2 seriescolor --> "red" - label := col_label - return sp.x, samples + return flat_x, flat_f end From c75de4fdf601d047a15e4affec25b8485446c9fa Mon Sep 17 00:00:00 2001 From: ST John Date: Tue, 24 Aug 2021 14:48:08 +0300 Subject: [PATCH 11/24] do not set seriestype --- src/util/plotting.jl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/util/plotting.jl b/src/util/plotting.jl index 0772eb9f..8a6fbea1 100644 --- a/src/util/plotting.jl +++ b/src/util/plotting.jl @@ -121,13 +121,14 @@ SamplePlot((x, gp)::Tuple{<:AbstractVector,<:AbstractGP}) = SamplePlot((gp(x, 1e nsamples::Int = pop!(plotattributes, :samples, 1) samples = rand(sp.f, nsamples) - flat_x = vcat(Iterators.flatten(zip(Iterators.repeated(sp.x), fill(NaN, nsamples)))...) - flat_f = vcat(Iterators.flatten(zip(eachcol(samples), Iterators.repeated([NaN])))...) + flat_x = repeat(vcat(sp.x, NaN), nsamples) + flat_f = vcat(samples, fill(NaN, 1, nsamples)) |> vec # Set default attributes - seriestype --> :line + #seriestype --> :line linealpha --> 0.2 seriescolor --> "red" + label --> "" return flat_x, flat_f end From aeab678316259afb0ab3ca218b8dd4e0d4e425e5 Mon Sep 17 00:00:00 2001 From: st-- Date: Tue, 24 Aug 2021 14:54:35 +0300 Subject: [PATCH 12/24] Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- src/util/plotting.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/plotting.jl b/src/util/plotting.jl index 8a6fbea1..4bcc8588 100644 --- a/src/util/plotting.jl +++ b/src/util/plotting.jl @@ -122,7 +122,7 @@ SamplePlot((x, gp)::Tuple{<:AbstractVector,<:AbstractGP}) = SamplePlot((gp(x, 1e samples = rand(sp.f, nsamples) flat_x = repeat(vcat(sp.x, NaN), nsamples) - flat_f = vcat(samples, fill(NaN, 1, nsamples)) |> vec + flat_f = vec(vcat(samples, fill(NaN, 1, nsamples))) # Set default attributes #seriestype --> :line From f5a77725c9a8dd6710359987bd5fe35bc3e2b2e3 Mon Sep 17 00:00:00 2001 From: ST John Date: Tue, 24 Aug 2021 15:12:24 +0300 Subject: [PATCH 13/24] adjust tests for new one-series-for-all-samples --- test/deprecations.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/deprecations.jl b/test/deprecations.jl index 95576086..58273158 100644 --- a/test/deprecations.jl +++ b/test/deprecations.jl @@ -4,11 +4,11 @@ gp = f(x, 0.1) plt = @test_deprecated sampleplot(gp, 10) - @test plt.n == 10 + @test plt.n == 1 @test_deprecated sampleplot!(gp, 4) - @test plt.n == 14 + @test plt.n == 2 @test_deprecated sampleplot!(Plots.current(), gp, 3) - @test plt.n == 17 + @test plt.n == 3 end From 707ef25ba87375d62a5bd248570343e4000a1c26 Mon Sep 17 00:00:00 2001 From: ST John Date: Wed, 25 Aug 2021 11:07:32 +0300 Subject: [PATCH 14/24] update test --- test/util/plotting.jl | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/test/util/plotting.jl b/test/util/plotting.jl index 0cc3b88e..966abd28 100644 --- a/test/util/plotting.jl +++ b/test/util/plotting.jl @@ -6,18 +6,20 @@ z = rand(10) plt1 = sampleplot(z, gp) @test plt1.n == 1 - @test plt1.series_list[1].plotattributes[:x] == sort(z) + @test plt1.series_list[1].plotattributes[:x] == vcat(z, NaN) - plt2 = sampleplot(gp; samples=10) - @test plt2.n == 10 - sort_x = sort(x) - @test all(series.plotattributes[:x] == sort_x for series in plt2.series_list) + plt2 = sampleplot(gp; samples=3) + @test plt2.n == 1 + plt2_x = plt2.series_list[1].plotattributes[:x] + plt2_y = plt2.series_list[1].plotattributes[:y] + @test plt2_x == vcat(z, NaN, z, NaN, z, NaN) + @test length(plt2_y) == length(plt2_x) + @test isnan(plt2_y[length(z) + 1]) && isnan(plt2_y[2length(z) + 2]) - z = rand(7) - plt3 = sampleplot(z, f; samples=8) - @test plt3.n == 8 - sort_z = sort(z) - @test all(series.plotattributes[:x] == sort_z for series in plt3.series_list) + z3 = rand(7) + plt3 = sampleplot(z3, f; samples=2) + @test plt3.n == 1 + @test plt3.series_list[1].plotattributes[:x] == vcat(z3, NaN, z3, NaN) # Check recipe dispatches for `FiniteGP`s rec = RecipesBase.apply_recipe(Dict{Symbol,Any}(), gp) From 528124e0f6809e3737bb13dc4da08c9adc2a8ce8 Mon Sep 17 00:00:00 2001 From: ST John Date: Wed, 25 Aug 2021 11:30:05 +0300 Subject: [PATCH 15/24] fix NaN comparison in test --- test/util/plotting.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/util/plotting.jl b/test/util/plotting.jl index 966abd28..64a4acdd 100644 --- a/test/util/plotting.jl +++ b/test/util/plotting.jl @@ -6,20 +6,20 @@ z = rand(10) plt1 = sampleplot(z, gp) @test plt1.n == 1 - @test plt1.series_list[1].plotattributes[:x] == vcat(z, NaN) + @test isequal(plt1.series_list[1].plotattributes[:x], vcat(z, NaN)) plt2 = sampleplot(gp; samples=3) @test plt2.n == 1 plt2_x = plt2.series_list[1].plotattributes[:x] plt2_y = plt2.series_list[1].plotattributes[:y] - @test plt2_x == vcat(z, NaN, z, NaN, z, NaN) + @test isequal(plt2_x, vcat(z, NaN, z, NaN, z, NaN)) @test length(plt2_y) == length(plt2_x) @test isnan(plt2_y[length(z) + 1]) && isnan(plt2_y[2length(z) + 2]) z3 = rand(7) plt3 = sampleplot(z3, f; samples=2) @test plt3.n == 1 - @test plt3.series_list[1].plotattributes[:x] == vcat(z3, NaN, z3, NaN) + @test isequal(plt3.series_list[1].plotattributes[:x], vcat(z3, NaN, z3, NaN)) # Check recipe dispatches for `FiniteGP`s rec = RecipesBase.apply_recipe(Dict{Symbol,Any}(), gp) From 830249b93b9d2c1abe665c211fd3ca645c88fc41 Mon Sep 17 00:00:00 2001 From: ST John Date: Wed, 25 Aug 2021 11:30:19 +0300 Subject: [PATCH 16/24] adjust linealpha to 0.35 to make up for no longer plotting markers --- src/util/plotting.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/plotting.jl b/src/util/plotting.jl index 4bcc8588..4cfc74a4 100644 --- a/src/util/plotting.jl +++ b/src/util/plotting.jl @@ -126,7 +126,7 @@ SamplePlot((x, gp)::Tuple{<:AbstractVector,<:AbstractGP}) = SamplePlot((gp(x, 1e # Set default attributes #seriestype --> :line - linealpha --> 0.2 + linealpha --> 0.35 seriescolor --> "red" label --> "" From d0c1f5b983664ab9134b9ed81f9c412ace1b444f Mon Sep 17 00:00:00 2001 From: ST John Date: Wed, 25 Aug 2021 11:54:15 +0300 Subject: [PATCH 17/24] fix mistake; --- test/util/plotting.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/util/plotting.jl b/test/util/plotting.jl index 64a4acdd..22f510ac 100644 --- a/test/util/plotting.jl +++ b/test/util/plotting.jl @@ -12,7 +12,7 @@ @test plt2.n == 1 plt2_x = plt2.series_list[1].plotattributes[:x] plt2_y = plt2.series_list[1].plotattributes[:y] - @test isequal(plt2_x, vcat(z, NaN, z, NaN, z, NaN)) + @test isequal(plt2_x, vcat(x, NaN, x, NaN, x, NaN)) @test length(plt2_y) == length(plt2_x) @test isnan(plt2_y[length(z) + 1]) && isnan(plt2_y[2length(z) + 2]) From bd3b3ed7aedc3404ddbc3059f7a0a3d88053dfa6 Mon Sep 17 00:00:00 2001 From: ST John Date: Wed, 25 Aug 2021 11:57:17 +0300 Subject: [PATCH 18/24] clean up other plot code as well --- examples/regression-1d/script.jl | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/examples/regression-1d/script.jl b/examples/regression-1d/script.jl index 12e5e405..d3b93b0f 100644 --- a/examples/regression-1d/script.jl +++ b/examples/regression-1d/script.jl @@ -289,15 +289,8 @@ mean(logpdf(gp_posterior(x_train, y_train, p)(x_test), y_test) for p in samples) # We sample a function from the posterior GP for the final 100 samples of kernel # parameters. -plt = scatter( - x_train, - y_train; - xlim=(0, 1), - xlabel="x", - ylabel="y", - title="posterior (DynamicHMC)", - label="Train Data", -) +plt = plot(; xlim=(0, 1), xlabel="x", ylabel="y", title="posterior (DynamicHMC)") +scatter!(plt, x_train, y_train; label="Train Data") scatter!(plt, x_test, y_test; label="Test Data") for p in samples[(end - 100):end] sampleplot!(plt, 0:0.02:1, gp_posterior(x_train, y_train, p)) @@ -348,15 +341,8 @@ mean(logpdf(gp_posterior(x_train, y_train, p)(x_test), y_test) for p in samples) # We sample a function from the posterior GP for the final 100 samples of kernel # parameters. -plt = scatter( - x_train, - y_train; - xlim=(0, 1), - xlabel="x", - ylabel="y", - title="posterior (EllipticalSliceSampling)", - label="Train Data", -) +plt = plot(; xlim=(0, 1), xlabel="x", ylabel="y", title="posterior (EllipticalSliceSampling)") +scatter!(plt, x_train, y_train; label="Train Data") scatter!(plt, x_test, y_test; label="Test Data") for p in samples[(end - 100):end] sampleplot!(plt, 0:0.02:1, gp_posterior(x_train, y_train, p)) From c4fa4d79e793db5f14a3d7dbafcaeb8866ae8080 Mon Sep 17 00:00:00 2001 From: ST John Date: Wed, 25 Aug 2021 11:58:56 +0300 Subject: [PATCH 19/24] update docstring --- src/util/plotting.jl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/util/plotting.jl b/src/util/plotting.jl index 4cfc74a4..3ee86699 100644 --- a/src/util/plotting.jl +++ b/src/util/plotting.jl @@ -85,6 +85,8 @@ Plot samples from the projection `f` of a Gaussian process versus `x`. When plotting multiple samples, these are treated as a _single_ series (i.e., only a single entry will be added to the legend when providing a `label`). +The seriescolor is red by default. + # Example ```julia @@ -94,7 +96,7 @@ gp = GP(SqExponentialKernel()) sampleplot(gp(rand(5)); samples=10, linealpha=1.0) ``` The given example plots 10 samples from the projection of the GP `gp`. -The `linealpha` is modified from default of 0.2 to 1. +The `linealpha` is modified from default of 0.35 to 1. --- sampleplot(x::AbstractVector, gp::AbstractGP; samples=1, kwargs...) @@ -125,7 +127,6 @@ SamplePlot((x, gp)::Tuple{<:AbstractVector,<:AbstractGP}) = SamplePlot((gp(x, 1e flat_f = vec(vcat(samples, fill(NaN, 1, nsamples))) # Set default attributes - #seriestype --> :line linealpha --> 0.35 seriescolor --> "red" label --> "" From 2c47712671e43950ffe9aea0bc9116d77993bd35 Mon Sep 17 00:00:00 2001 From: st-- Date: Wed, 25 Aug 2021 12:00:41 +0300 Subject: [PATCH 20/24] Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- examples/regression-1d/script.jl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/regression-1d/script.jl b/examples/regression-1d/script.jl index d3b93b0f..120a039e 100644 --- a/examples/regression-1d/script.jl +++ b/examples/regression-1d/script.jl @@ -341,7 +341,9 @@ mean(logpdf(gp_posterior(x_train, y_train, p)(x_test), y_test) for p in samples) # We sample a function from the posterior GP for the final 100 samples of kernel # parameters. -plt = plot(; xlim=(0, 1), xlabel="x", ylabel="y", title="posterior (EllipticalSliceSampling)") +plt = plot(; + xlim=(0, 1), xlabel="x", ylabel="y", title="posterior (EllipticalSliceSampling)" +) scatter!(plt, x_train, y_train; label="Train Data") scatter!(plt, x_test, y_test; label="Test Data") for p in samples[(end - 100):end] From a750d15ed1aa4abd02de510467c3789699db1672 Mon Sep 17 00:00:00 2001 From: ST John Date: Thu, 26 Aug 2021 09:58:00 +0300 Subject: [PATCH 21/24] sampleplot: remove seriescolor=red default --- src/util/plotting.jl | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/util/plotting.jl b/src/util/plotting.jl index 3ee86699..dc6aa211 100644 --- a/src/util/plotting.jl +++ b/src/util/plotting.jl @@ -85,8 +85,6 @@ Plot samples from the projection `f` of a Gaussian process versus `x`. When plotting multiple samples, these are treated as a _single_ series (i.e., only a single entry will be added to the legend when providing a `label`). -The seriescolor is red by default. - # Example ```julia @@ -128,7 +126,6 @@ SamplePlot((x, gp)::Tuple{<:AbstractVector,<:AbstractGP}) = SamplePlot((gp(x, 1e # Set default attributes linealpha --> 0.35 - seriescolor --> "red" label --> "" return flat_x, flat_f From 36f91b3f145bc6ebaa882a573b8f956f8556e458 Mon Sep 17 00:00:00 2001 From: ST John Date: Thu, 26 Aug 2021 10:35:15 +0300 Subject: [PATCH 22/24] bump minor version (not backwards compatible) --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 583bd96e..3e19b1cf 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "AbstractGPs" uuid = "99985d1d-32ba-4be9-9821-2ec096f28918" authors = ["JuliaGaussianProcesses Team"] -version = "0.4.1" +version = "0.5.0" [deps] ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" From ab37628170d58677831e770842fec284d49a296d Mon Sep 17 00:00:00 2001 From: ST John Date: Thu, 26 Aug 2021 10:39:09 +0300 Subject: [PATCH 23/24] bump docs/examples compat --- docs/Project.toml | 2 +- examples/regression-1d/Project.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/Project.toml b/docs/Project.toml index 367379a9..5667f86a 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -4,5 +4,5 @@ Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" [compat] -AbstractGPs = "0.4" +AbstractGPs = "0.4, 0.5" Documenter = "0.27" diff --git a/examples/regression-1d/Project.toml b/examples/regression-1d/Project.toml index c9b9bcb4..4e921146 100644 --- a/examples/regression-1d/Project.toml +++ b/examples/regression-1d/Project.toml @@ -13,7 +13,7 @@ Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" StatsFuns = "4c63d2b9-4356-54db-8cca-17b64c39e42c" [compat] -AbstractGPs = "0.4" +AbstractGPs = "0.4, 0.5" AdvancedHMC = "0.2" Distributions = "0.19, 0.20, 0.21, 0.22, 0.23, 0.24, 0.25" DynamicHMC = "2.2, 3.1" From 3c6a2ce009a3bbef7b2cfaae1ab3359d877c3744 Mon Sep 17 00:00:00 2001 From: ST John Date: Thu, 26 Aug 2021 10:41:18 +0300 Subject: [PATCH 24/24] explicitly set seriescolor="red" to account for backwards-incompatible change --- examples/regression-1d/script.jl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/regression-1d/script.jl b/examples/regression-1d/script.jl index a13304c9..8fa5e1bf 100644 --- a/examples/regression-1d/script.jl +++ b/examples/regression-1d/script.jl @@ -219,6 +219,7 @@ for (i, p) in enumerate(samples[(end - 100):end]) 0:0.02:1, gp_posterior(x_train, y_train, p); samples=5, + seriescolor="red", label=(i == 1 ? "samples" : nothing), ) end @@ -293,7 +294,7 @@ plt = plot(; xlim=(0, 1), xlabel="x", ylabel="y", title="posterior (DynamicHMC)" scatter!(plt, x_train, y_train; label="Train Data") scatter!(plt, x_test, y_test; label="Test Data") for p in samples[(end - 100):end] - sampleplot!(plt, 0:0.02:1, gp_posterior(x_train, y_train, p)) + sampleplot!(plt, 0:0.02:1, gp_posterior(x_train, y_train, p); seriescolor="red") end plt @@ -347,7 +348,7 @@ plt = plot(; scatter!(plt, x_train, y_train; label="Train Data") scatter!(plt, x_test, y_test; label="Test Data") for p in samples[(end - 100):end] - sampleplot!(plt, 0:0.02:1, gp_posterior(x_train, y_train, p)) + sampleplot!(plt, 0:0.02:1, gp_posterior(x_train, y_train, p); seriescolor="red") end plt