From f4858961c04656c204d67786c6ae6492c7702a29 Mon Sep 17 00:00:00 2001 From: Keith Campbell Date: Thu, 11 May 2017 21:10:35 -0400 Subject: [PATCH] update Float and Array{T} to pass 0.6 tests --- src/Bezier.jl | 10 +++++----- test/runtests.jl | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Bezier.jl b/src/Bezier.jl index d5a398a..07e19fd 100644 --- a/src/Bezier.jl +++ b/src/Bezier.jl @@ -3,7 +3,7 @@ module Bezier export bezier # Linear interpolation between two points -function bezier{T<:FloatingPoint}(t::Real, P1::Array{T}, P2::Array{T}) +function bezier{T<:AbstractFloat}(t::Real, P1::Array{T}, P2::Array{T}) if 0 ≤ t ≤ 1 return P1 + t * (P2 - P1) else @@ -14,12 +14,12 @@ function bezier{T<:FloatingPoint}(t::Real, P1::Array{T}, P2::Array{T}) end # Higher-order interpolation -function bezier{T<:FloatingPoint}(t::Real, points::Vector{Vector{T}}) +function bezier{T<:AbstractFloat}(t::Real, points::Vector{Vector{T}}) dimension = size(points, 1) if dimension ≤ 1 return points else - interpolated_points = Array(Vector{T}, dimension - 1) + interpolated_points = Array{Vector{T}}(dimension - 1) for i in 2:dimension interpolated_points[i - 1] = bezier(t, points[i - 1], points[i]) end @@ -28,12 +28,12 @@ function bezier{T<:FloatingPoint}(t::Real, points::Vector{Vector{T}}) end # Each row of the matrix is a point -function bezier{T<:FloatingPoint}(t::Real, points::Matrix{T}) +function bezier{T<:AbstractFloat}(t::Real, points::Matrix{T}) rows, cols = size(points) if rows ≤ 1 return points else - interpolated_points = Array(T, rows - 1, cols) + interpolated_points = Array{T}(rows - 1, cols) for r in 2:rows interpolated_point = bezier(t, points[r - 1, :], points[r, :]) for c in 1:cols diff --git a/test/runtests.jl b/test/runtests.jl index 82a7a72..21d140a 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -19,7 +19,7 @@ P22 = [2. 3] @test [2 3] == bezier(1, P21, P22) # quadratic interpolation with vector of vectors -@test Array[[10, 5]] == bezier(0.5, Vector{FloatingPoint}[[0., 0], [10, 10], [20, 0]]) +@test Array[[10, 5]] == bezier(0.5, Vector{Float64}[[0., 0], [10, 10], [20, 0]]) # quadratic interpolation with matrix @test [[10 5];] == bezier(0.5, [[0. 0]; [10 10]; [20 0]]) @@ -28,7 +28,7 @@ P22 = [2. 3] # boundary checks @test_throws DomainError bezier(prevfloat(0.), [0., 1], [2., 3]) @test_throws DomainError bezier(nextfloat(1.), [0., 1], [2., 3]) -@test_throws DomainError bezier(prevfloat(0.), Vector{FloatingPoint}[[0., 1], [2, 3]]) -@test_throws DomainError bezier(nextfloat(1.), Vector{FloatingPoint}[[0., 1], [2, 3]]) +@test_throws DomainError bezier(prevfloat(0.), Vector{Float64}[[0., 1], [2, 3]]) +@test_throws DomainError bezier(nextfloat(1.), Vector{Float64}[[0., 1], [2, 3]]) @test_throws DomainError bezier(prevfloat(0.), [0. 1; 2 3]) @test_throws DomainError bezier(nextfloat(1.), [0. 1; 2 3])