Skip to content

Commit

Permalink
Merge pull request JuliaLang#92 from skumagai/dictupdate
Browse files Browse the repository at this point in the history
(K=>V)[] => Dict{K,V}[] (JuliaLang#6739)
  • Loading branch information
johnmyleswhite committed Oct 8, 2014
2 parents 22d464b + dbc3ced commit 74e8095
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/counts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ proportions(x::IntegerArray, y::IntegerArray, k::Integer, wv::WeightVec) = propo
## auxiliary functions

function _normalize_countmap{T}(cm::Dict{T}, s::Real)
r = (T=>Float64)[]
r = Dict{T,Float64}()
for (k, c) in cm
r[k] = c / s
end
Expand Down Expand Up @@ -189,8 +189,8 @@ function addcounts!{T,W}(cm::Dict{T}, x::AbstractArray{T}, wv::WeightVec{W})
return cm
end

countmap{T}(x::AbstractArray{T}) = addcounts!((T=>Int)[], x)
countmap{T,W}(x::AbstractArray{T}, wv::WeightVec{W}) = addcounts!((T=>W)[], x, wv)
countmap{T}(x::AbstractArray{T}) = addcounts!(Dict{T,Int}(), x)
countmap{T,W}(x::AbstractArray{T}, wv::WeightVec{W}) = addcounts!(Dict{T,W}(), x, wv)

proportionmap(x::AbstractArray) = _normalize_countmap(countmap(x), length(x))
proportionmap(x::AbstractArray, wv::WeightVec) = _normalize_countmap(countmap(x, wv), sum(wv))
Expand Down
4 changes: 2 additions & 2 deletions src/misc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ end
# findat (get positions (within a) for elements in b)

function indexmap{T}(a::AbstractArray{T})
d = (T=>Int)[]
d = Dict{T,Int}()
for i = 1 : length(a)
@inbounds k = a[i]
if !haskey(d, k)
Expand All @@ -74,7 +74,7 @@ function indexmap{T}(a::AbstractArray{T})
end

function levelsmap{T}(a::AbstractArray{T})
d = (T=>Int)[]
d = Dict{T,Int}()
index = 1
for i = 1 : length(a)
@inbounds k = a[i]
Expand Down
4 changes: 2 additions & 2 deletions src/scalarstats.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ end
# compute mode over arbitrary array
function mode{T}(a::AbstractArray{T})
isempty(a) && error("mode: input array cannot be empty.")
cnts = (T=>Int)[]
cnts = Dict{T,Int}()
# first element
mc = 1
mv = a[1]
Expand All @@ -119,7 +119,7 @@ end

function modes{T}(a::AbstractArray{T})
isempty(a) && error("modes: input array cannot be empty.")
cnts = (T=>Int)[]
cnts = Dict{T,Int}()
# first element
mc = 1
cnts[a[1]] = 1
Expand Down

0 comments on commit 74e8095

Please sign in to comment.