Skip to content

Commit

Permalink
fix uses of deprecated syntax in Base
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Feb 1, 2016
1 parent 1e178e3 commit 0778a89
Show file tree
Hide file tree
Showing 15 changed files with 99 additions and 104 deletions.
2 changes: 1 addition & 1 deletion base/bitarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ BitArray(dims::Int...) = BitArray(dims)
typealias BitVector BitArray{1}
typealias BitMatrix BitArray{2}

call(::Type{BitVector}) = BitArray{1}(0)
(::Type{BitVector})() = BitArray{1}(0)

## utility functions ##

Expand Down
2 changes: 1 addition & 1 deletion base/dft.jl
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ type ScaledPlan{T,P,N} <: Plan{T}
pinv::Plan
ScaledPlan(p, scale) = new(p, scale)
end
call{T,P,N}(::Type{ScaledPlan{T}}, p::P, scale::N) = ScaledPlan{T,P,N}(p, scale)
(::Type{ScaledPlan{T}}){T,P,N}(p::P, scale::N) = ScaledPlan{T,P,N}(p, scale)
ScaledPlan{T}(p::Plan{T}, scale::Number) = ScaledPlan{T}(p, scale)
ScaledPlan(p::ScaledPlan, α::Number) = ScaledPlan(p.p, p.scale * α)

Expand Down
39 changes: 17 additions & 22 deletions base/fft/FFTW.jl
Original file line number Diff line number Diff line change
Expand Up @@ -454,10 +454,9 @@ end
for (Tr,Tc,fftw,lib) in ((:Float64,:Complex128,"fftw",libfftw),
(:Float32,:Complex64,"fftwf",libfftwf))

