Skip to content

Commit 1bfda4d

Browse files
authored
Merge pull request #150 from theogf/remove_basekernel
Remove BaseKernel and deprecated functions
2 parents 86cde32 + 0ebadc6 commit 1bfda4d

File tree

10 files changed

+11
-24
lines changed

10 files changed

+11
-24
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "KernelFunctions"
22
uuid = "ec8451be-7e33-11e9-00cf-bbf324bd1392"
3-
version = "0.4.4"
3+
version = "0.4.5"
44

55
[deps]
66
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"

src/KernelFunctions.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export CosineKernel
1414
export SqExponentialKernel, RBFKernel, GaussianKernel, SEKernel
1515
export LaplacianKernel, ExponentialKernel, GammaExponentialKernel
1616
export ExponentiatedKernel
17+
export FBMKernel
1718
export MaternKernel, Matern32Kernel, Matern52Kernel
1819
export LinearKernel, PolynomialKernel
1920
export RationalQuadraticKernel, GammaRationalQuadraticKernel
@@ -48,8 +49,7 @@ Abstract type defining a slice-wise transformation on an input matrix
4849
abstract type Transform end
4950

5051
abstract type Kernel end
51-
abstract type BaseKernel <: Kernel end
52-
abstract type SimpleKernel <: BaseKernel end
52+
abstract type SimpleKernel <: Kernel end
5353

5454
include("utils.jl")
5555
include("distances/pairwise.jl")

src/basekernels/fbm.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Fractional Brownian motion kernel with Hurst index `h` from (0,1) given by
99
For `h=1/2`, this is the Wiener Kernel, for `h>1/2`, the increments are
1010
positively correlated and for `h<1/2` the increments are negatively correlated.
1111
"""
12-
struct FBMKernel{T<:Real} <: BaseKernel
12+
struct FBMKernel{T<:Real} <: Kernel
1313
h::Vector{T}
1414
function FBMKernel(; h::T=0.5) where {T<:Real}
1515
@assert 0.0 <= h <= 1.0 "FBMKernel: Given Hurst index h is invalid."

src/basekernels/gabor.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Gabor kernel with lengthscale `ell` and period `p`. Given by
77
```
88
99
"""
10-
struct GaborKernel{K<:Kernel} <: BaseKernel
10+
struct GaborKernel{K<:Kernel} <: Kernel
1111
kernel::K
1212
function GaborKernel(;ell=nothing, p=nothing)
1313
k = _gabor(ell=ell, p=p)

src/basekernels/nn.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Bayesian neural network with erf (Error Function) as activation function.
1717
- [Neal(1996)](https://www.cs.toronto.edu/~radford/bnn.book.html)
1818
- [Andrew Gordon's Thesis Pg 45](http://www.cs.cmu.edu/~andrewgw/andrewgwthesis.pdf)
1919
"""
20-
struct NeuralNetworkKernel <: BaseKernel end
20+
struct NeuralNetworkKernel <: Kernel end
2121

2222
function::NeuralNetworkKernel)(x, y)
2323
return asin(dot(x, y) / sqrt((1 + sum(abs2, x)) * (1 + sum(abs2, y))))

src/basekernels/wiener.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ See the paper *Probabilistic ODE Solvers with Runge-Kutta Means* by Schober, Duv
3232
Hennig, NIPS, 2014, for more details.
3333
3434
"""
35-
struct WienerKernel{I} <: BaseKernel
35+
struct WienerKernel{I} <: Kernel
3636
function WienerKernel{I}() where I
3737
@assert I (-1, 0, 1, 2, 3) "Invalid parameter i=$(I). Should be -1, 0, 1, 2 or 3."
3838
if I == -1

src/generic.jl

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,5 @@ Base.iterate(k::Kernel, ::Any) = nothing
55

66
printshifted(io::IO, o, shift::Int) = print(io, o)
77

8-
### Syntactic sugar for creating matrices and using kernel functions
9-
function concretetypes(k, ktypes::Vector)
10-
isempty(subtypes(k)) ? push!(ktypes, k) : concretetypes.(subtypes(k), Ref(ktypes))
11-
return ktypes
12-
end
13-
14-
for k in nameof.(subtypes(BaseKernel))
15-
@eval begin
16-
@deprecate($k::Real;args...),transform($k(args...),ρ))
17-
@deprecate($k::AbstractVector{<:Real};args...),transform($k(args...),ρ))
18-
end
19-
end
20-
218
# Fallback implementation of evaluate for `SimpleKernel`s.
229
(k::SimpleKernel)(x, y) = kappa(k, evaluate(metric(k), x, y))

test/matrix/kernelmatrix.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Custom Kernel implementation that only defines how to evaluate itself. This is used to
22
# test that fallback kernelmatrix / kerneldiagmatrix methods work properly.
3-
struct BaseSE <: KernelFunctions.BaseKernel end
3+
struct BaseSE <: KernelFunctions.Kernel end
44
(k::BaseSE)(x, y) = exp(-evaluate(SqEuclidean(), x, y))
55

66
# Custom kernel to test `SimpleKernel` interface on, independently the `SimpleKernel`s that
@@ -90,7 +90,7 @@ KernelFunctions.kappa(::ToySimpleKernel, d) = exp(-d / 2)
9090

9191
tmp_diag = Vector{Float64}(undef, length(x))
9292
@test kerneldiagmatrix!(tmp_diag, k, x) kerneldiagmatrix(k, x)
93-
@test_throws DimensionMismatch kerneldiagmatrix!(tmp_diag, k, y)
93+
@test_throws DimensionMismatch kerneldiagmatrix!(tmp_diag, k, y)
9494
end
9595
end
9696

test/mokernels/independent.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
k = IndependentMOKernel(GaussianKernel())
66
@test k isa IndependentMOKernel
77
@test k isa Kernel
8-
@test k.kernel isa KernelFunctions.BaseKernel
8+
@test k.kernel isa KernelFunctions.Kernel
99
@test k(x[2], y[2]) isa Real
1010

1111
@test kernelmatrix(k, x, y) == kernelmatrix(k, collect(x), collect(y))

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ using Test
99
using Flux
1010
import Zygote, ForwardDiff, ReverseDiff, FiniteDifferences
1111

12-
using KernelFunctions: metric, kappa, ColVecs, RowVecs
12+
using KernelFunctions: SimpleKernel, metric, kappa, ColVecs, RowVecs
1313

1414
# Writing tests:
1515
# 1. The file structure of the test should match precisely the file structure of src.

0 commit comments

Comments
 (0)