KernelFunctions.jl icon indicating copy to clipboard operation
KernelFunctions.jl copied to clipboard

Independent mokernel failing numerical equality test randomly

Open mjp98 opened this issue 2 years ago • 2 comments

Testing locally on 1.8.5, I find that https://github.com/JuliaGaussianProcesses/KernelFunctions.jl/blob/master/test/mokernels/independent.jl#L17 occasionally fails,

independent: Test Failed at .../KernelFunctions.jl/test/mokernels/independent.jl:17
  Expression: kernelmatrix(k, x, y) == kernelmatrix(k, collect(x), collect(y))
      Evaluated: [0.6308251776147069 0.7710805544766418 … 0.0 0.0; 0.7662058489033383 0.6549773138194038 … 0.0 0.0; … ; 0.0 0.0 … 0.5723057547891549 0.4955933062398087; 0.0 0.0 … 0.7238376039335678 0.45712391842322964] == [0.6308251776147069 0.7710805544766418 … 0.0 0.0; 0.7662058489033383 0.6549773138194038 … 0.0 0.0; … ; 0.0 0.0 … 0.5723057547891549 0.4955933062398087; 0.0 0.0 … 0.7238376039335678 0.45712391842322964]

presumably due to some floating point error. The input matrices are set randomly:

    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)

It may be worth adding a seed (maybe with StableRNGs.jl?) so this is consistent across runs, and only testing equality up to a sensible numerical tolerance

mjp98 avatar Feb 27 '23 14:02 mjp98

Definitely. This looks like a test we shouldn't have written. I'll make a PR with the changes now.

willtebbutt avatar Feb 27 '23 14:02 willtebbutt

#495 should resolve

willtebbutt avatar Feb 27 '23 14:02 willtebbutt