Skip to content

Commit

Permalink
deprecate vectorised frexp
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbyrne committed Jan 4, 2017
1 parent 8563fc5 commit 2e0b001
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
10 changes: 10 additions & 0 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1470,6 +1470,16 @@ end
@deprecate (|)(A::AbstractArray, b::Number) A .| b
@deprecate (|)(A::AbstractArray, B::AbstractArray) A .| B

function frexp{T<:AbstractFloat}(A::Array{T})
depwarn("`frexp(x::Array)` is discontinued.", :frexp)
F = similar(A)
E = Array{Int}(size(A))
for (iF, iE, iA) in zip(eachindex(F), eachindex(E), eachindex(A))
F[iF], E[iE] = frexp(A[iA])
end
return (F, E)
end

# Calling promote_op is likely a bad idea, so deprecate its convenience wrapper promote_eltype_op
@deprecate promote_eltype_op(op, As...) promote_op(op, map(eltype, As)...)

Expand Down
9 changes: 0 additions & 9 deletions base/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -456,15 +456,6 @@ function frexp{T<:AbstractFloat}(x::T)
return reinterpret(T, xu), k
end

function frexp{T<:AbstractFloat}(A::Array{T})
F = similar(A)
E = Array{Int}(size(A))
for (iF, iE, iA) in zip(eachindex(F), eachindex(E), eachindex(A))
F[iF], E[iE] = frexp(A[iA])
end
return (F, E)
end

"""
modf(x)
Expand Down
12 changes: 4 additions & 8 deletions test/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -878,14 +878,10 @@ end
end

@testset "frexp" begin
@testset "$elty" for elty in (Float32, Float64)
@test frexp( convert(elty,0.5) ) == (convert(elty,0.5),0)
@test frexp( convert(elty,4.0) ) == (convert(elty,0.5),3)
@test frexp( convert(elty,10.5) )[1] convert(elty,0.65625)
@test frexp( convert(elty,10.5) )[2] == 4
@test frexp( [ convert(elty,4.0) convert(elty,10.5) ] )[1][1] convert(elty,0.5)
@test frexp( [ convert(elty,4.0) convert(elty,10.5) ] )[1][2] convert(elty,0.65625)
@test frexp( [ convert(elty,4.0) convert(elty,10.5) ] )[2] == [ 3 4 ]
@testset "$elty" for elty in (Float16, Float32, Float64)
@test frexp( convert(elty,0.5) ) == (0.5, 0)
@test frexp( convert(elty,4.0) ) == (0.5, 3)
@test frexp( convert(elty,10.5) ) == (0.65625, 4)
end
end

Expand Down

0 comments on commit 2e0b001

Please sign in to comment.