Sha256: d761be8d71b179857912a9d5e0b4c074d59f69b96964b8f9f705f1d8742fe78e
Contents?: true
Size: 1.62 KB
Versions: 2
Compression:
Stored size: 1.62 KB
Contents
# Npy Save and load NumPy `npy` and `npz` files in Ruby - no Python required :fire: Uses [Numo](https://github.com/ruby-numo/numo-narray) for blazing performance [![Build Status](https://travis-ci.org/ankane/npy.svg?branch=master)](https://travis-ci.org/ankane/npy) ## Installation Add this line to your application’s Gemfile: ```ruby gem 'npy' ``` ## Getting Started ### npy `npy` files contain a single array Save an array ```ruby x = Numo::Int32[0..9] Npy.save("x.npy", x) ``` Load an `npy` file ```ruby x = Npy.load("x.npy") ``` Load an `npy` string ```ruby byte_str = File.binread("x.npy") x = Npy.load_string(byte_str) ``` ### npz `npz` files contain multiple arrays Save multiple arrays ```ruby x = Numo::Int32[0..9] y = x * 2 Npy.save_npz("data.npz", x: x, y: y) ``` Load an `npz` file ```ruby data = Npy.load_npz("data.npz") ``` Get keys ```ruby data.keys ``` Get an array ```ruby data["x"] ``` Arrays are lazy loaded for performance ## Resources - [npy format](https://docs.scipy.org/doc/numpy/reference/generated/numpy.lib.format.html#module-numpy.lib.format) - [NumPy data types](https://docs.scipy.org/doc/numpy/user/basics.types.html) - [Numo::NArray docs](https://ruby-numo.github.io/narray/narray/Numo/NArray.html) ## History View the [changelog](https://github.com/ankane/npy/blob/master/CHANGELOG.md) ## Contributing Everyone is encouraged to help improve this project. Here are a few ways you can help: - [Report bugs](https://github.com/ankane/npy/issues) - Fix bugs and [submit pull requests](https://github.com/ankane/npy/pulls) - Write, clarify, or fix documentation - Suggest or add new features
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
npy-0.2.0 | README.md |
npy-0.1.2 | README.md |