Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions test/mokernels/independent.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
@testset "independent" begin
outdim = 3
x = KernelFunctions.MOInputIsotopicByOutputs([rand(5) for _ in 1:4], outdim)
y = KernelFunctions.MOInputIsotopicByOutputs([rand(5) for _ in 1:4], outdim)
z = KernelFunctions.MOInputIsotopicByOutputs([rand(5) for _ in 1:2], outdim)
rng = StableRNG(123456)
x = KernelFunctions.MOInputIsotopicByOutputs([rand(rng, 5) for _ in 1:4], outdim)
y = KernelFunctions.MOInputIsotopicByOutputs([rand(rng, 5) for _ in 1:4], outdim)
z = KernelFunctions.MOInputIsotopicByOutputs([rand(rng, 5) for _ in 1:2], outdim)

xIF = KernelFunctions.MOInputIsotopicByFeatures(x.x, outdim)
yIF = KernelFunctions.MOInputIsotopicByFeatures(y.x, outdim)
Expand All @@ -14,14 +15,17 @@
@test k isa Kernel
@test k.kernel isa Kernel

@test kernelmatrix(k, x, y) == kernelmatrix(k, collect(x), collect(y))
@test isapprox(
kernelmatrix(k, x, y), kernelmatrix(k, collect(x), collect(y));
rtol=1e-6,
)

## accuracy
KernelFunctions.TestUtils.test_interface(k, x, y, z)
KernelFunctions.TestUtils.test_interface(k, xIF, yIF, zIF)

# type stability (maybe move to test_interface?)
x2 = MOInput(rand(Float32, 4), 2)
x2 = MOInput(rand(rng, Float32, 4), 2)
@test k(x2[1], x2[2]) isa Float32
@test k(x2[1], x2[1]) isa Float32
@test eltype(typeof(kernelmatrix(k, x2))) <: Float32
Expand Down