Skip to content

Commit 81cc6e4

Browse files
committed
Merge pull request #34 from KristofferC/kc/type_asserts
remove unnecessary type asserts
2 parents dc0763e + b53dfd8 commit 81cc6e4

File tree

3 files changed

+11
-18
lines changed

3 files changed

+11
-18
lines changed

src/mahalanobis.jl

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,22 @@ sqmahalanobis(a::AbstractVector, b::AbstractVector, Q::AbstractMatrix) = evaluat
2323

2424
function colwise!{T<:AbstractFloat}(r::AbstractArray, dist::SqMahalanobis{T}, a::AbstractMatrix, b::AbstractMatrix)
2525
Q = dist.qmat
26-
m::Int, n::Int = get_colwise_dims(size(Q, 1), r, a, b)
26+
m, n = get_colwise_dims(size(Q, 1), r, a, b)
2727
z = a - b
2828
dot_percol!(r, Q * z, z)
2929
end
3030

3131
function colwise!{T<:AbstractFloat}(r::AbstractArray, dist::SqMahalanobis{T}, a::AbstractVector, b::AbstractMatrix)
3232
Q = dist.qmat
33-
m::Int, n::Int = get_colwise_dims(size(Q, 1), r, a, b)
33+
m, n = get_colwise_dims(size(Q, 1), r, a, b)
3434
z = a .- b
3535
Qz = Q * z
3636
dot_percol!(r, Q * z, z)
3737
end
3838

3939
function pairwise!{T<:AbstractFloat}(r::AbstractMatrix, dist::SqMahalanobis{T}, a::AbstractMatrix, b::AbstractMatrix)
4040
Q = dist.qmat
41-
m::Int, na::Int, nb::Int = get_pairwise_dims(size(Q, 1), r, a, b)
41+
m, na, nb = get_pairwise_dims(size(Q, 1), r, a, b)
4242

4343
Qa = Q * a
4444
Qb = Q * b
@@ -56,7 +56,7 @@ end
5656

5757
function pairwise!{T<:AbstractFloat}(r::AbstractMatrix, dist::SqMahalanobis{T}, a::AbstractMatrix)
5858
Q = dist.qmat
59-
m::Int, n::Int = get_pairwise_dims(size(Q, 1), r, a)
59+
m, n = get_pairwise_dims(size(Q, 1), r, a)
6060

6161
Qa = Q * a
6262
sa2 = dot_percol(a, Qa)
@@ -98,5 +98,3 @@ end
9898
function pairwise!{T<:AbstractFloat}(r::AbstractMatrix, dist::Mahalanobis{T}, a::AbstractMatrix)
9999
sqrt!(pairwise!(r, SqMahalanobis(dist.qmat), a))
100100
end
101-
102-

src/metrics.jl

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ function pdist!(r, sa2, sb2)
198198
r
199199
end
200200
function pairwise!(r::AbstractMatrix, dist::SqEuclidean, a::AbstractMatrix)
201-
m::Int, n::Int = get_pairwise_dims(r, a)
201+
m, n = get_pairwise_dims(r, a)
202202
At_mul_B!(r, a, a)
203203
sa2 = sumsq_percol(a)
204204
for j = 1 : n
@@ -215,7 +215,7 @@ end
215215

216216
# Euclidean
217217
function pairwise!(r::AbstractMatrix, dist::Euclidean, a::AbstractMatrix, b::AbstractMatrix)
218-
m::Int, na::Int, nb::Int = get_pairwise_dims(r, a, b)
218+
m, na, nb = get_pairwise_dims(r, a, b)
219219
At_mul_B!(r, a, b)
220220
sa2 = sumsq_percol(a)
221221
sb2 = sumsq_percol(b)
@@ -228,7 +228,7 @@ function pairwise!(r::AbstractMatrix, dist::Euclidean, a::AbstractMatrix, b::Abs
228228
r
229229
end
230230
function pairwise!(r::AbstractMatrix, dist::Euclidean, a::AbstractMatrix)
231-
m::Int, n::Int = get_pairwise_dims(r, a)
231+
m, n = get_pairwise_dims(r, a)
232232
At_mul_B!(r, a, a)
233233
sa2 = sumsq_percol(a)
234234
for j = 1 : n
@@ -246,7 +246,7 @@ end
246246

247247
# CosineDist
248248
function pairwise!(r::AbstractMatrix, dist::CosineDist, a::AbstractMatrix, b::AbstractMatrix)
249-
m::Int, na::Int, nb::Int = get_pairwise_dims(r, a, b)
249+
m, na, nb = get_pairwise_dims(r, a, b)
250250
At_mul_B!(r, a, b)
251251
ra = sqrt!(sumsq_percol(a))
252252
rb = sqrt!(sumsq_percol(b))
@@ -288,8 +288,3 @@ end
288288
function pairwise!(r::AbstractMatrix, dist::CorrDist, a::AbstractMatrix)
289289
pairwise!(r, CosineDist(), _centralize_colwise(a))
290290
end
291-
292-
293-
294-
295-

src/wmetrics.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ whamming(a::AbstractArray, b::AbstractArray, w::AbstractArray) = evaluate(Weight
117117
# SqEuclidean
118118
function pairwise!(r::AbstractMatrix, dist::WeightedSqEuclidean, a::AbstractMatrix, b::AbstractMatrix)
119119
w = dist.weights
120-
m::Int, na::Int, nb::Int = get_pairwise_dims(length(w), r, a, b)
120+
m, na, nb = get_pairwise_dims(length(w), r, a, b)
121121

122122
sa2 = wsumsq_percol(w, a)
123123
sb2 = wsumsq_percol(w, b)
@@ -131,7 +131,7 @@ function pairwise!(r::AbstractMatrix, dist::WeightedSqEuclidean, a::AbstractMatr
131131
end
132132
function pairwise!(r::AbstractMatrix, dist::WeightedSqEuclidean, a::AbstractMatrix)
133133
w = dist.weights
134-
m::Int, n::Int = get_pairwise_dims(length(w), r, a)
134+
m, n = get_pairwise_dims(length(w), r, a)
135135

136136
sa2 = wsumsq_percol(w, a)
137137
At_mul_B!(r, a, a .* w)
@@ -160,4 +160,4 @@ function pairwise!(r::AbstractMatrix, dist::WeightedEuclidean, a::AbstractMatrix
160160
end
161161
function pairwise!(r::AbstractMatrix, dist::WeightedEuclidean, a::AbstractMatrix)
162162
sqrt!(pairwise!(r, WeightedSqEuclidean(dist.weights), a))
163-
end
163+
end

0 commit comments

Comments
 (0)