Skip to content

Commit

Permalink
fix deprecations in test
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbyrne committed May 31, 2018
1 parent 71b906f commit f6a92fc
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 60 deletions.
24 changes: 12 additions & 12 deletions test/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,10 @@ let x = [1, 3.2, 4.7],
@test sin.(α) == broadcast(sin, α)
@test sin.(3.2) == broadcast(sin, 3.2) == sin(3.2)
@test factorial.(3) == broadcast(factorial, 3)
@test atan2.(x, y) == broadcast(atan2, x, y)
@test atan2.(x, y') == broadcast(atan2, x, y')
@test atan2.(x, α) == broadcast(atan2, x, α)
@test atan2.(α, y') == broadcast(atan2, α, y')
@test atan.(x, y) == broadcast(atan, x, y)
@test atan.(x, y') == broadcast(atan, x, y')
@test atan.(x, α) == broadcast(atan, x, α)
@test atan.(α, y') == broadcast(atan, α, y')
end

# issue 14725
Expand Down Expand Up @@ -215,13 +215,13 @@ end
# PR #17300: loop fusion
@test (x->x+1).((x->x+2).((x->x+3).(1:10))) == 7:16
let A = [sqrt(i)+j for i = 1:3, j=1:4]
@test atan2.(log.(A), sum(A, dims=1)) == broadcast(atan2, broadcast(log, A), sum(A, dims=1))
@test atan.(log.(A), sum(A, dims=1)) == broadcast(atan, broadcast(log, A), sum(A, dims=1))
end
let x = sin.(1:10)
@test atan2.((x->x+1).(x), (x->x+2).(x)) == broadcast(atan2, x.+1, x.+2)
@test sin.(atan2.([x.+1,x.+2]...)) == sin.(atan2.(x.+1 ,x.+2)) == @. sin(atan2(x+1,x+2))
@test sin.(atan2.(x, 3.7)) == broadcast(x -> sin(atan2(x,3.7)), x)
@test atan2.(x, 3.7) == broadcast(x -> atan2(x,3.7), x) == broadcast(atan2, x, 3.7)
@test atan.((x->x+1).(x), (x->x+2).(x)) == broadcast(atan, x.+1, x.+2)
@test sin.(atan.([x.+1,x.+2]...)) == sin.(atan.(x.+1 ,x.+2)) == @. sin(atan(x+1,x+2))
@test sin.(atan.(x, 3.7)) == broadcast(x -> sin(atan(x,3.7)), x)
@test atan.(x, 3.7) == broadcast(x -> atan(x,3.7), x) == broadcast(atan, x, 3.7)
end
# Use side effects to check for loop fusion.
let g = Int[]
Expand All @@ -235,11 +235,11 @@ end
# fusion with splatted args:
let x = sin.(1:10), a = [x]
@test cos.(x) == cos.(a...)
@test atan2.(x,x) == atan2.(a..., a...) == atan2.([x, x]...)
@test atan2.(x, cos.(x)) == atan2.(a..., cos.(x)) == broadcast(atan2, x, cos.(a...)) == broadcast(atan2, a..., cos.(a...))
@test atan.(x,x) == atan.(a..., a...) == atan.([x, x]...)
@test atan.(x, cos.(x)) == atan.(a..., cos.(x)) == broadcast(atan, x, cos.(a...)) == broadcast(atan, a..., cos.(a...))
@test ((args...)->cos(args[1])).(x) == cos.(x) == ((y,args...)->cos(y)).(x)
end
@test atan2.(3, 4) == atan2(3, 4) == (() -> atan2(3, 4)).()
@test atan.(3, 4) == atan(3, 4) == (() -> atan(3, 4)).()
# fusion with keyword args:
let x = [1:4;]
f17300kw(x; y=0) = x + y
Expand Down
2 changes: 1 addition & 1 deletion test/fastmath.jl
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ end
end
end
for f in (:+, :-, :*, :/, :%, :(==), :!=, :<, :<=, :>, :>=, :^,
:atan2, :hypot, :max, :min, :log)
:atan, :hypot, :max, :min, :log)
@eval begin
@test @fastmath($f($half, $third)) $f($half, $third)
@test @fastmath($f($third, $half)) $f($third, $half)
Expand Down
88 changes: 44 additions & 44 deletions test/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ end
@test asin(x) asin(big(x))
@test asinh(x) asinh(big(x))
@test atan(x) atan(big(x))
@test atan2(x,y) atan2(big(x),big(y))
@test atan(x,y) atan(big(x),big(y))
@test atanh(x) atanh(big(x))
@test cbrt(x) cbrt(big(x))
@test cos(x) cos(big(x))
Expand Down Expand Up @@ -172,7 +172,7 @@ end
@test isequal(acosh(T(1)), T(0))
@test asin(T(1)) T(pi)/2 atol=eps(T)
@test atan(T(1)) T(pi)/4 atol=eps(T)
@test atan2(T(1),T(1)) T(pi)/4 atol=eps(T)
@test atan(T(1),T(1)) T(pi)/4 atol=eps(T)
@test isequal(cbrt(T(0)), T(0))
@test isequal(cbrt(T(1)), T(1))
@test isequal(cbrt(T(1000000000)), T(1000))
Expand Down Expand Up @@ -211,7 +211,7 @@ end
@test cbrt(x^3) x
@test asinh(sinh(x)) x
@test atan(tan(x)) x
@test atan2(x,y) atan(x/y)
@test atan(x,y) atan(x/y)
@test atanh(tanh(x)) x
@test cos(acos(x)) x
@test cosh(acosh(1+x)) 1+x
Expand Down Expand Up @@ -612,7 +612,7 @@ end

