NPZ.jl
NPZ.jl copied to clipboard
Error handling empty array
Although it's weird to store an empty array in the npz file (I forgot to delete that field :cry:), NPZ.jl will throw an error when it trys to unpack an npz file with empty array.
Steps to reproduce
- create an npz file with empty field
In [4]: a=np.load("aba.npz")
In [5]: a["a"]
Out[5]: array([], dtype=float64)
- in julia
julia> npzread("aba.npz")
ERROR: EOFError: read end of file
Stacktrace:
[1] _read(f::ZipFile.ReadableFile, a::Vector{UInt8})
@ ZipFile ~/.julia/packages/ZipFile/evaHP/src/ZipFile.jl:519
[2] read!
@ ~/.julia/packages/ZipFile/evaHP/src/ZipFile.jl:483 [inlined]
[3] readheader(f::ZipFile.ReadableFile)
@ NPZ ~/.julia/packages/NPZ/uRQRY/src/NPZ.jl:210
[4] npzreadarray(f::ZipFile.ReadableFile)
@ NPZ ~/.julia/packages/NPZ/uRQRY/src/NPZ.jl:243
[5] (::NPZ.var"#4#7")(f::ZipFile.ReadableFile)
@ NPZ ./none:0
[6] iterate
@ ./generator.jl:47 [inlined]
[7] _all(f::Base.var"#318#320", itr::Base.Generator{Base.Iterators.Filter{NPZ.var"#5#8"{Vector{String}}, Vector{ZipFile.ReadableFile}}, NPZ.var"#4#7"}, #unused#::Colon)
@ Base ./reduce.jl:1156
[8] all
@ ./reduce.jl:1152 [inlined]
[9] Dict(kv::Base.Generator{Base.Iterators.Filter{NPZ.var"#5#8"{Vector{String}}, Vector{ZipFile.ReadableFile}}, NPZ.var"#4#7"})
@ Base ./dict.jl:131
[10] npzread (repeats 2 times)
@ ~/.julia/packages/NPZ/uRQRY/src/NPZ.jl:311 [inlined]
[11] npzread(::String)
@ NPZ ~/.julia/packages/NPZ/uRQRY/src/NPZ.jl:295
[12] top-level scope
@ REPL[1]:1
caused by: EOFError: read end of file
Stacktrace:
[1] _read(f::ZipFile.ReadableFile, a::Vector{Float64})
@ ZipFile ~/.julia/packages/ZipFile/evaHP/src/ZipFile.jl:519
[2] _npzreadarray(f::ZipFile.ReadableFile, hdr::NPZ.Header{Float64, 1, typeof(ltoh)})
@ NPZ ~/.julia/packages/NPZ/uRQRY/src/NPZ.jl:0
[3] npzreadarray(f::ZipFile.ReadableFile)
@ NPZ ~/.julia/packages/NPZ/uRQRY/src/NPZ.jl:244
[4] (::NPZ.var"#4#7")(f::ZipFile.ReadableFile)
@ NPZ ./none:0
[5] iterate
@ ./generator.jl:47 [inlined]
[6] grow_to!(dest::Dict{Any, Any}, itr::Base.Generator{Base.Iterators.Filter{NPZ.var"#5#8"{Vector{String}}, Vector{ZipFile.ReadableFile}}, NPZ.var"#4#7"})
@ Base ./dict.jl:140
[7] dict_with_eltype
@ ./abstractdict.jl:550 [inlined]
[8] Dict(kv::Base.Generator{Base.Iterators.Filter{NPZ.var"#5#8"{Vector{String}}, Vector{ZipFile.ReadableFile}}, NPZ.var"#4#7"})
@ Base ./dict.jl:129
[9] npzread (repeats 2 times)
@ ~/.julia/packages/NPZ/uRQRY/src/NPZ.jl:311 [inlined]
[10] npzread(::String)
@ NPZ ~/.julia/packages/NPZ/uRQRY/src/NPZ.jl:295
[11] top-level scope
@ REPL[1]:1