fhs / NPZ.jl

A Julia package that provides support for reading and writing Numpy .npy and .npz files
Other
117 stars 16 forks source link

Error reading python generated .npy with float64 numbers #43

Open javierdvalle opened 3 years ago

javierdvalle commented 3 years ago

Hi, I am getting this error when trying to load a matrix written by python in npy format. The matrix contains float64 numbers. It only happens with dtype=float64 numbers, when I try the same with dtype=int I don't get any errors and the matrix is loaded correctly.

python> matrix.dtype

dtype('float64')

python> np.save('data/matrix.npy', matrix)
julia> npzread("data/matrix.npy")
Illegal inttoptr
      %33 = ptrtoint double addrspace(13)* %32 to i64
Illegal inttoptr
      %52 = inttoptr i64 %51 to i8 addrspace(13)*

signal (6): Aborted
in expression starting at REPL[4]:1
gsignal at /usr/bin/../lib/x86_64-linux-gnu/libc.so.6 (unknown line)
abort at /usr/bin/../lib/x86_64-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: 0x7f6165e4bd04)
_ZN4llvm13FPPassManager13runOnFunctionERNS_8FunctionE at /usr/bin/../lib/x86_64-linux-gnu/libLLVM-8.so.1 (unknown line)
_ZN4llvm13FPPassManager11runOnModuleERNS_6ModuleE at /usr/bin/../lib/x86_64-linux-gnu/libLLVM-8.so.1 (unknown line)
_ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE at /usr/bin/../lib/x86_64-linux-gnu/libLLVM-8.so.1 (unknown line)
unknown function (ip: 0x7f6165f35ac1)
unknown function (ip: 0x7f6165f382d8)
unknown function (ip: 0x7f6165f388cd)
unknown function (ip: 0x7f6165e73b4a)
unknown function (ip: 0x7f6165ea4ed3)
unknown function (ip: 0x7f6165eca84b)
jl_apply_generic at /usr/bin/../lib/x86_64-linux-gnu/libjulia.so.1 (unknown line)
npzreadarray at /home/javier/.julia/packages/NPZ/OBINJ/src/NPZ.jl:227
npzread at /home/javier/.julia/packages/NPZ/OBINJ/src/NPZ.jl:251
unknown function (ip: 0x7f6165edd75b)
unknown function (ip: 0x7f6165edd389)
unknown function (ip: 0x7f6165edd8f0)
unknown function (ip: 0x7f6165ede9c8)
unknown function (ip: 0x7f6165edf616)
unknown function (ip: 0x7f6165ef7e08)
unknown function (ip: 0x7f6165ef83c8)
jl_toplevel_eval_in at /usr/bin/../lib/x86_64-linux-gnu/libjulia.so.1 (unknown line)
eval at ./boot.jl:331
eval_user_input at /build/julia-98cBbp/julia-1.4.1+dfsg/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:86
macro expansion at /build/julia-98cBbp/julia-1.4.1+dfsg/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:118 [inlined]
#26 at ./task.jl:358
unknown function (ip: 0x7f6165ee2cbb)
unknown function (ip: (nil))
Allocations: 5381468 (Pool: 5380292; Big: 1176); GC: 5
Aborted (core dumped)
jishnub commented 3 years ago

I can't reproduce this, could you provide an example of the matrix that you're having an issue with?

In [1]: import numpy as np

In [3]: matrix = np.zeros((2,2))

In [4]: matrix.dtype
Out[4]: dtype('float64')

In [5]: np.save('matrix.npy', matrix)
julia> using NPZ

julia> npzread("matrix.npy")
2×2 Array{Float64,2}:
 0.0  0.0
 0.0  0.0
javierdvalle commented 3 years ago

Hi, sorry for not providing more details. I am using the following version numbers:

That exact example is raising the following error:

$ python
Python 3.8.5 (default, Jul 28 2020, 12:59:40) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> matrix = np.zeros((2,2))
>>> matrix.dtype
dtype('float64')
>>> np.save('matrix.npy', matrix)
>>>
$ julia
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.4.1
 _/ |\__'_|_|_|\__'_|  |  Ubuntu ⛬  julia/1.4.1+dfsg-1
|__/                   |

julia> using NPZ

julia> npzread("matrix.npy")
Illegal inttoptr
      %33 = ptrtoint double addrspace(13)* %32 to i64
Illegal inttoptr
      %52 = inttoptr i64 %51 to i8 addrspace(13)*

signal (6): Aborted
in expression starting at REPL[2]:1
gsignal at /usr/bin/../lib/x86_64-linux-gnu/libc.so.6 (unknown line)
abort at /usr/bin/../lib/x86_64-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: 0x7fa4084e2d04)
_ZN4llvm13FPPassManager13runOnFunctionERNS_8FunctionE at /usr/bin/../lib/x86_64-linux-gnu/libLLVM-8.so.1 (unknown line)
_ZN4llvm13FPPassManager11runOnModuleERNS_6ModuleE at /usr/bin/../lib/x86_64-linux-gnu/libLLVM-8.so.1 (unknown line)
_ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE at /usr/bin/../lib/x86_64-linux-gnu/libLLVM-8.so.1 (unknown line)
unknown function (ip: 0x7fa4085ccac1)
unknown function (ip: 0x7fa4085cf2d8)
unknown function (ip: 0x7fa4085cf8cd)
unknown function (ip: 0x7fa40850ab4a)
unknown function (ip: 0x7fa40853c082)
unknown function (ip: 0x7fa40856184b)
jl_apply_generic at /usr/bin/../lib/x86_64-linux-gnu/libjulia.so.1 (unknown line)
npzreadarray at /home/javier/.julia/packages/NPZ/UizJj/src/NPZ.jl:244
npzread at /home/javier/.julia/packages/NPZ/UizJj/src/NPZ.jl:299
unknown function (ip: 0x7fa40857475b)
unknown function (ip: 0x7fa408574389)
unknown function (ip: 0x7fa4085748f0)
unknown function (ip: 0x7fa4085759c8)
unknown function (ip: 0x7fa408576616)
unknown function (ip: 0x7fa40858ee08)
unknown function (ip: 0x7fa40858f3c8)
jl_toplevel_eval_in at /usr/bin/../lib/x86_64-linux-gnu/libjulia.so.1 (unknown line)
eval at ./boot.jl:331
eval_user_input at /build/julia-98cBbp/julia-1.4.1+dfsg/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:86
macro expansion at /build/julia-98cBbp/julia-1.4.1+dfsg/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:118 [inlined]
#26 at ./task.jl:358
unknown function (ip: 0x7fa408579cbb)
unknown function (ip: (nil))
Allocations: 4526430 (Pool: 4525414; Big: 1016); GC: 5
Aborted (core dumped)