Skip to content

Commit

Permalink
fix some lint stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
KristofferC committed Aug 24, 2016
1 parent 62143f4 commit e3a061e
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 24 deletions.
4 changes: 2 additions & 2 deletions src/NearestNeighbors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ abstract NNTree{V <: AbstractVector, P <: Metric}
typealias DistanceType Float64
typealias MinkowskiMetric Union{Euclidean, Chebyshev, Cityblock, Minkowski}

function check_input{V1, V2 <: AbstractVector}(tree::NNTree{V1}, points::Vector{V2})
function check_input{V1, V2 <: AbstractVector}(::NNTree{V1}, ::Vector{V2})
if length(V1) != length(V2)
throw(ArgumentError(
"dimension of input points:$(length(V2)) and tree data:$(length(V1)) must agree"))
end
end

function check_input{V1, V2 <: Number}(tree::NNTree{V1}, point::Vector{V2})
function check_input{V1, V2 <: Number}(::NNTree{V1}, point::Vector{V2})
if length(V1) != length(point)
throw(ArgumentError(
"dimension of input points:$(length(point)) and tree data:$(length(V1)) must agree"))
Expand Down
1 change: 0 additions & 1 deletion src/ball_tree.jl
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ end

function _knn(tree::BallTree,
point::AbstractVector,
k::Int,
best_idxs::Vector{Int},
best_dists::Vector,
skip::Function)
Expand Down
1 change: 0 additions & 1 deletion src/brute_tree.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ end

function _knn{V}(tree::BruteTree{V},
point::AbstractVector,
k::Int,
best_idxs::Vector{Int},
best_dists::Vector,
skip::Function)
Expand Down
10 changes: 5 additions & 5 deletions src/evaluation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
@inline eval_pow(d::Minkowski, s) = abs(s)^d.p

@inline eval_diff(::MinkowskiMetric, a, b) = a - b
@inline eval_diff(::Chebyshev, a, b) = b
@inline eval_diff(::Chebyshev, ::Any, b) = b

function Distances.evaluate(d::Distances.UnionMetrics, a::AbstractVector,
b::AbstractVector, do_end::Bool=true)
s = eval_start(d, a, b)
@simd for I in eachindex(b)
@inbounds ai = a[I]
@inbounds bi = b[I]
@simd for i in eachindex(b)
@inbounds ai = a[i]
@inbounds bi = b[i]
s = eval_reduce(d, s, eval_op(d, ai, bi))
end
if do_end
Expand All @@ -21,6 +21,6 @@ function Distances.evaluate(d::Distances.UnionMetrics, a::AbstractVector,
end

function Distances.evaluate(d::Distances.PreMetric, a::AbstractVector,
b::AbstractArray, do_end::Bool=true)
b::AbstractArray, ::Bool=true)
evaluate(d, a, b)
end
14 changes: 7 additions & 7 deletions src/hyperspheres.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ end
evaluate(m, s1.center, s2.center) + s1.r <= s2.r
end

@inline function interpolate{V <: AbstractVector, M <: NormMetric}(m::M,
@inline function interpolate{V <: AbstractVector, M <: NormMetric}(::M,
c1::V,
c2::V,
x,
Expand All @@ -31,12 +31,12 @@ end
return ab.center, true
end

@inline function interpolate{V <: AbstractVector, M <: Metric}(m::M,
@inline function interpolate{V <: AbstractVector, M <: Metric}(::M,
c1::V,
c2::V,
x,
d,
ab)
::V,
::Any,
::Any,
::Any)
return c1, false
end

Expand All @@ -46,7 +46,7 @@ function create_bsphere{V}(data::Vector{V}, metric::Metric, indices::Vector{Int}
# First find center of all points
fill!(ab.center, 0.0)
for i in low:high
for j in length(ab.center)
for j in 1:length(ab.center)
ab.center[j] += data[indices[i]][j]
end
end
Expand Down
1 change: 0 additions & 1 deletion src/kd_tree.jl
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ end

function _knn(tree::KDTree,
point::AbstractVector,
k::Int,
best_idxs::Vector{Int},
best_dists::Vector,
skip::Function)
Expand Down
8 changes: 4 additions & 4 deletions src/knn.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ function knn{V, T <: AbstractVector}(tree::NNTree{V}, points::Vector{T}, k::Int,
dists = [Vector{DistanceType}(k) for _ in 1:n_points]
idxs = [Vector{Int}(k) for _ in 1:n_points]
for i in 1:n_points
knn_point!(tree, points[i], k, sortres, dists[i], idxs[i], skip)
knn_point!(tree, points[i], sortres, dists[i], idxs[i], skip)
end
return idxs, dists
end

function knn_point!{V, T <: Number}(tree::NNTree{V}, point::AbstractVector{T}, k::Int, sortres, dist, idx, skip)
function knn_point!{V, T <: Number}(tree::NNTree{V}, point::AbstractVector{T}, sortres, dist, idx, skip)
fill!(idx, -1)
fill!(dist, typemax(DistanceType))
_knn(tree, point, k, idx, dist, skip)
_knn(tree, point, idx, dist, skip)
sortres && heap_sort_inplace!(dist, idx)
if tree.reordered
for j in 1:k
for j in eachindex(idx)
@inbounds idx[j] = tree.indices[idx[j]]
end
end
Expand Down
4 changes: 2 additions & 2 deletions src/tree_ops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ end

# Checks the distance function and add those points that are among the k best.
# Uses a heap for fast insertion.
@inline function add_points_knn!(best_dists::Vector, best_idxs::Vector{Int},
@inline function add_points_knn!{F}(best_dists::Vector, best_idxs::Vector{Int},
tree::NNTree, index::Int, point::AbstractVector,
do_end::Bool, skip::Function)
do_end::Bool, skip::F)
for z in get_leaf_range(tree.tree_data, index)
@POINT 1
idx = tree.reordered ? z : tree.indices[z]
Expand Down
2 changes: 1 addition & 1 deletion src/utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,6 @@ end
end

# Default skip function, always false
@inline function always_false(i::Int)
@inline function always_false(::Int)
false
end

0 comments on commit e3a061e

Please sign in to comment.