cloud-oak/ProgressBars.jl

KeyError: key 9 not found

Closed this issue · 3 comments

Hi,
I had this strange error. Could somebody tell me what's wrong?
Error:

100.0%┣████████████████████████████████████ERROR: LoadError: KeyError: key 9 not found
Stacktrace:
 [1] getindex(::Dict{Int64,Char}, ::Int64) at .\dict.jl:467
 [2] display_progress(::ProgressBar) at C:\Users\hakun\.julia\packages\ProgressBars\TlZeU\src\ProgressBars.jl:142
 [3] iterate(::ProgressBar, ::Int64) at C:\Users\hakun\.julia\packages\ProgressBars\TlZeU\src\ProgressBars.jl:181
 [4] top-level scope at D:\GitHub\judiling_test\test.jl:7
 [5] include(::String) at .\client.jl:457
 [6] top-level scope at REPL[3]:1
in expression starting at D:\GitHub\judiling_test\test.jl:6

Scripts:

using ProgressBars

iter = 1:119
iter = tqdm(iter)

for i in iter
end
khdlr commented

Hi Xuefeng,

oddly, I can't seem to reproduce the error using your script.

Could you kindly tell me the versions of Julia and ProgressBars.jl that you're running?
You can obtain them by running the following script:

using Pkg
print(VERSION)
Pkg.status("ProgressBars")

The error stack trace suggests that you are trying to iterate over a Dict object. Could you share some more code of where it's going wrong?

Cheers,
Konrad

khdlr commented

Closing, as there has been no activity for a while. Feel free to reopen

I had the same error today. Looks like the Dict EIGHT can be indexed with 9 in some edge case
image
If you can not figure out this edge case, maybe change line 330:

print(iter.output_stream, EIGHTS[part])

to

print(iter.output_stream, get(EIGHTS, part, '█')])

get is the safer option here as a default can be provided in case the key is invalid.

Version:

  • Julia v1.9.0
  • ProgressBars v1.5.0