Skip to content

Commit 9ec1b5a

Browse files
committed
wip: drop staticArrays as a hard requirement
1 parent f41fd84 commit 9ec1b5a

File tree

4 files changed

+11
-14
lines changed

4 files changed

+11
-14
lines changed

Project.toml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,15 @@ name = "Contour"
22
uuid = "d38c429a-6771-53c6-b99e-75d170b6e991"
33
version = "0.5.7"
44

5-
[deps]
6-
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
7-
85
[compat]
9-
StaticArrays = "0.10,0.11,0.12, 1.0"
106
julia = "0.7, 1"
117

128
[extras]
139
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1410
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
11+
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
1512
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
1613
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
1714

1815
[targets]
19-
test = ["LinearAlgebra", "StatsBase", "Test", "OffsetArrays"]
16+
test = ["LinearAlgebra", "StatsBase", "Test", "OffsetArrays", "StaticArrays"]

src/Contour.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export
1717
import Base: push!, length, eltype, show
1818

1919
struct Curve2{T}
20-
vertices::Vector{SVector{2,T}}
20+
vertices::Vector{NTuple{2,T}}
2121
end
2222
Curve2(::Type{T}) where {T} = Curve2(SVector{2,T}[])
2323
show(io::IO, ::MIME"text/plain", c2::Curve2) = write(io, "$(typeof(c2))\n with $(length(c2.vertices)-1) vertices")
@@ -273,7 +273,7 @@ function trace_contour(x, y, z, h::Number, cells::Dict)
273273
yi_range = first(y_ax):last(y_ax)-1
274274

275275

276-
VT = SVector{2,promote_type(map(eltype, (x, y, z))...)}
276+
VT = NTuple{2,promote_type(map(eltype, (x, y, z))...)}
277277

278278
# When tracing out contours, this algorithm picks an arbitrary
279279
# starting cell, then first follows the contour in one direction

src/interpolate.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function interpolate(x, y, z::AbstractMatrix, h::Number, ind, edge::UInt8, ::Typ
1717
x_interp = x[xi] + (x[xi + 1] - x[xi]) * (h - z[xi, yi]) / (z[xi + 1, yi] - z[xi, yi])
1818
end
1919

20-
return VT(x_interp, y_interp)
20+
return VT <: Tuple ? (x_interp, y_interp) : VT(x_interp, y_interp)
2121
end
2222

2323
function interpolate(x::AbstractRange, y::AbstractRange, z::AbstractMatrix, h::Number, ind, edge::UInt8, ::Type{VT}) where {VT}
@@ -36,7 +36,7 @@ function interpolate(x::AbstractRange, y::AbstractRange, z::AbstractMatrix, h::N
3636
x_interp = x[xi] + step(x) * (h - z[xi, yi]) / (z[xi + 1, yi] - z[xi, yi])
3737
end
3838

39-
return VT(x_interp, y_interp)
39+
return VT <: Tuple ? (x_interp, y_interp) : VT(x_interp, y_interp)
4040
end
4141

4242
function interpolate(x::AbstractMatrix, y::AbstractMatrix, z::AbstractMatrix, h::Number, ind, edge::UInt8, ::Type{VT}) where {VT}
@@ -59,5 +59,5 @@ function interpolate(x::AbstractMatrix, y::AbstractMatrix, z::AbstractMatrix, h:
5959
x_interp = x[xi,yi] + Δ[2]
6060
end
6161

62-
return VT(x_interp, y_interp)
62+
return VT <: Tuple ? (x_interp, y_interp) : VT(x_interp, y_interp)
6363
end

test/verify_vertices.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ lines = Contour.contour(X, Y, Z, h).lines
6565

6666
for line in lines
6767
@test length(line.vertices) == 2
68-
d = line.vertices[2] - line.vertices[1]
68+
d = line.vertices[2] .- line.vertices[1]
6969
@test d[2] / d[1] -1.0
7070
end
7171

@@ -80,7 +80,7 @@ lines = Contour.contour(X, Y, Z, h).lines
8080

8181
for line in lines
8282
@test length(line.vertices) == 2
83-
d = line.vertices[2] - line.vertices[1]
83+
d = line.vertices[2] .- line.vertices[1]
8484
@test d[2] / d[1] 1.0
8585
end
8686

@@ -94,7 +94,7 @@ lines = Contour.contour(X, Y, Z, h).lines
9494

9595
for line in lines
9696
@test length(line.vertices) == 2
97-
d = line.vertices[2] - line.vertices[1]
97+
d = line.vertices[2] .- line.vertices[1]
9898
@test d[2] / d[1] 1.0
9999
end
100100

@@ -109,7 +109,7 @@ lines = Contour.contour(X, Y, Z, h).lines
109109

110110
for line in lines
111111
@test length(line.vertices) == 2
112-
d = line.vertices[2] - line.vertices[1]
112+
d = line.vertices[2] .- line.vertices[1]
113113
@test d[2] / d[1] -1.0
114114
end
115115

0 commit comments

Comments
 (0)