Skip to content

.npy and .npz file format support for ndarray

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

qu1x/ndarray-npy

 
 

Repository files navigation

ndarray-npy

Continuous integration Coverage Dependencies status ndarray-npy at crates.io Documentation Matrix chat at #rust-sci:matrix.org IRC at #rust-sci on OFTC

This crate provides support for reading/writing ndarray's ArrayBase type from/to .npy and .npz files. See the documentation for more information.

This crate is a work-in-progress. It currently supports only a subset of .npy header descriptors and supports only primitive fixed-size integer, floating point, and bool types as the array element type. You can implement the *Element traits for your own types, but the next breaking release of this library will probably change those traits.

Future plans include support for:

  • Memory-mapped .npz files. (Memory-mapped .npy files are already supported.)
  • More element types (e.g. structs). If you need support for structs before this is implemented in ndarray-npy, check out the npy crate.
  • Possibly merging this with the npy crate.

Using with Cargo

To use with the default features:

[dependencies]
ndarray-npy = "0.8"

The default feature set includes the compressed_npz feature, which enables support for uncompresssed and compressed .npz files. This requires a dependency on the zip crate and a compression backend crate.

To use without the default features:

[dependencies]
ndarray-npy = { version = "0.8", default-features = false }

With default-features = false, ndarray-npy provides support only for .npy files, not .npz files. If you want .npz file support, you can select additional features:

  • npz enables support for uncompressed .npz files. This requires a dependency on the zip crate.
  • compressed_npz enables support for uncompressed and compressed .npz files. This requires a dependency on the zip crate and a compression backend crate.

For example, you can use just the npz feature:

[dependencies.ndarray-npy]
version = "0.8"
default-features = false
features = ["npz"]

Library authors

Library authors should specify their dependency on ndarray-npy like this:

[dependencies.ndarray-npy]
version = "0.8"
default-features = false
features = [FEATURES_LIST_HERE]

where the features list is one of the following:

  • [] if your crate does not depend on .npz file support
  • ["npz"] if your crate depends on .npz file support but not compression
  • ["compressed_npz"] if your crate depends on .npz file support with compression

Releases

See RELEASES.md.

Contributing

Please feel free to create issues and submit PRs. PRs adding more tests would be especially appreciated.

License

Copyright 2018–2021 Jim Turner and ndarray-npy developers

Licensed under the Apache License, Version 2.0, or the MIT license, at your option. You may not use this project except in compliance with those terms.

About

.npy and .npz file format support for ndarray

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 98.6%
  • Python 1.4%