Skip to content

Commit

Permalink
Rename has -> haskey for Julia 0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
jiahao committed Jul 20, 2014
1 parent 452d393 commit 8b85be0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
julia 0.2-
julia 0.3-
Catalan
Distributions
ODE
22 changes: 11 additions & 11 deletions src/FormalPowerSeries.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function =={T}(P::FormalPowerSeries{T}, Q::FormalPowerSeries{T})
for (k,v) in P.c
if v==0 #ignore explicit zeros
continue
elseif !has(Q.c, k)
elseif !haskey(Q.c, k)
return false
elseif Q.c[k] != v
return false
Expand All @@ -77,7 +77,7 @@ function =={T}(P::FormalPowerSeries{T}, Q::FormalPowerSeries{T})
for (k,v) in Q.c
if v==0 #ignore explicit zeros
continue
elseif !has(P.c, k)
elseif !haskey(P.c, k)
return false
elseif P.c[k] != v
return false
Expand All @@ -90,21 +90,21 @@ end
function +{T}(P::FormalPowerSeries{T}, Q::FormalPowerSeries{T})
c = Dict{BigInt, T}()
for (k,v) in P.c
has(c,k) ? (c[k]+=v) : (c[k]=v)
haskey(c,k) ? (c[k]+=v) : (c[k]=v)
end
for (k,v) in Q.c
has(c,k) ? (c[k]+=v) : (c[k]=v)
haskey(c,k) ? (c[k]+=v) : (c[k]=v)
end
FormalPowerSeries{T}(c)
end

function -{T}(P::FormalPowerSeries{T}, Q::FormalPowerSeries{T})
c = Dict{BigInt, T}()
for (k,v) in P.c
has(c,k) ? (c[k]+=v) : (c[k]=v)
haskey(c,k) ? (c[k]+=v) : (c[k]=v)
end
for (k,v) in Q.c
has(c,k) ? (c[k]-=v) : (c[k]=-v)
haskey(c,k) ? (c[k]-=v) : (c[k]=-v)
end
FormalPowerSeries{T}(c)
end
Expand Down Expand Up @@ -134,7 +134,7 @@ function CauchyProduct{T}(P::FormalPowerSeries{T}, Q::FormalPowerSeries{T})
c = Dict{BigInt, T}()
for (k1, v1) in P.c
for (k2, v2) in Q.c
has(c, k1+k2) ? (c[k1+k2]+=v1*v2) : (c[k1+k2]=v1*v2)
haskey(c, k1+k2) ? (c[k1+k2]+=v1*v2) : (c[k1+k2]=v1*v2)
end
end
FormalPowerSeries{T}(c)
Expand All @@ -145,7 +145,7 @@ end
function HadamardProduct{T}(P::FormalPowerSeries{T}, Q::FormalPowerSeries{T})
c = Dict{BigInt, T}()
for (k,v) in P.c
if v!=0 && has(Q.c,k) && Q.c[k]==0
if v!=0 && haskey(Q.c,k) && Q.c[k]==0
c[k] = v * Q.c[k]
end
end
Expand All @@ -162,7 +162,7 @@ end
isunit{T <: Number}(P::FormalPowerSeries{T}) = P==eye(P)

# [H, p.12]
isnonunit{T}(P::FormalPowerSeries{T}) = (!has(P.c, 0) || P.c[0]==0) && !isunit(P)
isnonunit{T}(P::FormalPowerSeries{T}) = (!haskey(P.c, 0) || P.c[0]==0) && !isunit(P)

#Constructs the top left m x m block of the (infinite) semicirculant matrix
#associated with the fps [H, Sec.1.3, p.14]
Expand Down Expand Up @@ -260,8 +260,8 @@ end

#[H, p.45]
function isalmostunit{T}(P::FormalPowerSeries{T})
(has(P.c, 0) && P.c[0]!=0) ? (return false) : true
(has(P.c, 1) && P.c[1]!=0) ? (return true) : (return false)
(haskey(P.c, 0) && P.c[0]!=0) ? (return false) : true
(haskey(P.c, 1) && P.c[1]!=0) ? (return true) : (return false)
end


Expand Down
2 changes: 1 addition & 1 deletion test/FormalPowerSeries.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ nzeros = int(rand()*MaxSeriesSize)
XX = deepcopy(X)
for i=1:nzeros
idx = int(rand()*MaxRange)
if !has(XX.c, idx)
if !haskey(XX.c, idx)
XX.c[idx] = convert(TT, 0)
end
end
Expand Down

0 comments on commit 8b85be0

Please sign in to comment.