Crate ndarray_npy[−][src]
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
ReadNpyExt
extension traitread_npy
convenience function
- Writing
WriteNpyExt
extension traitwrite_npy
convenience functionwrite_zeroed_npy
to write an.npy
file (sparse if possible) of zeroed data
- Readonly viewing (primarily for use with memory-mapped files)
ViewNpyExt
extension trait
- Mutable viewing (primarily for use with memory-mapped files)
ViewMutNpyExt
extension trait
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 thedescr
field of the header dictionary is a Python string literal of the form'string'
,"string"
,'''string'''
, or"""string"""
. -
The element traits (
WritableElement
,ReadableElement
,ViewElement
, andViewMutElement
) are currently implemented only for fixed-size integers up to 64 bits, floating point numbers, andbool
.
The plan is to add support for more element types (including custom user-defined structs) in the future.
Structs
NpzReader | Reader for |
NpzWriter | Writer for |
Enums
ReadDataError | An error reading array data. |
ReadNpyError | An error reading a |
ReadNpzError | An error reading a |
ViewDataError | An error viewing array data. |
ViewNpyError | An error viewing a |
WriteDataError | An error writing array data. |
WriteNpyError | An error writing a |
WriteNpzError | An error writing a |
Traits
ReadNpyExt | Extension trait for reading |
ReadableElement | An array element type that can be read from an |
ViewElement | An array element type that can be viewed (without copying) in an |
ViewMutElement | An array element type that can be mutably viewed (without copying) in an
|
ViewMutNpyExt | Extension trait for creating an |
ViewNpyExt | Extension trait for creating an |
WritableElement | An array element type that can be written to an |
WriteNpyExt | Extension trait for writing |
Functions
read_npy | Read an |
write_npy | Writes an array to an |
write_zeroed_npy | Writes an |