Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error handling empty array #53

Open
TomCC7 opened this issue Jul 20, 2022 · 0 comments
Open

Error handling empty array #53

TomCC7 opened this issue Jul 20, 2022 · 0 comments

Comments

@TomCC7
Copy link

TomCC7 commented Jul 20, 2022

Although it's weird to store an empty array in the npz file (I forgot to delete that field 😢), 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant