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
ReadNpyExtextension traitread_npyconvenience function
- Writing
WriteNpyExtextension traitwrite_npyconvenience functionwrite_zeroed_npyto write an.npyfile (sparse if possible) of zeroed data
- Readonly viewing (primarily for use with memory-mapped files)
ViewNpyExtextension trait
- Mutable viewing (primarily for use with memory-mapped files)
ViewMutNpyExtextension 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
.npyfiles is currently limited to files where thedescrfield 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, complex floating point numbers (if enabled with the crate feature), andbool.
The plan is to add support for more element types (including custom user-defined structs) in the future.
Structs§
- Reader for
.npzfiles. - Writer for
.npzfiles.
Enums§
- An error reading array data.
- An error reading a
.npyfile. - An error reading a
.npzfile. - An error viewing array data.
- An error viewing a
.npyfile. - An error writing array data.
- An error writing a
.npyfile. - An error writing a
.npzfile.
Traits§
- Extension trait for reading
Arrayfrom.npyfiles. - An array element type that can be read from an
.npyor.npzfile. - An array element type that can be viewed (without copying) in an
.npyfile. - An array element type that can be mutably viewed (without copying) in an
.npyfile. - Extension trait for creating an
ArrayViewMutfrom a mutable buffer containing an.npyfile. - Extension trait for creating an
ArrayViewfrom a buffer containing an.npyfile. - An array element type that can be written to an
.npyor.npzfile. - Extension trait for writing
ArrayBaseto.npyfiles.
Functions§
- Read an
.npyfile located at the specified path. - Writes an array to an
.npyfile at the specified path. - Writes an
.npyfile (sparse if possible) with bitwise-zero-filled data.