diff --git a/test/mokernels/independent.jl b/test/mokernels/independent.jl index a1ce1c25a..9c216826f 100644 --- a/test/mokernels/independent.jl +++ b/test/mokernels/independent.jl @@ -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) @@ -14,14 +15,16 @@ @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