Skip to content

Commit abea39d

Browse files
committed
Added some basic tests
1 parent 2599a55 commit abea39d

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

test/constructors.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
#TODO Test metric weights for ARD, test equivalency for different constructors,
3+
# test type conversion
4+
l = 2.0
5+
vl = [l,l]
6+
7+
## SquaredExponentialKernel
8+
@testset "SquaredExponentialKernel" begin
9+
@test KernelFunctions.metric(SquaredExponentialKernel(l)) == SqEuclidean()
10+
@test KernelFunctions.metric(SquaredExponentialKernel(vl)) == WeightedSqEuclidean(vl)
11+
end
12+
13+
SquaredExponentialKernel(l)

test/kernelmatrix.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
dims = [10,5]
2+
3+
A = rand(dims...)
4+
B = rand(dims...)
5+
K = [zeros(dims[1],dims[1]),zeros(dims[2],dims[2])]
6+
k = SquaredExponentialKernel()
7+
8+
@testset "Inplace kernelmatrix" begin
9+
for obsdim in [1,2]
10+
@test kernelmatrix!(K[obsdim],k,A,B,obsdim=obsdim) == kernelmatrix(k,A,B,obsdim=obsdim)
11+
end
12+
end
13+
14+
@testset "Kernal matrix" begin
15+
for obsdim in [1,2]
16+
@test kernelmatrix(k,A,B,obsdim=obsdim) == kappa.([k],pairwise(KernelFunctions.metric(k),A,B,dims=obsdim))
17+
end
18+
end

test/runtests.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
using Test
22
using KernelFunctions
3+
using Distances
34

4-
@test 1+1 == 2
5+
include("kernelmatrix.jl")
6+
include("constructors.jl")

0 commit comments

Comments
 (0)