From 8be5fdaab3ce2d55cd18566dbc321b5a56f7948a Mon Sep 17 00:00:00 2001 From: Michael Krabbe Borregaard Date: Wed, 16 Jan 2019 11:23:02 +0100 Subject: [PATCH] Totally remove StaticArrays --- NEWS.md | 2 +- REQUIRE | 1 - src/Plots.jl | 1 - src/components.jl | 22 +++++++++++----------- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/NEWS.md b/NEWS.md index 8dc206eb..4732994a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -10,7 +10,7 @@ --- ## (current master) -- changed behaviour of Vectors of length-2 and length-3 StaticVectors +- Removed StaticArrays dependency and changed behaviour of Vectors of length-2 and length-3 StaticVectors ## 0.22.1 - push PlotsDisplay just after REPLDisplay diff --git a/REQUIRE b/REQUIRE index a6b2ed11..6488f5c0 100644 --- a/REQUIRE +++ b/REQUIRE @@ -4,7 +4,6 @@ RecipesBase 0.6.0 PlotUtils 0.4.1 PlotThemes 0.1.3 Reexport -StaticArrays 0.5 FixedPointNumbers 0.3 Measures Showoff diff --git a/src/Plots.jl b/src/Plots.jl index fb93c45f..ad5afdbc 100644 --- a/src/Plots.jl +++ b/src/Plots.jl @@ -4,7 +4,6 @@ _current_plots_version = v"0.20.6" using Reexport -import StaticArrays using Dates, Printf, Statistics, Base64, LinearAlgebra, Random import SparseArrays: findnz diff --git a/src/components.jl b/src/components.jl index f338432c..5cdb66f4 100644 --- a/src/components.jl +++ b/src/components.jl @@ -1,12 +1,12 @@ -const P2 = StaticArrays.SVector{2,Float64} -const P3 = StaticArrays.SVector{3,Float64} +const P2 = NTuple{2,Float64} +const P3 = NTuple{3,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)) -nanpush!(a::AbstractVector{P3}, b) = (push!(a, P3(NaN,NaN,NaN)); push!(a, b)) -nanappend!(a::AbstractVector{P3}, b) = (push!(a, P3(NaN,NaN,NaN)); append!(a, b)) +nanpush!(a::AbstractVector{P2}, b) = (push!(a, (NaN,NaN)); push!(a, b)) +nanappend!(a::AbstractVector{P2}, b) = (push!(a, (NaN,NaN)); append!(a, b)) +nanpush!(a::AbstractVector{P3}, b) = (push!(a, (NaN,NaN,NaN)); push!(a, b)) +nanappend!(a::AbstractVector{P3}, b) = (push!(a, (NaN,NaN,NaN)); append!(a, b)) compute_angle(v::P2) = (angle = atan(v[2], v[1]); angle < 0 ? 2π - angle : angle) # ------------------------------------------------------------- @@ -104,7 +104,7 @@ function makecross(; offset = -0.5, radius = 1.0) end -from_polar(angle, dist) = P2(dist*cos(angle), dist*sin(angle)) +from_polar(angle, dist) = (dist*cos(angle), dist*sin(angle)) function makearrowhead(angle; h = 2.0, w = 0.4) tip = from_polar(angle, h) @@ -754,17 +754,17 @@ end # ----------------------------------------------------------------------- "create a BezierCurve for plotting" -mutable struct BezierCurve{T <: StaticArrays.SVector} +mutable struct BezierCurve{T <: Tuple} control_points::Vector{T} end function (bc::BezierCurve)(t::Real) - p = zero(P2) + p = zeros(2) n = length(bc.control_points)-1 for i in 0:n - p += bc.control_points[i+1] * binomial(n, i) * (1-t)^(n-i) * t^i + @. p += bc.control_points[i+1] * binomial(n, i) * (1-t)^(n-i) * t^i end - p + (p...,) end # mean(x::Real, y::Real) = 0.5*(x+y) #commented out as I cannot see this used anywhere and it overwrites a Base method with different functionality