diff --git a/Project.toml b/Project.toml index 88c97aed8..48646036b 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "KernelFunctions" uuid = "ec8451be-7e33-11e9-00cf-bbf324bd1392" -version = "0.10.38" +version = "0.10.39" [deps] ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" diff --git a/src/TestUtils.jl b/src/TestUtils.jl index 26b4fe467..b5de47f33 100644 --- a/src/TestUtils.jl +++ b/src/TestUtils.jl @@ -6,20 +6,14 @@ using KernelFunctions using Random using Test -# default tolerance values for test_interface: -const __ATOL = sqrt(eps(Float64)) -const __RTOL = sqrt(eps(Float64)) -# ≈ 1.5e-8; chosen for no particular reason other than because it seems to -# satisfy our own test cases within KernelFunctions.jl - """ test_interface( k::Kernel, x0::AbstractVector, x1::AbstractVector, x2::AbstractVector; - atol=__ATOL, - rtol=__RTOL, + rtol=1e-6, + atol=rtol, ) Run various consistency checks on `k` at the inputs `x0`, `x1`, and `x2`. @@ -29,22 +23,14 @@ be of different lengths. These tests are intended to pick up on really substantial issues with a kernel implementation (e.g. substantial asymmetry in the kernel matrix, large negative eigenvalues), rather than to test the numerics in detail, which can be kernel-specific. -The default value of `__ATOL` and `__RTOL` is `sqrt(eps(Float64)) ≈ 1.5e-8`, which satisfied -this intention in the cases tested within KernelFunctions.jl itself. - - test_interface([rng::AbstractRNG], k::Kernel, T::Type{<:Real}; atol=__ATOL, rtol=__RTOL) - -`test_interface` offers automated test data generation for kernels whose inputs are reals. -This will run the tests for `Vector{T}`, `Vector{Vector{T}}`, `ColVecs{T}`, and `RowVecs{T}`. -For other input vector types, please provide the data manually. """ function test_interface( k::Kernel, x0::AbstractVector, x1::AbstractVector, x2::AbstractVector; - atol=__ATOL, - rtol=__RTOL, + rtol=1e-6, + atol=rtol, ) # Ensure that we have the required inputs. @assert length(x0) == length(x1) @@ -160,7 +146,16 @@ function test_interface(k::Kernel, T::Type{<:AbstractVector}; kwargs...) return test_interface(Random.GLOBAL_RNG, k, T; kwargs...) end -function test_interface(rng::AbstractRNG, k::Kernel, T::Type{<:Real}; kwargs...) +""" + test_interface([rng::AbstractRNG], k::Kernel, ::Type{T}; kwargs...) where {T<:Real} + +Run the [`test_interface`](@ref) tests for randomly generated inputs of types `Vector{T}`, `Vector{Vector{T}}`, `ColVecs{T}`, and `RowVecs{T}`. + +For other input types, please provide the data manually. + +The keyword arguments are forwarded to the invocations of [`test_interface`](@ref) with the randomly generated inputs. +""" +function test_interface(rng::AbstractRNG, k::Kernel, ::Type{T}; kwargs...) where {T<:Real} @testset "Vector{$T}" begin test_interface(rng, k, Vector{T}; kwargs...) end diff --git a/src/basekernels/matern.jl b/src/basekernels/matern.jl index dcc35f6be..c050cad0d 100644 --- a/src/basekernels/matern.jl +++ b/src/basekernels/matern.jl @@ -37,11 +37,8 @@ MaternKernel(; nu::Real=1.5, ν::Real=nu, metric=Euclidean()) = MaternKernel(ν, @functor MaternKernel -@inline _get_ν(k::MaternKernel) = only(k.ν) -ChainRulesCore.@non_differentiable _get_ν(k) # work-around; should be "NotImplemented" rather than NoTangent - @inline function kappa(k::MaternKernel, d::Real) - result = _matern(_get_ν(k), d) + result = _matern(only(k.ν), d) return ifelse(iszero(d), one(result), result) end diff --git a/test/Project.toml b/test/Project.toml index d71c3dfc0..8860a9fb2 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -30,4 +30,4 @@ LogExpFunctions = "0.2, 0.3" PDMats = "0.9, 0.10, 0.11" ReverseDiff = "1.2" SpecialFunctions = "0.10, 1, 2" -Zygote = "0.4, 0.5, 0.6" +Zygote = "0.6.38"