@eval function call{K,inplace,N}(::Type{cFFTWPlan{$Tc,K,inplace,N}},
X::StridedArray{$Tc,N},
Y::StridedArray{$Tc,N},
region, flags::Integer, timelimit::Real)
@eval function (::Type{cFFTWPlan{$Tc,K,inplace,N}}){K,inplace,N}(X::StridedArray{$Tc,N},
Y::StridedArray{$Tc,N},
region, flags::Integer, timelimit::Real)
direction = K
set_timelimit($Tr, timelimit)
R = copy(region)
Expand All @@ -475,10 +474,9 @@ for (Tr,Tc,fftw,lib) in ((:Float64,:Complex128,"fftw",libfftw),
return cFFTWPlan{$Tc,K,inplace,N}(plan, flags, R, X, Y)
end

@eval function call{inplace,N}(::Type{rFFTWPlan{$Tr,$FORWARD,inplace,N}},
X::StridedArray{$Tr,N},
Y::StridedArray{$Tc,N},
region, flags::Integer, timelimit::Real)
@eval function (::Type{rFFTWPlan{$Tr,$FORWARD,inplace,N}}){inplace,N}(X::StridedArray{$Tr,N},
Y::StridedArray{$Tc,N},
region, flags::Integer, timelimit::Real)
R = copy(region)
region = circshift([region...],-1) # FFTW halves last dim
set_timelimit($Tr, timelimit)
Expand All @@ -496,10 +494,9 @@ for (Tr,Tc,fftw,lib) in ((:Float64,:Complex128,"fftw",libfftw),
return rFFTWPlan{$Tr,$FORWARD,inplace,N}(plan, flags, R, X, Y)
end

@eval function call{inplace,N}(::Type{rFFTWPlan{$Tc,$BACKWARD,inplace,N}},
X::StridedArray{$Tc,N},
Y::StridedArray{$Tr,N},
region, flags::Integer, timelimit::Real)
@eval function (::Type{rFFTWPlan{$Tc,$BACKWARD,inplace,N}}){inplace,N}(X::StridedArray{$Tc,N},
Y::StridedArray{$Tr,N},
region, flags::Integer, timelimit::Real)
R = copy(region)
region = circshift([region...],-1) # FFTW halves last dim
set_timelimit($Tr, timelimit)
Expand All @@ -517,11 +514,10 @@ for (Tr,Tc,fftw,lib) in ((:Float64,:Complex128,"fftw",libfftw),
return rFFTWPlan{$Tc,$BACKWARD,inplace,N}(plan, flags, R, X, Y)
end

@eval function call{inplace,N}(::Type{r2rFFTWPlan{$Tr,ANY,inplace,N}},
X::StridedArray{$Tr,N},
Y::StridedArray{$Tr,N},
region, kinds, flags::Integer,
timelimit::Real)
@eval function (::Type{r2rFFTWPlan{$Tr,ANY,inplace,N}}){inplace,N}(X::StridedArray{$Tr,N},
Y::StridedArray{$Tr,N},
region, kinds, flags::Integer,
timelimit::Real)
R = copy(region)
knd = fix_kinds(region, kinds)
set_timelimit($Tr, timelimit)
Expand All @@ -540,11 +536,10 @@ for (Tr,Tc,fftw,lib) in ((:Float64,:Complex128,"fftw",libfftw),
end

# support r2r transforms of complex = transforms of real & imag parts
@eval function call{inplace,N}(::Type{r2rFFTWPlan{$Tc,ANY,inplace,N}},
X::StridedArray{$Tc,N},
Y::StridedArray{$Tc,N},
region, kinds, flags::Integer,
timelimit::Real)
@eval function (::Type{r2rFFTWPlan{$Tc,ANY,inplace,N}}){inplace,N}(X::StridedArray{$Tc,N},
Y::StridedArray{$Tc,N},
region, kinds, flags::Integer,
timelimit::Real)
R = copy(region)
knd = fix_kinds(region, kinds)
set_timelimit($Tr, timelimit)
Expand Down
110 changes: 55 additions & 55 deletions base/functors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,116 +11,116 @@
abstract Func{N}

immutable IdFun <: Func{1} end
call(::IdFun, x) = x
(::IdFun)(x) = x

This comment has been minimized.

Copy link
@tkelman

tkelman Feb 1, 2016

Contributor

this whole file can probably go away now?


immutable AbsFun <: Func{1} end
call(::AbsFun, x) = abs(x)
(::AbsFun)(x) = abs(x)

immutable Abs2Fun <: Func{1} end
call(::Abs2Fun, x) = abs2(x)
(::Abs2Fun)(x) = abs2(x)

immutable ExpFun <: Func{1} end
call(::ExpFun, x) = exp(x)
(::ExpFun)(x) = exp(x)

immutable LogFun <: Func{1} end
call(::LogFun, x) = log(x)
(::LogFun)(x) = log(x)

immutable ConjFun <: Func{1} end
call(::ConjFun, x) = conj(x)
(::ConjFun)(x) = conj(x)

immutable AndFun <: Func{2} end
call(::AndFun, x, y) = x & y
(::AndFun)(x, y) = x & y

immutable OrFun <: Func{2} end
call(::OrFun, x, y) = x | y
(::OrFun)(x, y) = x | y

immutable XorFun <: Func{2} end
call(::XorFun, x, y) = x $ y
(::XorFun)(x, y) = x $ y

immutable AddFun <: Func{2} end
call(::AddFun, x, y) = x + y
(::AddFun)(x, y) = x + y

immutable DotAddFun <: Func{2} end
call(::DotAddFun, x, y) = x .+ y
(::DotAddFun)(x, y) = x .+ y

immutable SubFun <: Func{2} end
call(::SubFun, x, y) = x - y
(::SubFun)(x, y) = x - y

immutable DotSubFun <: Func{2} end
call(::DotSubFun, x, y) = x .- y
(::DotSubFun)(x, y) = x .- y

immutable MulFun <: Func{2} end
call(::MulFun, x, y) = x * y
(::MulFun)(x, y) = x * y

immutable DotMulFun <: Func{2} end
call(::DotMulFun, x, y) = x .* y
(::DotMulFun)(x, y) = x .* y

immutable RDivFun <: Func{2} end
call(::RDivFun, x, y) = x / y
(::RDivFun)(x, y) = x / y

immutable DotRDivFun <: Func{2} end
call(::DotRDivFun, x, y) = x ./ y
(::DotRDivFun)(x, y) = x ./ y

immutable LDivFun <: Func{2} end
call(::LDivFun, x, y) = x \ y
(::LDivFun)(x, y) = x \ y

immutable IDivFun <: Func{2} end
call(::IDivFun, x, y) = div(x, y)
(::IDivFun)(x, y) = div(x, y)

immutable DotIDivFun <: Func{2} end
call(::DotIDivFun, x, y) = x y
(::DotIDivFun)(x, y) = x y

immutable ModFun <: Func{2} end
call(::ModFun, x, y) = mod(x, y)
(::ModFun)(x, y) = mod(x, y)

immutable RemFun <: Func{2} end
call(::RemFun, x, y) = rem(x, y)
(::RemFun)(x, y) = rem(x, y)

immutable DotRemFun <: Func{2} end
call(::DotRemFun, x, y) = x .% y
(::DotRemFun)(x, y) = x .% y

immutable PowFun <: Func{2} end
call(::PowFun, x, y) = x ^ y
(::PowFun)(x, y) = x ^ y

immutable MaxFun <: Func{2} end
call(::MaxFun, x, y) = scalarmax(x,y)
(::MaxFun)(x, y) = scalarmax(x,y)

immutable MinFun <: Func{2} end
call(::MinFun, x, y) = scalarmin(x, y)
(::MinFun)(x, y) = scalarmin(x, y)

immutable LessFun <: Func{2} end
call(::LessFun, x, y) = x < y
(::LessFun)(x, y) = x < y

immutable MoreFun <: Func{2} end
call(::MoreFun, x, y) = x > y
(::MoreFun)(x, y) = x > y

immutable DotLSFun <: Func{2} end
call(::DotLSFun, x, y) = x .<< y
(::DotLSFun)(x, y) = x .<< y

immutable DotRSFun <: Func{2} end
call(::DotRSFun, x, y) = x .>> y
(::DotRSFun)(x, y) = x .>> y

# a fallback unspecialized function object that allows code using
# function objects to not care whether they were able to specialize on
# the function value or not
immutable UnspecializedFun{N} <: Func{N}
f::Function
end
call(f::UnspecializedFun{1}, x) = f.f(x)
call(f::UnspecializedFun{2}, x, y) = f.f(x,y)
(f::UnspecializedFun{1})(x) = f.f(x)
(f::UnspecializedFun{2})(x, y) = f.f(x,y)

# Special purpose functors

immutable Predicate{F} <: Func{1}
f::F
end
call(pred::Predicate, x) = pred.f(x)::Bool
(pred::Predicate)(x) = pred.f(x)::Bool

immutable EqX{T} <: Func{1}
x::T
end

call(f::EqX, y) = f.x == y
(f::EqX)(y) = f.x == y

# More promote_op rules

Expand Down Expand Up @@ -149,29 +149,29 @@ promote_op{T<:Integer}(::PowFun, ::Type{Bool}, ::Type{T}) = Bool


immutable BitFunctorUnary{T,F} <: Func{1} end
call(::BitFunctorUnary{true, true}, p) = p | ~p # Must work for bits and ints
call(::BitFunctorUnary{false, false}, p) = p & ~p # LLVM figures them out nicely
call(::BitFunctorUnary{true, false}, p) = p
call(::BitFunctorUnary{false, true}, p) = ~p
(::BitFunctorUnary{true, true})( p) = p | ~p # Must work for bits and ints
(::BitFunctorUnary{false, false})(p) = p & ~p # LLVM figures them out nicely
(::BitFunctorUnary{true, false})(p) = p
(::BitFunctorUnary{false, true})( p) = ~p

immutable BitFunctorBinary{TT,TF,FT,FF} <: Func{2} end
call(::BitFunctorBinary{true, true, true, true }, p, q) = p | ~p
call(::BitFunctorBinary{true, true, true, false}, p, q) = p | q
call(::BitFunctorBinary{true, true, false, true }, p, q) = p | ~q
call(::BitFunctorBinary{true, true, false, false}, p, q) = p
call(::BitFunctorBinary{true, false, true, true }, p, q) = ~p | q
call(::BitFunctorBinary{true, false, true, false}, p, q) = q
call(::BitFunctorBinary{true, false, false, true }, p, q) = ~(p $ q)
call(::BitFunctorBinary{true, false, false, false}, p, q) = p & q

call(::BitFunctorBinary{false, false, false, false}, p, q) = p & ~p
call(::BitFunctorBinary{false, false, false, true }, p, q) = ~(p | q)
call(::BitFunctorBinary{false, false, true, false}, p, q) = ~p & q
call(::BitFunctorBinary{false, false, true, true }, p, q) = ~p
call(::BitFunctorBinary{false, true, false, false}, p, q) = p & ~q
call(::BitFunctorBinary{false, true, false, true }, p, q) = ~q
call(::BitFunctorBinary{false, true, true, false}, p, q) = p $ q
call(::BitFunctorBinary{false, true, true, true }, p, q) = ~(p & q)
(::BitFunctorBinary{true, true, true, true })(p, q) = p | ~p
(::BitFunctorBinary{true, true, true, false})(p, q) = p | q
(::BitFunctorBinary{true, true, false, true })(p, q) = p | ~q
(::BitFunctorBinary{true, true, false, false})(p, q) = p
(::BitFunctorBinary{true, false, true, true })(p, q) = ~p | q
(::BitFunctorBinary{true, false, true, false})(p, q) = q
(::BitFunctorBinary{true, false, false, true })(p, q) = ~(p $ q)
(::BitFunctorBinary{true, false, false, false})(p, q) = p & q

(::BitFunctorBinary{false, false, false, false})(p, q) = p & ~p
(::BitFunctorBinary{false, false, false, true })(p, q) = ~(p | q)
(::BitFunctorBinary{false, false, true, false})(p, q) = ~p & q
(::BitFunctorBinary{false, false, true, true })(p, q) = ~p
(::BitFunctorBinary{false, true, false, false})(p, q) = p & ~q
(::BitFunctorBinary{false, true, false, true })(p, q) = ~q
(::BitFunctorBinary{false, true, true, false})(p, q) = p $ q
(::BitFunctorBinary{false, true, true, true })(p, q) = ~(p & q)

# Specializations by value

Expand Down
2 changes: 1 addition & 1 deletion base/irrationals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ convert(::Type{Float16}, x::Irrational) = Float16(Float32(x))
convert{T<:Real}(::Type{Complex{T}}, x::Irrational) = convert(Complex{T}, convert(T,x))
convert{T<:Integer}(::Type{Rational{T}}, x::Irrational) = convert(Rational{T}, Float64(x))

@generated function call{T<:Union{Float32,Float64},s}(t::Type{T},c::Irrational{s},r::RoundingMode)
@generated function (t::Type{T}){T<:Union{Float32,Float64},s}(c::Irrational{s},r::RoundingMode)
f = T(big(c()),r())
:($f)
end
Expand Down
4 changes: 2 additions & 2 deletions base/operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ function afoldl(op,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,qs...)
end

immutable ElementwiseMaxFun end
call(::ElementwiseMaxFun, x, y) = max(x,y)
(::ElementwiseMaxFun)(x, y) = max(x,y)

immutable ElementwiseMinFun end
call(::ElementwiseMinFun, x, y) = min(x, y)
(::ElementwiseMinFun)(x, y) = min(x, y)

for (op,F) in ((:+,:(AddFun())), (:*,:(MulFun())), (:&,:(AndFun())), (:|,:(OrFun())),
(:$,:(XorFun())), (:min,:(ElementwiseMinFun())), (:max,:(ElementwiseMaxFun())), (:kron,:kron))
Expand Down
2 changes: 1 addition & 1 deletion base/reduce.jl
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ function count(pred, itr)
end

immutable NotEqZero <: Func{1} end
call(::NotEqZero, x) = x != 0
(::NotEqZero)(x) = x != 0

"""
countnz(A)
Expand Down
8 changes: 4 additions & 4 deletions base/refpointer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ Ref(x::Ref) = x
Ref(x::Any) = RefValue(x)
Ref{T}(x::Ptr{T}, i::Integer=1) = x + (i-1)*Core.sizeof(T)
Ref(x, i::Integer) = (i != 1 && error("Object only has one element"); Ref(x))
call{T}(::Type{Ref{T}}) = RefValue{T}() # Ref{T}()
call{T}(::Type{Ref{T}}, x) = RefValue{T}(x) # Ref{T}(x)
(::Type{Ref{T}}){T}() = RefValue{T}() # Ref{T}()
(::Type{Ref{T}}){T}(x) = RefValue{T}(x) # Ref{T}(x)
convert{T}(::Type{Ref{T}}, x) = RefValue{T}(x)

function unsafe_convert{T}(P::Type{Ptr{T}}, b::RefValue{T})
Expand Down Expand Up @@ -62,10 +62,10 @@ end
unsafe_convert{T}(::Type{Ptr{Void}}, b::RefArray{T}) = convert(Ptr{Void}, unsafe_convert(Ptr{T}, b))

# convert Arrays to pointer arrays for ccall
function call{P<:Ptr,T<:Ptr}(::Type{Ref{P}}, a::Array{T}) # Ref{P<:Ptr}(a::Array{T<:Ptr})
function (::Type{Ref{P}}){P<:Ptr,T<:Ptr}(a::Array{T}) # Ref{P<:Ptr}(a::Array{T<:Ptr})
return RefArray(a) # effectively a no-op
end
function call{P<:Ptr,T}(::Type{Ref{P}}, a::Array{T}) # Ref{P<:Ptr}(a::Array)
function (::Type{Ref{P}}){P<:Ptr,T}(a::Array{T}) # Ref{P<:Ptr}(a::Array)
if (!isbits(T) && T <: eltype(P))
# this Array already has the right memory layout for the requested Ref
return RefArray(a,1,false) # root something, so that this function is type-stable
Expand Down
2 changes: 1 addition & 1 deletion base/regex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ function ismatch(r::Regex, s::SubString, offset::Integer=0)
r.match_data)
end

call(r::Regex, s) = ismatch(r, s)
(r::Regex)(s) = ismatch(r, s)

function match(re::Regex, str::Union{SubString{UTF8String}, UTF8String}, idx::Integer, add_opts::UInt32=UInt32(0))
compile(re)
Expand Down
6 changes: 3 additions & 3 deletions base/require.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ find_in_node1_path(name) = myid()==1 ?
find_in_path(name) : remotecall_fetch(find_in_path, 1, name)

# Store list of files and their load time
package_list = (ByteString=>Float64)[]
package_list = Dict{ByteString,Float64}()
# to synchronize multiple tasks trying to require something
package_locks = (ByteString=>Any)[]
package_locks = Dict{ByteString,Any}()

# only broadcast top-level (not nested) requires and reloads
toplevel_load = true
Expand All @@ -43,7 +43,7 @@ function require(name::ByteString)
path == nothing && error("$name not found")

if myid() == 1 && toplevel_load
refs = { @spawnat p _require(path) for p in filter(x->x!=1, procs()) }
refs = Any[ @spawnat p _require(path) for p in filter(x->x!=1, procs()) ]
_require(path)
for r in refs; wait(r); end
else
Expand Down
10 changes: 5 additions & 5 deletions base/sharedarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ type SharedArray{T,N} <: DenseArray{T,N}
SharedArray(d,p,r,sn) = new(d,p,r,sn)
end

call{T,N}(::Type{SharedArray{T}}, d::NTuple{N,Int}; kwargs...) =
(::Type{SharedArray{T}}){T,N}(d::NTuple{N,Int}; kwargs...) =
SharedArray(T, d; kwargs...)
call{T}(::Type{SharedArray{T}}, d::Integer...; kwargs...) =
(::Type{SharedArray{T}}){T}(d::Integer...; kwargs...) =
SharedArray(T, d; kwargs...)
call{T}(::Type{SharedArray{T}}, m::Integer; kwargs...) =
(::Type{SharedArray{T}}){T}(m::Integer; kwargs...) =
SharedArray(T, m; kwargs...)
call{T}(::Type{SharedArray{T}}, m::Integer, n::Integer; kwargs...) =
(::Type{SharedArray{T}}){T}(m::Integer, n::Integer; kwargs...) =
SharedArray(T, m, n; kwargs...)
call{T}(::Type{SharedArray{T}}, m::Integer, n::Integer, o::Integer; kwargs...) =
(::Type{SharedArray{T}}){T}(m::Integer, n::Integer, o::Integer; kwargs...) =
SharedArray(T, m, n, o; kwargs...)

"""
Expand Down
Loading

0 comments on commit 0778a89

Please sign in to comment.