Skip to content

Commit 095b8d0

Browse files
authored
Stop using deprecated signatures from Distances.jl (#529)
1 parent cf937ce commit 095b8d0

File tree

7 files changed

+27
-27
lines changed

7 files changed

+27
-27
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
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.10.57"
3+
version = "0.10.58"
44

55
[deps]
66
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
@@ -25,7 +25,7 @@ ZygoteRules = "700de1a5-db45-46bc-99cf-38207098b444"
2525
ChainRulesCore = "1"
2626
Compat = "3.7, 4"
2727
CompositionsBase = "0.1"
28-
Distances = "0.10"
28+
Distances = "0.10.9"
2929
FillArrays = "0.10, 0.11, 0.12, 0.13, 1"
3030
Functors = "0.1, 0.2, 0.3, 0.4"
3131
IrrationalConstants = "0.1, 0.2"

src/basekernels/fbm.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ end
5757

5858
function kernelmatrix!(K::AbstractMatrix, κ::FBMKernel, x::AbstractVector)
5959
modx = _mod(x)
60-
pairwise!(K, SqEuclidean(), x)
60+
pairwise!(SqEuclidean(), K, x)
6161
K .= _fbm.(modx, modx', K, κ.h)
6262
return K
6363
end
@@ -72,7 +72,7 @@ end
7272
function kernelmatrix!(
7373
K::AbstractMatrix, κ::FBMKernel, x::AbstractVector, y::AbstractVector
7474
)
75-
pairwise!(K, SqEuclidean(), x, y)
75+
pairwise!(SqEuclidean(), K, x, y)
7676
K .= _fbm.(_mod(x), _mod(y)', K, κ.h)
7777
return K
7878
end

src/distances/pairwise.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ end
66

77
pairwise(d::PreMetric, X::AbstractVector) = pairwise(d, X, X)
88

9-
function pairwise!(out::AbstractMatrix, d::PreMetric, X::AbstractVector, Y::AbstractVector)
9+
function pairwise!(d::PreMetric, out::AbstractMatrix, X::AbstractVector, Y::AbstractVector)
1010
return broadcast!(d, out, X, permutedims(Y))
1111
end
1212

13-
pairwise!(out::AbstractMatrix, d::PreMetric, X::AbstractVector) = pairwise!(out, d, X, X)
13+
pairwise!(d::PreMetric, out::AbstractMatrix, X::AbstractVector) = pairwise!(d, out, X, X)
1414

1515
function pairwise(d::PreMetric, x::AbstractVector{<:Real})
1616
return Distances_pairwise(d, reshape(x, :, 1); dims=1)
@@ -20,14 +20,14 @@ function pairwise(d::PreMetric, x::AbstractVector{<:Real}, y::AbstractVector{<:R
2020
return Distances_pairwise(d, reshape(x, :, 1), reshape(y, :, 1); dims=1)
2121
end
2222

23-
function pairwise!(out::AbstractMatrix, d::PreMetric, x::AbstractVector{<:Real})
24-
return Distances.pairwise!(out, d, reshape(x, :, 1); dims=1)
23+
function pairwise!(d::PreMetric, out::AbstractMatrix, x::AbstractVector{<:Real})
24+
return Distances.pairwise!(d, out, reshape(x, :, 1); dims=1)
2525
end
2626

2727
function pairwise!(
28-
out::AbstractMatrix, d::PreMetric, x::AbstractVector{<:Real}, y::AbstractVector{<:Real}
28+
d::PreMetric, out::AbstractMatrix, x::AbstractVector{<:Real}, y::AbstractVector{<:Real}
2929
)
30-
return Distances.pairwise!(out, d, reshape(x, :, 1), reshape(y, :, 1); dims=1)
30+
return Distances.pairwise!(d, out, reshape(x, :, 1), reshape(y, :, 1); dims=1)
3131
end
3232

3333
# Also defines the colwise method for abstractvectors

src/matrix/kernelmatrix.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,15 @@ kernelmatrix_diag(κ::Kernel, x::AbstractVector, y::AbstractVector) = map(κ, x,
134134

135135
function kernelmatrix!(K::AbstractMatrix, κ::SimpleKernel, x::AbstractVector)
136136
validate_inplace_dims(K, x)
137-
pairwise!(K, metric(κ), x)
137+
pairwise!(metric(κ), K, x)
138138
return map!(x -> kappa(κ, x), K, K)
139139
end
140140

141141
function kernelmatrix!(
142142
K::AbstractMatrix, κ::SimpleKernel, x::AbstractVector, y::AbstractVector
143143
)
144144
validate_inplace_dims(K, x, y)
145-
pairwise!(K, metric(κ), x, y)
145+
pairwise!(metric(κ), K, x, y)
146146
return map!(x -> kappa(κ, x), K, K)
147147
end
148148

src/utils.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,11 @@ end
107107
function pairwise(d::PreMetric, x::ColVecs, y::AbstractVector{<:AbstractVector{<:Real}})
108108
return Distances_pairwise(d, x.X, reduce(hcat, y); dims=2)
109109
end
110-
function pairwise!(out::AbstractMatrix, d::PreMetric, x::ColVecs)
111-
return Distances.pairwise!(out, d, x.X; dims=2)
110+
function pairwise!(d::PreMetric, out::AbstractMatrix, x::ColVecs)
111+
return Distances.pairwise!(d, out, x.X; dims=2)
112112
end
113-
function pairwise!(out::AbstractMatrix, d::PreMetric, x::ColVecs, y::ColVecs)
114-
return Distances.pairwise!(out, d, x.X, y.X; dims=2)
113+
function pairwise!(d::PreMetric, out::AbstractMatrix, x::ColVecs, y::ColVecs)
114+
return Distances.pairwise!(d, out, x.X, y.X; dims=2)
115115
end
116116

117117
"""
@@ -178,11 +178,11 @@ end
178178
function pairwise(d::PreMetric, x::RowVecs, y::AbstractVector{<:AbstractVector{<:Real}})
179179
return Distances_pairwise(d, x.X, permutedims(reduce(hcat, y)); dims=1)
180180
end
181-
function pairwise!(out::AbstractMatrix, d::PreMetric, x::RowVecs)
182-
return Distances.pairwise!(out, d, x.X; dims=1)
181+
function pairwise!(d::PreMetric, out::AbstractMatrix, x::RowVecs)
182+
return Distances.pairwise!(d, out, x.X; dims=1)
183183
end
184-
function pairwise!(out::AbstractMatrix, d::PreMetric, x::RowVecs, y::RowVecs)
185-
return Distances.pairwise!(out, d, x.X, y.X; dims=1)
184+
function pairwise!(d::PreMetric, out::AbstractMatrix, x::RowVecs, y::RowVecs)
185+
return Distances.pairwise!(d, out, x.X, y.X; dims=1)
186186
end
187187

188188
# Resolve ambiguity error for ColVecs vs RowVecs. #346

test/distances/pairwise.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111

1212
@test KernelFunctions.pairwise(d, x, y) pairwise(d, X, Y; dims=2)
1313
@test KernelFunctions.pairwise(d, x) pairwise(d, X; dims=2)
14-
KernelFunctions.pairwise!(K, d, x, y)
14+
KernelFunctions.pairwise!(d, K, x, y)
1515
@test K pairwise(d, X, Y; dims=2)
1616
K = zeros(Ns[1], Ns[1])
17-
KernelFunctions.pairwise!(K, d, x)
17+
KernelFunctions.pairwise!(d, K, x)
1818
@test K pairwise(d, X; dims=2)
1919

2020
x = randn(rng, 10)
@@ -24,6 +24,6 @@
2424
K = zeros(10, 11)
2525
@test KernelFunctions.pairwise(d, x, y) pairwise(d, X, Y; dims=1)
2626
@test KernelFunctions.pairwise(d, x) pairwise(d, X; dims=1)
27-
KernelFunctions.pairwise!(K, d, x, y)
27+
KernelFunctions.pairwise!(d, K, x, y)
2828
@test K pairwise(d, X, Y; dims=1)
2929
end

test/utils.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@
4747
@test vcat(DX, DY) isa ColVecs
4848
@test vcat(DX, DY).X == hcat(X, Y)
4949
K = zeros(N, N)
50-
KernelFunctions.pairwise!(K, SqEuclidean(), DX)
50+
KernelFunctions.pairwise!(SqEuclidean(), K, DX)
5151
@test K pairwise(SqEuclidean(), X; dims=2)
5252
K = zeros(N, N + 1)
53-
KernelFunctions.pairwise!(K, SqEuclidean(), DX, DY)
53+
KernelFunctions.pairwise!(SqEuclidean(), K, DX, DY)
5454
@test K pairwise(SqEuclidean(), X, Y; dims=2)
5555

5656
let
@@ -105,10 +105,10 @@
105105
@test vcat(DX, DY) isa RowVecs
106106
@test vcat(DX, DY).X == vcat(X, Y)
107107
K = zeros(D, D)
108-
KernelFunctions.pairwise!(K, SqEuclidean(), DX)
108+
KernelFunctions.pairwise!(SqEuclidean(), K, DX)
109109
@test K pairwise(SqEuclidean(), X; dims=1)
110110
K = zeros(D, D + 1)
111-
KernelFunctions.pairwise!(K, SqEuclidean(), DX, DY)
111+
KernelFunctions.pairwise!(SqEuclidean(), K, DX, DY)
112112
@test K pairwise(SqEuclidean(), X, Y; dims=1)
113113

114114
let

0 commit comments

Comments
 (0)