fhs / NPZ.jl

A Julia package that provides support for reading and writing Numpy .npy and .npz files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

npzwrite cannot write Dict in julia 0.6

algorithmx opened this issue · comments

It seems that the function overload at line 276 in NPZ.jl has not been recognized because the error indicates a call to line 272 (... src/NPZ.jl:272).

My idea to fix it is simply adding a new function called "npzwrite_dict" ... or changing the name of that function. But I am completely new to GitHub and don't know how to update it ...

Any helps ?

yunlong@THEO-7101:~$ julia
_
_ _ ()_ | A fresh approach to technical computing
() | () () | Documentation: https://docs.julialang.org
_ _ | | __ _ | Type "?help" for help.
| | | | | | |/ ` | |
| | |
| | | | (
| | | Version 0.6.0 (2017-06-19 13:05 UTC)
/ |_'|||_'_| | Official http://julialang.org/ release
|__/ | x86_64-pc-linux-gnu

julia> using NPZ

julia> dict = Dict{String,Array{Float64,1}}("en"=>Float64[1.0,-1.0,2.0,-2.0])
Dict{String,Array{Float64,1}} with 1 entry:
"en" => [1.0, -1.0, 2.0, -2.0]

julia> npzwrite("test.npz", dict)
ERROR: MethodError: no method matching npzwritearray(::IOStream, ::Dict{String,Array{Float64,1}})
Closest candidates are:
npzwritearray(::IO, ::Array{UInt8,N} where N, ::DataType, ::Array{Int64,1}) at /home/yunlong/.julia/v0.6/NPZ/src/NPZ.jl:238
npzwritearray(::IO, ::Array{T,N} where N) where T at /home/yunlong/.julia/v0.6/NPZ/src/NPZ.jl:263
npzwritearray(::IO, ::T<:Number) where T<:Number at /home/yunlong/.julia/v0.6/NPZ/src/NPZ.jl:267
Stacktrace:
[1] npzwrite(::String, ::Dict{String,Array{Float64,1}}) at /home/yunlong/.julia/v0.6/NPZ/src/NPZ.jl:272

julia>

Walk-around:

using PyCall
@pyimport numpy as np
np.savez_compressed("test.npz".en=dict["en"])