guo-yong-zhi / WordCloud.jl

word cloud generator in julia
MIT License
105 stars 2 forks source link

Issue with short wordlists? #2

Closed carstenbauer closed 3 years ago

carstenbauer commented 3 years ago

Trying to run

words = ["multiple", "dispatch", "generic", "programming", "parallel", "computing", "high", "performance", "linear", "algebra"]
weights = rand(length(words)) .^ 2 .* 100 .+ 30
wc = wordcloud(words, weights)
generate!(wc)

leads to

(scheme, length(colors)) = (:Pastel2_5, 5)
angles = (0, 90, 45)
maskcolor = 0.0
set minfontsize to 8.0
groundoccupied = 320185
length(words) = 10
(sc, tg, tg / ground_size) = (223.69490766953797, 133760.0, 0.4177584833767978)
(sc, tg, tg / ground_size) = (224.71148861392473, 206258.0, 0.6441838312225745)
set fillingrate to 0.65, with scale=224.71148861392473
#1. scale = 224.71148861392473
(nepoch, patient) = (1000, 10)
MethodError: no method matching getindex(::Set{Int64}, ::Int64)

Stacktrace:
 [1] (::Combinatorics.var"#9#11"{Set{Int64}})(::Int64) at ./none:0
 [2] iterate at ./generator.jl:47 [inlined]
 [3] collect at ./array.jl:686 [inlined]
 [4] reorder at /Users/crstnbr/.julia/packages/Combinatorics/Udg6X/src/combinations.jl:48 [inlined]
 [5] iterate at ./generator.jl:47 [inlined]
 [6] collect(::Base.Generator{Combinatorics.Combinations,Combinatorics.var"#reorder#10"{Set{Int64}}}) at ./array.jl:686
 [7] |> at ./operators.jl:834 [inlined]
 [8] listcollision_native(::Array{Any,1}, ::WordCloud.QTree.ShiftedQtree{Array{WordCloud.QTree.PaddedMat{Array{UInt8,2}},1}}, ::Set{Int64}; collist::Array{Pair{Tuple{Int64,Int64},Tuple{Int64,Int64,Int64}},1}, queue::Array{Tuple{Int64,Int64,Int64},1}, at::Tuple{Int64,Int64,Int64}) at /Users/crstnbr/.julia/packages/WordCloud/JZsfo/src/qtreetools.jl:124
 [9] #listcollision#27 at /Users/crstnbr/.julia/packages/WordCloud/JZsfo/src/qtreetools.jl:367 [inlined]
 [10] trainepoch_EM2!(::Array{Any,1}, ::WordCloud.QTree.ShiftedQtree{Array{WordCloud.QTree.PaddedMat{Array{UInt8,2}},1}}; memory::WordCloud.LRU{Int64,WordCloud.IntMap{Int64}}, optimiser::Function, queue::Array{Tuple{Int64,Int64,Int64},1}, collpool::Array{Pair{Tuple{Int64,Int64},Tuple{Int64,Int64,Int64}},1}) at /Users/crstnbr/.julia/packages/WordCloud/JZsfo/src/train.jl:202
 [11] train!(::Array{Any,1}, ::WordCloud.QTree.ShiftedQtree{Array{WordCloud.QTree.PaddedMat{Array{UInt8,2}},1}}, ::Int64; trainer::typeof(WordCloud.trainepoch_EM2!), patient::Int64, callbackstep::Int64, callbackfun::WordCloud.var"#46#48", kargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /Users/crstnbr/.julia/packages/WordCloud/JZsfo/src/train.jl:376
 [12] train!(::Array{Any,1}, ::WordCloud.QTree.ShiftedQtree{Array{WordCloud.QTree.PaddedMat{Array{UInt8,2}},1}}, ::Int64) at /Users/crstnbr/.julia/packages/WordCloud/JZsfo/src/train.jl:359 (repeats 2 times)
 [13] generate!(::wordcloud; retry::Int64, krags::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /Users/crstnbr/.julia/packages/WordCloud/JZsfo/src/interface.jl:323
 [14] generate!(::wordcloud) at /Users/crstnbr/.julia/packages/WordCloud/JZsfo/src/interface.jl:313
 [15] top-level scope at In[29]:5
 [16] include_string(::Function, ::Module, ::String, ::String) at ./loading.jl:1091

When I make the list longer by, for example, repeat(words, 3) it works fine.

guo-yong-zhi commented 3 years ago

Ok, I fixed it at v0.3.3. Please retry.

carstenbauer commented 3 years ago

Works fine on #master. Thanks for fixing it and great package!