Skip to content

Commit 3a67a02

Browse files
rdeitsLuke Stagner
authored andcommitted
fix test errors and deprecations on julia v0.7 (#5)
* fix test errors and deprecations on julia v0.7 * comments * update CI
1 parent 5ebbfca commit 3a67a02

File tree

6 files changed

+27
-10
lines changed

6 files changed

+27
-10
lines changed

.travis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ os:
44
- linux
55
- osx
66
julia:
7-
- 0.6
7+
- 0.7
88
- nightly
9-
matrix:
10-
allow_failures:
11-
- julia: nightly
9+
# matrix:
10+
# allow_failures:
11+
# - julia: nightly
1212
notifications:
1313
email: false
1414
# uncomment the following lines to override the default test script

REQUIRE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
julia 0.5
1+
julia 0.7-alpha
22
NearestNeighbors
33
RecipesBase

src/ConcaveHull.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module ConcaveHull
22

33
using NearestNeighbors
44
using RecipesBase
5+
using LinearAlgebra
56

67
include("hull.jl")
78
include("concave_hull.jl")

src/concave_hull.jl

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ function cross2d(x,y)
22
return x[1]*y[2] - x[2]*y[1]
33
end
44

5-
function intersect_line{T<:AbstractVector,S<:AbstractVector}(ls1::NTuple{2,T},ls2::NTuple{2,S})
5+
function intersect_line(ls1::NTuple{2,T},ls2::NTuple{2,S}) where {T<:AbstractVector,S<:AbstractVector}
66
r = ls1[2] - ls1[1]
77
s = ls2[2] - ls2[1]
88
qmp = ls2[1]-ls1[1]
@@ -15,7 +15,7 @@ end
1515
function get_angle(p_pro,p_cur,p_pre)
1616
r = p_pro - p_cur
1717
p = p_pre - p_cur
18-
t = atan2(cross2d(p,r),dot(p,r))
18+
t = atan(cross2d(p,r),dot(p,r))
1919
return t > 0 ? t : t + 2pi
2020
end
2121

@@ -33,13 +33,29 @@ function intersect_hull(ls, hull)
3333
return false
3434
end
3535

36+
# In Julia v0.7 and above, indmax cannot be used with generators.
37+
# In a future version, we should be able to replace this function
38+
# with Base.argmax(f, itr)
39+
function indmax_f(f::Function, itr::AbstractVector)
40+
imax = firstindex(itr)
41+
vmax = f(itr[imax])
42+
for i in (firstindex(itr)+1):lastindex(itr)
43+
v = f(itr[i])
44+
if v > vmax
45+
vmax = v
46+
imax = i
47+
end
48+
end
49+
imax
50+
end
51+
3652
function concave_hull(tree::KDTree, k::Int)
3753
npoints = length(tree.data)
3854
k = clamp(k, 3, npoints-1)
3955
hull = Hull(eltype(tree.data), k)
4056

4157
#Start at point with largest x value
42-
i0 = indmax(v[1] for v in tree.data)
58+
i0 = indmax_f(v -> v[1], tree.data)
4359

4460
ishull = zeros(Bool,npoints)
4561
ishull[i0] = true

src/hull.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ struct Hull{T<:AbstractVector}
33
k::Int
44
end
55

6-
Hull{S<:AbstractVector}(T::Type{S},k::Int) = Hull(T[],k)
6+
Hull(::Type{T},k::Int) where {T<:AbstractVector} = Hull(T[],k)
77

88
function is_left(p0,p1,p2)
99
return ((p1[1] - p0[1]) * (p2[2] - p0[2]) - (p2[1] - p0[1]) * (p1[2] - p0[2]))

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using ConcaveHull
2-
using Base.Test
2+
using Test
33

44
# Triangle
55
p = [[-1.0,0.0],[1.0,0.0],[0.0,1.0]]

0 commit comments

Comments
 (0)