Skip to main content

Crate rawarray

Crate rawarray 

Source
Expand description

Library for reading, writing, and manipulating RawArray files.

A RawArray is a minimal, but complete, fast and efficient file format for saving n-dimensional arrays to disk and reloading them later while restoring all properties of the former arrays. RawArrays make a faster, simpler substitute for MAT and HDF5 files in particular when one wants to store just a single array, or when one is perfectly content to let the file system handle your hierarchy of data storage, instead of a bloated container format. As a bonus, RawArrays support complex numbers natively, which HDF5 does not.

The standard file extension is .ra, which can be pronounced either “ra”, as in the Egyptian god, or “are-ay”, as in “array”. Rather than start another gif-like conflict, I think either is fine.

§Optional Features

As of version 0.1.3, this crate uses optional features to reduce dependencies for basic use cases. If you’re upgrading and getting compile errors about missing types, you may need to add feature flags:

  • half: Support for half-precision floats (f16, bf16). Add to Cargo.toml if needed: rawarray = { version = "0.1.3", features = ["half"] }

  • ndarray: Support for conversion from/to ndarray::Array types. Add to Cargo.toml if needed: rawarray = { version = "0.1.3", features = ["ndarray"] }

  • num-complex: Support for complex numbers via num_complex::Complex. Add to Cargo.toml if needed: rawarray = { version = "0.1.3", features = ["num-complex"] }

§Quick Start

use rawarray::RawArray;
let vec1: Vec<f32> = vec![1.0, 2.0, 3.0, 4.0];
let ra: RawArray<f32> = vec1.clone().into();
ra.write("myarray.ra")?;

let vec2: Vec<f32> = RawArray::<f32>::read("myarray.ra")?.into();
assert_eq!(vec1, vec2);

Structs§

RawArray
Container type for RawArrays
RawArrayFile
Wraps reading for some simpler parsing code

Traits§

RawArrayType
Helper trait to constrain to elemental types that make sense.