Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loosen tolerance on test #495

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all 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
13 changes: 8 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,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
)
Comment on lines +18 to +20
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the non-standard rtol needed, in particular if we fix the seeds with StableRNGs? Maybe

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

would be sufficient?


## 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