Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fhs/npz.jl
A Julia package that provides support for reading and writing Numpy .npy and .npz files
https://github.com/fhs/npz.jl
Last synced: 4 days ago
JSON representation
A Julia package that provides support for reading and writing Numpy .npy and .npz files
- Host: GitHub
- URL: https://github.com/fhs/npz.jl
- Owner: fhs
- License: other
- Created: 2013-07-24T08:20:47.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2024-08-29T02:29:15.000Z (5 months ago)
- Last Synced: 2024-11-12T07:41:21.408Z (2 months ago)
- Language: Julia
- Homepage:
- Size: 406 KB
- Stars: 124
- Watchers: 4
- Forks: 18
- Open Issues: 18
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
## Overview
The NPZ package provides support for reading and writing Numpy .npy and
.npz files in Julia.An .npy file contains a single numpy array, stored in a binary
format along with its shape, data type, etc. An .npz file contains a
collection numpy arrays each encoded in the .npy format and stored in a
ZIP file. For more information, see the `numpy.save`, `numpy.savez`,
`numpy.savez_compressed`, and `numpy.load` functions in the [Numpy
documentation](http://docs.scipy.org/doc/numpy/reference/routines.io.html#npz-files).[![CI](https://github.com/fhs/NPZ.jl/workflows/CI/badge.svg?branch=master&event=push)](https://github.com/fhs/NPZ.jl/actions?query=workflow%3ACI+branch%3Amaster+event%3Apush)
[![](https://img.shields.io/badge/docs-dev-blue.svg)](https://fhs.github.io/NPZ.jl/dev)## Installation
Install via the Julia package manager, `Pkg.add("NPZ")`.
## Usage
We try to provide an interface similar to the
[MAT.jl](https://github.com/simonster/MAT.jl) package. Some usage
examples are shown below.Write and then read back an array:
```julia
julia> using NPZjulia> x = [i-j for i in 1:3, j in 1:4];
julia> npzwrite("x.npy", x)
julia> y = npzread("x.npy")
3x4 Int64 Array:
0 -1 -2 -3
1 0 -1 -2
2 1 0 -1
```Write and then read back a collection of arrays or numbers:
```julia
julia> npzwrite("data.npz", Dict("x" => x, "a" => collect(1:9), "n" => 42))julia> vars = npzread("data.npz")
Dict{String,Any} with 3 entries:
"x" => [0 -1 -2 -3; 1 0 -1 -2; 2 1 0 -1]
"a" => [1, 2, 3, 4, 5, 6, 7, 8, 9]
"n" => 42
```