Skip to content

Commit be582d5

Browse files
author
Will Tebbutt
committed
Uncomment tests
1 parent 956b581 commit be582d5

File tree

1 file changed

+103
-103
lines changed

1 file changed

+103
-103
lines changed

test/basekernels/rational.jl

Lines changed: 103 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,33 @@
44
v1 = rand(rng, 3)
55
v2 = rand(rng, 3)
66

7-
# @testset "RationalKernel" begin
8-
# α = rand()
9-
# k = RationalKernel(; α=α)
10-
11-
# @testset "RationalKernel ≈ Exponential for large α" begin
12-
# @test isapprox(
13-
# RationalKernel(; α=1e9)(v1, v2),
14-
# ExponentialKernel()(v1, v2);
15-
# atol=1e-6,
16-
# rtol=1e-6,
17-
# )
18-
# end
19-
20-
# @test metric(RationalKernel()) == Euclidean()
21-
# @test metric(RationalKernel(; α=α)) == Euclidean()
22-
# @test repr(k) == "Rational Kernel (α = $(α), metric = Euclidean(0.0))"
23-
24-
# k2 = RationalKernel(; α=α, metric=WeightedEuclidean(ones(3)))
25-
# @test metric(k2) isa WeightedEuclidean
26-
# @test k2(v1, v2) ≈ k(v1, v2)
27-
28-
# # Standardised tests.
29-
# TestUtils.test_interface(k, Float64)
30-
# test_ADs(x -> RationalKernel(; alpha=exp(x[1])), [α])
31-
# test_params(k, ([α],))
32-
# test_interface_ad_perf(α -> RationalKernel(; alpha=α), α, StableRNG(123456))
33-
# end
7+
@testset "RationalKernel" begin
8+
α = rand()
9+
k = RationalKernel(; α=α)
10+
11+
@testset "RationalKernel ≈ Exponential for large α" begin
12+
@test isapprox(
13+
RationalKernel(; α=1e9)(v1, v2),
14+
ExponentialKernel()(v1, v2);
15+
atol=1e-6,
16+
rtol=1e-6,
17+
)
18+
end
19+
20+
@test metric(RationalKernel()) == Euclidean()
21+
@test metric(RationalKernel(; α=α)) == Euclidean()
22+
@test repr(k) == "Rational Kernel (α = $(α), metric = Euclidean(0.0))"
23+
24+
k2 = RationalKernel(; α=α, metric=WeightedEuclidean(ones(3)))
25+
@test metric(k2) isa WeightedEuclidean
26+
@test k2(v1, v2) k(v1, v2)
27+
28+
# Standardised tests.
29+
TestUtils.test_interface(k, Float64)
30+
test_ADs(x -> RationalKernel(; alpha=exp(x[1])), [α])
31+
test_params(k, ([α],))
32+
test_interface_ad_perf-> RationalKernel(; alpha=α), α, StableRNG(123456))
33+
end
3434

3535
@testset "RationalQuadraticKernel" begin
3636
α = rand()
@@ -76,80 +76,80 @@
7676
end
7777
end
7878

