# NPZ.jl

NPZ.npzreadMethod
npzread(filename::AbstractString, [vars])

Read a variable or a collection of variables from filename. The input needs to be either an npy or an npz file. The optional argument vars is used only for npz files. If it is specified, only the matching variables are read in from the file.

Zero-dimensional arrays

Zero-dimensional arrays are stripped while being read in, and the values that they contain are returned. This is a notable difference from numpy, where numerical values are written out and read back in as zero-dimensional arrays.

Examples

julia> npzwrite("temp.npz", x = ones(3), y = 3)

Dict{String,Any} with 2 entries:
"x" => [1.0, 1.0, 1.0]
"y" => 3

Dict{String,Array{Float64,1}} with 1 entry:
"x" => [1.0, 1.0, 1.0]
source
NPZ.npzwriteMethod
npzwrite(filename::AbstractString, x)

Write the variable x to the npy file filename. Unlike numpy, the extension .npy is not appened to filename.

Warning

Any existing file with the same name will be overwritten.

Examples

julia> npzwrite("abc.npy", zeros(3))

3-element Array{Float64,1}:
0.0
0.0
0.0
source
NPZ.npzwriteMethod
npzwrite(filename::AbstractString, vars::Dict{<:AbstractString})
npzwrite(filename::AbstractString, args...; kwargs...)

In the first form, write the variables in vars to an npz file named filename.

In the second form, collect the variables in args and kwargs and write them all to filename. The variables in args are saved with names arr_0, arr_1 and so on, whereas the ones in kwargs are saved with the specified names.

Unlike numpy, the extension .npz is not appened to filename.

Warning

Any existing file with the same name will be overwritten.

Examples

julia> npzwrite("temp.npz", Dict("x" => ones(3), "y" => 3))

Dict{String,Any} with 2 entries:
"x" => [1.0, 1.0, 1.0]
"y" => 3

julia> npzwrite("temp.npz", ones(2,2), x = ones(3), y = 3)

"y"     => 3
NPZ.readheaderMethod
readheader(filename, [vars...])
Return a header or a collection of headers corresponding to each variable contained in filename. The header contains information about the eltype and size of the array that may be extracted using the corresponding accessor functions.