Npy
Save and load NumPy npy and npz files in Ruby
Install / Use
/learn @ankane/NpyREADME
Npy
Save and load NumPy npy and npz files in Ruby - no Python required
:fire: Uses Numo for blazing performance
Installation
Add this line to your application’s Gemfile:
gem "npy"
Getting Started
npy
npy files contain a single array
Save an array
x = Numo::Int32[0..9]
Npy.save("x.npy", x)
Load an npy file
x = Npy.load("x.npy")
Load an npy string
byte_str = File.binread("x.npy")
x = Npy.load_string(byte_str)
npz
npz files contain multiple arrays
Save multiple arrays
x = Numo::Int32[0..9]
y = x * 2
Npy.save_npz("data.npz", x: x, y: y)
Load an npz file
data = Npy.load_npz("data.npz")
Get keys
data.keys
Get an array
data["x"]
Arrays are lazy loaded for performance
Resources
History
View the changelog
Contributing
Everyone is encouraged to help improve this project. Here are a few ways you can help:
- Report bugs
- Fix bugs and submit pull requests
- Write, clarify, or fix documentation
- Suggest or add new features
To get started with development:
git clone https://github.com/ankane/npy.git
cd npy
bundle install
bundle exec rake test
Related Skills
node-connect
345.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
104.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
345.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
345.4kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