79-
# @testset "GammaRationalKernel" begin
80-
# k = GammaRationalKernel()
81-
82-
# @test repr(k) == "Gamma Rational Kernel (α = 2.0, γ = 1.0, metric = Euclidean(0.0))"
83-
84-
# @testset "GammaRational (γ=2) ≈ RQ with rescaled inputs" begin
85-
# @test isapprox(
86-
# GammaRationalKernel(; γ=2)(v1 ./ sqrt(2), v2 ./ sqrt(2)),
87-
# RationalQuadraticKernel()(v1, v2),
88-
# )
89-
# a = 1 + rand()
90-
# @test isapprox(
91-
# GammaRationalKernel(; α=a, γ=2)(v1 ./ sqrt(2), v2 ./ sqrt(2)),
92-
# RationalQuadraticKernel(; α=a)(v1, v2),
93-
# )
94-
# end
95-
96-
# @testset "GammaRational (γ=2) ≈ EQ for large α with rescaled inputs" begin
97-
# v1 = randn(2)
98-
# v2 = randn(2)
99-
# @test isapprox(
100-
# GammaRationalKernel(; α=1e9, γ=2)(v1 ./ sqrt(2), v2 ./ sqrt(2)),
101-
# SqExponentialKernel()(v1, v2);
102-
# atol=1e-6,
103-
# rtol=1e-6,
104-
# )
105-
# end
106-
107-
# @testset "Default GammaRational ≈ Rational" begin
108-
# @test isapprox(GammaRationalKernel()(v1, v2), RationalKernel()(v1, v2))
109-
# a = 1 + rand()
110-
# @test isapprox(
111-
# GammaRationalKernel(; α=a)(v1, v2), RationalKernel(; α=a)(v1, v2)
112-
# )
113-
# end
114-
115-
# @testset "Default GammaRational ≈ Exponential for large α" begin
116-
# v1 = randn(4)
117-
# v2 = randn(4)
118-
# @test isapprox(
119-
# GammaRationalKernel(; α=1e9)(v1, v2),
120-
# ExponentialKernel()(v1, v2);
121-
# atol=1e-6,
122-
# rtol=1e-6,
123-
# )
124-
# end
125-
126-
# @testset "GammaRational ≈ GammaExponential for same γ and large α" begin
127-
# v1 = randn(3)
128-
# v2 = randn(3)
129-
# γ = rand() + 0.5
130-
# @test isapprox(
131-
# GammaRationalKernel(; α=1e9, γ=γ)(v1, v2),
132-
# GammaExponentialKernel(; γ=γ)(v1, v2);
133-
# atol=1e-6,
134-
# rtol=1e-6,
135-
# )
136-
# end
137-
138-
# @test metric(GammaRationalKernel()) == Euclidean()
139-
# @test metric(GammaRationalKernel(; γ=2.0)) == Euclidean()
140-
# @test metric(GammaRationalKernel(; γ=2.0, α=3.0)) == Euclidean()
141-
142-
# k2 = GammaRationalKernel(; metric=WeightedEuclidean(ones(3)))
143-
# @test metric(k2) isa WeightedEuclidean
144-
# @test k2(v1, v2) ≈ k(v1, v2)
145-
146-
# # Standardised tests.
147-
# TestUtils.test_interface(k, Float64)
148-
# a = 1.0 + rand()
149-
# test_ADs(x -> GammaRationalKernel(; α=x[1], γ=x[2]), [a, 1 + 0.5 * rand()])
150-
# test_params(GammaRationalKernel(; α=a, γ=x), ([a], [x]))
151-
# test_interface_ad_perf((2.0, 1.5), StableRNG(123456)) do θ
152-
# GammaRationalKernel(; α=θ[1], γ=θ[2])
153-
# end
154-
# end
79+
@testset "GammaRationalKernel" begin
80+
k = GammaRationalKernel()
81+
82+
@test repr(k) == "Gamma Rational Kernel (α = 2.0, γ = 1.0, metric = Euclidean(0.0))"
83+
84+
@testset "GammaRational (γ=2) ≈ RQ with rescaled inputs" begin
85+
@test isapprox(
86+
GammaRationalKernel(; γ=2)(v1 ./ sqrt(2), v2 ./ sqrt(2)),
87+
RationalQuadraticKernel()(v1, v2),
88+
)
89+
a = 1 + rand()
90+
@test isapprox(
91+
GammaRationalKernel(; α=a, γ=2)(v1 ./ sqrt(2), v2 ./ sqrt(2)),
92+
RationalQuadraticKernel(; α=a)(v1, v2),
93+
)
94+
end
95+
96+
@testset "GammaRational (γ=2) ≈ EQ for large α with rescaled inputs" begin
97+
v1 = randn(2)
98+
v2 = randn(2)
99+
@test isapprox(
100+
GammaRationalKernel(; α=1e9, γ=2)(v1 ./ sqrt(2), v2 ./ sqrt(2)),
101+
SqExponentialKernel()(v1, v2);
102+
atol=1e-6,
103+
rtol=1e-6,
104+
)
105+
end
106+
107+
@testset "Default GammaRational ≈ Rational" begin
108+
@test isapprox(GammaRationalKernel()(v1, v2), RationalKernel()(v1, v2))
109+
a = 1 + rand()
110+
@test isapprox(
111+
GammaRationalKernel(; α=a)(v1, v2), RationalKernel(; α=a)(v1, v2)
112+
)
113+
end
114+
115+
@testset "Default GammaRational ≈ Exponential for large α" begin
116+
v1 = randn(4)
117+
v2 = randn(4)
118+
@test isapprox(
119+
GammaRationalKernel(; α=1e9)(v1, v2),
120+
ExponentialKernel()(v1, v2);
121+
atol=1e-6,
122+
rtol=1e-6,
123+
)
124+
end
125+
126+
@testset "GammaRational ≈ GammaExponential for same γ and large α" begin
127+
v1 = randn(3)
128+
v2 = randn(3)
129+
γ = rand() + 0.5
130+
@test isapprox(
131+
GammaRationalKernel(; α=1e9, γ=γ)(v1, v2),
132+
GammaExponentialKernel(; γ=γ)(v1, v2);
133+
atol=1e-6,
134+
rtol=1e-6,
135+
)
136+
end
137+
138+
@test metric(GammaRationalKernel()) == Euclidean()
139+
@test metric(GammaRationalKernel(; γ=2.0)) == Euclidean()
140+
@test metric(GammaRationalKernel(; γ=2.0, α=3.0)) == Euclidean()
141+
142+
k2 = GammaRationalKernel(; metric=WeightedEuclidean(ones(3)))
143+
@test metric(k2) isa WeightedEuclidean
144+
@test k2(v1, v2) k(v1, v2)
145+
146+
# Standardised tests.
147+
TestUtils.test_interface(k, Float64)
148+
a = 1.0 + rand()
149+
test_ADs(x -> GammaRationalKernel(; α=x[1], γ=x[2]), [a, 1 + 0.5 * rand()])
150+
test_params(GammaRationalKernel(; α=a, γ=x), ([a], [x]))
151+
test_interface_ad_perf((2.0, 1.5), StableRNG(123456)) do θ
152+
GammaRationalKernel(; α=θ[1], γ=θ[2])
153+
end
154+
end
155155
end

0 commit comments

Comments
 (0)