Skip to content

Commit f6ff436

Browse files
authored
Merge pull request #42 from tpapp/tp/fix-v0.7
Fixes for v0.7.
2 parents daad6eb + bfdc849 commit f6ff436

File tree

5 files changed

+22
-21
lines changed

5 files changed

+22
-21
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ sudo: false
33
os:
44
- linux
55
julia:
6-
- 0.6
6+
- 0.7
77
- nightly
88
notifications:
99
- email: false

REQUIRE

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
julia 0.6
2-
Compat 0.9.4
1+
julia 0.7-beta
32
StaticArrays

src/Contour.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ levels to trace.
100100
function contourlevels(z, n)
101101
zmin, zmax = extrema(z)
102102
dz = (zmax - zmin) / (n + 1)
103-
range(zmin + dz, dz, n)
103+
range(zmin + dz; step = dz, length = n)
104104
end
105105

106106
"""
@@ -109,8 +109,8 @@ a tuple of lists.
109109
"""
110110
function coordinates(c::Curve2{T}) where {T}
111111
N = length(c.vertices)
112-
xlist = Vector{T}(N)
113-
ylist = Vector{T}(N)
112+
xlist = Vector{T}(undef, N)
113+
ylist = Vector{T}(undef, N)
114114

115115
for (i, v) in enumerate(c.vertices)
116116
xlist[i] = v[1]
@@ -221,14 +221,14 @@ function add_vertex!(curve::Curve2{T}, pos::(Tuple{T,T}), dir::UInt8) where {T}
221221
if dir == fwd
222222
push!(curve.vertices, SVector{2,T}(pos...))
223223
else
224-
unshift!(curve.vertices, SVector{2,T}(pos...))
224+
pushfirst!(curve.vertices, SVector{2,T}(pos...))
225225
end
226226
end
227227

228228
# Given the row and column indices of the lower left
229229
# vertex, add the location where the contour level
230230
# crosses the specified edge.
231-
function interpolate(x, y, z::Matrix{T}, h::Number, xi::Int, yi::Int, edge::UInt8) where {T <: AbstractFloat}
231+
function interpolate(x, y, z::AbstractMatrix{T}, h::Number, xi::Int, yi::Int, edge::UInt8) where {T <: AbstractFloat}
232232
if edge == W
233233
y_interp = y[yi] + (y[yi + 1] - y[yi]) * (h - z[xi, yi]) / (z[xi, yi + 1] - z[xi, yi])
234234
x_interp = x[xi]

test/interface.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module InterfaceTests
22

3-
using Contour, Base.Test
3+
using Contour, Test
44

55
function setup()
66
nx, ny = 10, 10

test/verify_vertices.jl

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
module VerticesTests
22

3-
using Contour, Base.Test
3+
using Contour, Test
4+
using Base.MathConstants: π, φ
5+
using LinearAlgebra: Diagonal
46

57
# Setup test axes that will be shared among the tests
68

79
# Shift the axes so that they do not line up with
810
# integer values
911
Δ = 0.01
10-
X = collect(0:Δ:4) + π
11-
Y = collect(0:Δ:3) + φ
12+
X = collect(0:Δ:4) .+ π
13+
Y = collect(0:Δ:3) .+ φ
1214

1315
# TEST CASE 1
1416
#
@@ -61,8 +63,8 @@ lines = Contour.contour(X, Y, Z, h).lines
6163

6264
for line in lines
6365
@test length(line.vertices) == 2
64-
Δ = line.vertices[2] - line.vertices[1]
65-
@test Δ[2] / Δ[1] -1.0
66+
d = line.vertices[2] - line.vertices[1]
67+
@test d[2] / d[1] -1.0
6668
end
6769

6870
# Case 5: z_center < h
@@ -76,8 +78,8 @@ lines = Contour.contour(X, Y, Z, h).lines
7678

7779
for line in lines
7880
@test length(line.vertices) == 2
79-
Δ = line.vertices[2] - line.vertices[1]
80-
@test Δ[2] / Δ[1] 1.0
81+
d = line.vertices[2] - line.vertices[1]
82+
@test d[2] / d[1] 1.0
8183
end
8284

8385
# Case 10: z_center > h
@@ -90,8 +92,8 @@ lines = Contour.contour(X, Y, Z, h).lines
9092

9193
for line in lines
9294
@test length(line.vertices) == 2
93-
Δ = line.vertices[2] - line.vertices[1]
94-
@test Δ[2] / Δ[1] 1.0
95+
d = line.vertices[2] - line.vertices[1]
96+
@test d[2] / d[1] 1.0
9597
end
9698

9799
# Case 10: z_center < h
@@ -105,16 +107,16 @@ lines = Contour.contour(X, Y, Z, h).lines
105107

106108
for line in lines
107109
@test length(line.vertices) == 2
108-
Δ = line.vertices[2] - line.vertices[1]
109-
@test Δ[2] / Δ[1] -1.0
110+
d = line.vertices[2] - line.vertices[1]
111+
@test d[2] / d[1] -1.0
110112
end
111113

112114
# Test Known Bugs
113115

114116
# Issue #12
115117
x = float(collect(1:3));
116118
y = copy(x);
117-
z = eye(3, 3);
119+
z = Diagonal(ones(3));
118120
contours(x, y, z)
119121

120122
# Test handling of saddle points

0 commit comments

Comments
 (0)