@testset "vectorization of 2-arg functions" begin
binary_math_functions = [
copysign, flipsign, log, atan2, hypot, max, min,
copysign, flipsign, log, atan, hypot, max, min,
beta, lbeta,
]
@testset "$f" for f in binary_math_functions
Expand Down Expand Up @@ -788,58 +788,58 @@ end
@test atan(1.7581305072934137) 1.053644580517088
end
end
@testset "atan2" begin
@testset "atan" begin
for T in (Float32, Float64)
@test isnan_type(T, atan2(T(NaN), T(NaN)))
@test isnan_type(T, atan2(T(NaN), T(0.1)))
@test isnan_type(T, atan2(T(0.1), T(NaN)))
@test isnan_type(T, atan(T(NaN), T(NaN)))
@test isnan_type(T, atan(T(NaN), T(0.1)))
@test isnan_type(T, atan(T(0.1), T(NaN)))
r = T(randn())
absr = abs(r)
# y zero
@test atan2(T(r), one(T)) === atan(T(r))
@test atan2(zero(T), absr) === zero(T)
@test atan2(-zero(T), absr) === -zero(T)
@test atan2(zero(T), -absr) === T(pi)
@test atan2(-zero(T), -absr) === -T(pi)
@test atan(T(r), one(T)) === atan(T(r))
@test atan(zero(T), absr) === zero(T)
@test atan(-zero(T), absr) === -zero(T)
@test atan(zero(T), -absr) === T(pi)
@test atan(-zero(T), -absr) === -T(pi)
# x zero and y not zero
@test atan2(one(T), zero(T)) === T(pi)/2
@test atan2(-one(T), zero(T)) === -T(pi)/2
@test atan(one(T), zero(T)) === T(pi)/2
@test atan(-one(T), zero(T)) === -T(pi)/2
# isinf(x) == true && isinf(y) == true
@test atan2(T(Inf), T(Inf)) === T(pi)/4 # m == 0 (see atan2 code)
@test atan2(-T(Inf), T(Inf)) === -T(pi)/4 # m == 1
@test atan2(T(Inf), -T(Inf)) === 3*T(pi)/4 # m == 2
@test atan2(-T(Inf), -T(Inf)) === -3*T(pi)/4 # m == 3
@test atan(T(Inf), T(Inf)) === T(pi)/4 # m == 0 (see atan code)
@test atan(-T(Inf), T(Inf)) === -T(pi)/4 # m == 1
@test atan(T(Inf), -T(Inf)) === 3*T(pi)/4 # m == 2
@test atan(-T(Inf), -T(Inf)) === -3*T(pi)/4 # m == 3
# isinf(x) == true && isinf(y) == false
@test atan2(absr, T(Inf)) === zero(T) # m == 0
@test atan2(-absr, T(Inf)) === -zero(T) # m == 1
@test atan2(absr, -T(Inf)) === T(pi) # m == 2
@test atan2(-absr, -T(Inf)) === -T(pi) # m == 3
@test atan(absr, T(Inf)) === zero(T) # m == 0
@test atan(-absr, T(Inf)) === -zero(T) # m == 1
@test atan(absr, -T(Inf)) === T(pi) # m == 2
@test atan(-absr, -T(Inf)) === -T(pi) # m == 3
# isinf(y) == true && isinf(x) == false
@test atan2(T(Inf), absr) === T(pi)/2
@test atan2(-T(Inf), absr) === -T(pi)/2
@test atan2(T(Inf), -absr) === T(pi)/2
@test atan2(-T(Inf), -absr) === -T(pi)/2
@test atan(T(Inf), absr) === T(pi)/2
@test atan(-T(Inf), absr) === -T(pi)/2
@test atan(T(Inf), -absr) === T(pi)/2
@test atan(-T(Inf), -absr) === -T(pi)/2
# |y/x| above high threshold
atanpi = T(1.5707963267948966)
@test atan2(T(2.0^61), T(1.0)) === atanpi # m==0
@test atan2(-T(2.0^61), T(1.0)) === -atanpi # m==1
@test atan2(T(2.0^61), -T(1.0)) === atanpi # m==2
@test atan2(-T(2.0^61), -T(1.0)) === -atanpi # m==3
@test atan2(-T(Inf), -absr) === -T(pi)/2
@test atan(T(2.0^61), T(1.0)) === atanpi # m==0
@test atan(-T(2.0^61), T(1.0)) === -atanpi # m==1
@test atan(T(2.0^61), -T(1.0)) === atanpi # m==2
@test atan(-T(2.0^61), -T(1.0)) === -atanpi # m==3
@test atan(-T(Inf), -absr) === -T(pi)/2
# |y|/x between 0 and low threshold
@test atan2(T(2.0^-61), -T(1.0)) === T(pi) # m==2
@test atan2(-T(2.0^-61), -T(1.0)) === -T(pi) # m==3
@test atan(T(2.0^-61), -T(1.0)) === T(pi) # m==2
@test atan(-T(2.0^-61), -T(1.0)) === -T(pi) # m==3
# y/x is "safe" ("arbitrary values", just need to hit the branch)
_ATAN2_PI_LO(::Type{Float32}) = -8.7422776573f-08
_ATAN2_PI_LO(::Type{Float64}) = 1.2246467991473531772E-16
@test atan2(T(5.0), T(2.5)) === atan(abs(T(5.0)/T(2.5)))
@test atan2(-T(5.0), T(2.5)) === -atan(abs(-T(5.0)/T(2.5)))
@test atan2(T(5.0), -T(2.5)) === T(pi)-(atan(abs(T(5.0)/-T(2.5)))-_ATAN2_PI_LO(T))
@test atan2(-T(5.0), -T(2.5)) === -(T(pi)-atan(abs(-T(5.0)/-T(2.5)))-_ATAN2_PI_LO(T))
@test atan2(T(1235.2341234), T(2.5)) === atan(abs(T(1235.2341234)/T(2.5)))
@test atan2(-T(1235.2341234), T(2.5)) === -atan(abs(-T(1235.2341234)/T(2.5)))
@test atan2(T(1235.2341234), -T(2.5)) === T(pi)-(atan(abs(T(1235.2341234)/-T(2.5)))-_ATAN2_PI_LO(T))
@test atan2(-T(1235.2341234), -T(2.5)) === -(T(pi)-(atan(abs(-T(1235.2341234)/T(2.5)))-_ATAN2_PI_LO(T)))
_ATAN_PI_LO(::Type{Float32}) = -8.7422776573f-08
_ATAN_PI_LO(::Type{Float64}) = 1.2246467991473531772E-16
@test atan(T(5.0), T(2.5)) === atan(abs(T(5.0)/T(2.5)))
@test atan(-T(5.0), T(2.5)) === -atan(abs(-T(5.0)/T(2.5)))
@test atan(T(5.0), -T(2.5)) === T(pi)-(atan(abs(T(5.0)/-T(2.5)))-_ATAN_PI_LO(T))
@test atan(-T(5.0), -T(2.5)) === -(T(pi)-atan(abs(-T(5.0)/-T(2.5)))-_ATAN_PI_LO(T))
@test atan(T(1235.2341234), T(2.5)) === atan(abs(T(1235.2341234)/T(2.5)))
@test atan(-T(1235.2341234), T(2.5)) === -atan(abs(-T(1235.2341234)/T(2.5)))
@test atan(T(1235.2341234), -T(2.5)) === T(pi)-(atan(abs(T(1235.2341234)/-T(2.5)))-_ATAN_PI_LO(T))
@test atan(-T(1235.2341234), -T(2.5)) === -(T(pi)-(atan(abs(-T(1235.2341234)/T(2.5)))-_ATAN_PI_LO(T)))
end
end

Expand Down
4 changes: 2 additions & 2 deletions test/mpfr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -696,9 +696,9 @@ end
# hypot
@test hypot(BigFloat(3), BigFloat(4)) == 5

# atan2
# atan
setprecision(53) do
@test atan2(12,2) == atan2(BigFloat(12), BigFloat(2))
@test atan(12,2) == atan(BigFloat(12), BigFloat(2))
end
end
@testset "ldexp" begin
Expand Down
2 changes: 1 addition & 1 deletion test/numbers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2214,7 +2214,7 @@ end
end
end
end
@testset "angle(z::Real) = atan2(zero(z), z)" begin
@testset "angle(z::Real) = atan(zero(z), z)" begin
#function only returns two values, depending on sign
@test angle(10) == 0.0
@test angle(-10) == 3.141592653589793
Expand Down

0 comments on commit f6a92fc

Please sign in to comment.