# Npy Load NumPy `npy` and `npz` files in Ruby - no Python required :fire: Uses [Numo::NArray](https://github.com/ruby-numo/numo-narray) for blazing performance ## Installation Add this line to your application’s Gemfile: ```ruby gem 'npy' ``` ## Getting Started ### npy `npy` files contain a single array Load an `npy` file ```ruby arr = Npy.load("x.npy") ``` Load an `npy` string ```ruby byte_str = File.binread("x.npy") arr = Npy.load_string(byte_str) ``` ### npz `npz` files contain multiple arrays Load an `npz` file ```ruby arrs = Npy.load_npz("mnist.npz") ``` Get keys ```ruby arrs.keys ``` Get an array ```ruby arrs["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) ## 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