From 7d173b1c89f698dc995d6bcb46c94b86e9e4afc5 Mon Sep 17 00:00:00 2001 From: willtebbutt Date: Thu, 22 Jul 2021 10:40:54 +0100 Subject: [PATCH] Utilise AbstractGPs.TestUtils (#206) --- ...aussian_process_probabilistic_programme.jl | 36 ++----------------- test/gp/gp.jl | 5 +-- 2 files changed, 3 insertions(+), 38 deletions(-) diff --git a/test/gaussian_process_probabilistic_programme.jl b/test/gaussian_process_probabilistic_programme.jl index 0a14a005..3948efa1 100644 --- a/test/gaussian_process_probabilistic_programme.jl +++ b/test/gaussian_process_probabilistic_programme.jl @@ -82,40 +82,8 @@ GPPPInput(:f1, randn(4)), ), ] - - atol=1e-9 - rtol=1e-9 - - m = mean(f, x0) - @test m isa AbstractVector{<:Real} - @test length(m) == length(x0) - - @assert length(x0) ≠ length(x1) - - # Check that unary cov is consistent with binary cov and conforms to the API - K_x0 = cov(f, x0) - @test K_x0 isa AbstractMatrix{<:Real} - @test size(K_x0) == (length(x0), length(x0)) - @test K_x0 ≈ cov(f, x0, x0) atol=atol rtol=rtol - @test minimum(eigvals(K_x0)) > -atol - @test K_x0 ≈ K_x0' atol=atol rtol=rtol - - # Check that single-process binary cov is consistent with single-process binary-cov - K_x0_x1 = cov(f, x0, x1) - @test K_x0_x1 isa AbstractMatrix{<:Real} - @test size(K_x0_x1) == (length(x0), length(x1)) - - # Check that single-process binary var is consistent. - K_x0_x0_diag = var(f, x0, x0) - @test K_x0_x0_diag isa AbstractVector{<:Real} - @test length(K_x0_x0_diag) == length(x0) - @test K_x0_x0_diag ≈ diag(cov(f, x0, x0)) atol=atol rtol=rtol - - # Check that unary var conforms to the API and is consistent with unary cov - K_x0_diag = var(f, x0) - @test K_x0_diag isa AbstractVector{<:Real} - @test length(K_x0_diag) == length(x0) - @test K_x0_diag ≈ diag(cov(f, x0)) atol=atol rtol=rtol + rng = MersenneTwister(123456) + AbstractGPs.TestUtils.test_internal_abstractgps_interface(rng, f, x0, x1) end @timedtestset "gppp macro" begin diff --git a/test/gp/gp.jl b/test/gp/gp.jl index ec86a9dd..1f3ea26a 100644 --- a/test/gp/gp.jl +++ b/test/gp/gp.jl @@ -11,10 +11,7 @@ @test mean(f, x) == AbstractGPs._map(m, x) @test cov(f, x) == kernelmatrix(k, x) - @test var(f, x) == diag(cov(f, x)) - @test cov(f, x, x) == kernelmatrix(k, x, x) - @test cov(f, x, x′) == kernelmatrix(k, x, x′) - @test cov(f, x, x′) ≈ cov(f, x′, x)' + AbstractGPs.TestUtils.test_internal_abstractgps_interface(rng, f, x, x′) end # Test the creation of indepenent GPs.