Skip to content

Commit

Permalink
remove dependency on discontinued GeometryTypes
Browse files Browse the repository at this point in the history
  • Loading branch information
daschw committed Oct 27, 2020
1 parent 8ce603d commit 5660ea9
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 18 deletions.
3 changes: 0 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ FFMPEG = "c87230d0-a227-11e9-1b43-d7ebe4e7570a"
FixedPointNumbers = "53c48c17-4a7d-5ca2-90c5-79b7896eea93"
GR = "28b8d3ca-fb5f-59d9-8090-bfdbd6d07a71"
GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326"
GeometryTypes = "4d00f742-c7ba-57c2-abde-4428a4b178cb"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
Latexify = "23fbe1c1-3f47-55db-b15f-69d7ec21a316"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down Expand Up @@ -39,12 +38,10 @@ FFMPEG = "0.2, 0.3, 0.4"
FixedPointNumbers = "0.6, 0.7, 0.8"
GR = "0.46, 0.47, 0.48, 0.49, 0.50, 0.51, 0.52"
GeometryBasics = "0.2, 0.3.1"
GeometryTypes = "0.7, 0.8"
JSON = "0.21, 1"
Latexify = "0.14"
Measures = "0.3"
NaNMath = "0.3"
PGFPlotsX = "1.2.0"
PlotThemes = "2"
PlotUtils = "1"
RecipesBase = "1"
Expand Down
2 changes: 1 addition & 1 deletion src/Plots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const _current_plots_version = VersionNumber(split(first(filter(line -> occursin

using Reexport

import GeometryTypes, GeometryBasics
import GeometryBasics
using Dates, Printf, Statistics, Base64, LinearAlgebra, Random
using SparseArrays

Expand Down
6 changes: 3 additions & 3 deletions src/components.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const P2 = GeometryTypes.Point2{Float64}
const P3 = GeometryTypes.Point3{Float64}
const P2 = GeometryBasics.Point2{Float64}
const P3 = GeometryBasics.Point3{Float64}

nanpush!(a::AbstractVector{P2}, b) = (push!(a, P2(NaN,NaN)); push!(a, b))
nanappend!(a::AbstractVector{P2}, b) = (push!(a, P2(NaN,NaN)); append!(a, b))
Expand Down Expand Up @@ -729,7 +729,7 @@ end

# -----------------------------------------------------------------------
"create a BezierCurve for plotting"
mutable struct BezierCurve{T <: GeometryTypes.Point}
mutable struct BezierCurve{T <: GeometryBasics.Point}
control_points::Vector{T}
end

Expand Down
4 changes: 2 additions & 2 deletions src/recipes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1369,8 +1369,8 @@ end
# --------------------------------------------------------------------
# Lists of tuples and GeometryBasics.Points
# --------------------------------------------------------------------
@recipe f(v::AVec{<:_Point}) = RecipesPipeline.unzip(v)
@recipe f(p::_Point) = [p]
@recipe f(v::AVec{<:GeometryBasics.Point}) = RecipesPipeline.unzip(v)
@recipe f(p::GeometryBasics.Point) = [p]

# Special case for 4-tuples in :ohlc series
@recipe f(xyuv::AVec{<:Tuple{R1, R2, R3, R4}}) where {R1, R2, R3, R4} =
Expand Down
16 changes: 9 additions & 7 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -149,18 +149,20 @@ makevec(v::T) where {T} = T[v]
maketuple(x::Real) = (x,x)
maketuple(x::Tuple{T,S}) where {T,S} = x

const _Point{N,T} = Union{GeometryTypes.Point{N,T}, GeometryBasics.Point{N,T}}
for i in 2:4
@eval begin
RecipesPipeline.unzip(v::Union{AVec{<:Tuple{Vararg{T,$i} where T}},
AVec{<:_Point{$i}}}) = $(Expr(:tuple, (:([t[$j] for t in v]) for j=1:i)...))
RecipesPipeline.unzip(
v::Union{AVec{<:Tuple{Vararg{T,$i} where T}}, AVec{<:GeometryBasics.Point{$i}}},
) = $(Expr(:tuple, (:([t[$j] for t in v]) for j=1:i)...))
end
end

RecipesPipeline.unzip(v::Union{AVec{<:_Point{N}},
AVec{<:Tuple{Vararg{T,N} where T}}}) where N = error("$N-dimensional unzip not implemented.")
RecipesPipeline.unzip(v::Union{AVec{<:_Point},
AVec{<:Tuple}}) = error("Can't unzip points of different dimensions.")
RecipesPipeline.unzip(
::Union{AVec{<:GeometryBasics.Point{N}}, AVec{<:Tuple{Vararg{T,N} where T}}}
) where N = error("$N-dimensional unzip not implemented.")
RecipesPipeline.unzip(::Union{AVec{<:GeometryBasics.Point}, AVec{<:Tuple}}) = error(
"Can't unzip points of different dimensions."
)

# given 2-element lims and a vector of data x, widen lims to account for the extrema of x
function _expand_limits(lims, x)
Expand Down
3 changes: 1 addition & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ using Test
using FileIO
using Gtk
using LibGit2
import GeometryTypes, GeometryBasics
import GeometryBasics
using Dates
using RecipesBase

Expand Down Expand Up @@ -199,7 +199,6 @@ end
[(missing,missing)], [(missing,missing,missing),("a","b","c")])
for z in zipped
@test isequal(collect(zip(Plots.unzip(z)...)), z)
@test isequal(collect(zip(Plots.unzip(GeometryTypes.Point.(z))...)), z)
@test isequal(collect(zip(Plots.unzip(GeometryBasics.Point.(z))...)), z)
end
op1 = Plots.process_clims((1.0, 2.0))
Expand Down

0 comments on commit 5660ea9

Please sign in to comment.