Crate ndarray_npy

Source
Expand description

This crate provides methods to read/write ndarray’s ArrayBase type from/to .npy and .npz files.

See the repository for information about the default features and how to use this crate with Cargo.

§.npy Files

  • Reading
  • Writing
  • Readonly viewing (primarily for use with memory-mapped files)
  • Mutable viewing (primarily for use with memory-mapped files)

It’s possible to create .npy files larger than the available memory with write_zeroed_npy and then modify them by memory-mapping and using ViewMutNpyExt.

§.npz Files

§Limitations

  • Parsing of .npy files is currently limited to files where the descr field of the header dictionary is a Python string literal of the form 'string', "string", '''string''', or """string""".

  • The element traits (WritableElement, ReadableElement, ViewElement, and ViewMutElement) are currently implemented only for fixed-size integers up to 64 bits, floating point numbers, complex floating point numbers (if enabled with the crate feature), and bool.

The plan is to add support for more element types (including custom user-defined structs) in the future.

Structs§

NpzReader
Reader for .npz files.
NpzWriter
Writer for .npz files.

Enums§

ReadDataError
An error reading array data.
ReadNpyError
An error reading a .npy file.
ReadNpzError
An error reading a .npz file.
ViewDataError
An error viewing array data.
ViewNpyError
An error viewing a .npy file.
WriteDataError
An error writing array data.
WriteNpyError
An error writing a .npy file.
WriteNpzError
An error writing a .npz file.

Traits§

ReadNpyExt
Extension trait for reading Array from .npy files.
ReadableElement
An array element type that can be read from an .npy or .npz file.
ViewElement
An array element type that can be viewed (without copying) in an .npy file.
ViewMutElement
An array element type that can be mutably viewed (without copying) in an .npy file.
ViewMutNpyExt
Extension trait for creating an ArrayViewMut from a mutable buffer containing an .npy file.
ViewNpyExt
Extension trait for creating an ArrayView from a buffer containing an .npy file.
WritableElement
An array element type that can be written to an .npy or .npz file.
WriteNpyExt
Extension trait for writing ArrayBase to .npy files.

Functions§

read_npy
Read an .npy file located at the specified path.
write_npy
Writes an array to an .npy file at the specified path.
write_zeroed_npy
Writes an .npy file (sparse if possible) with bitwise-zero-filled data.