#ndarray #numpy #array #npy #npz

ndarray-npy

.npy and .npz file format support for ndarray

5 releases (3 breaking)

✓ Uses Rust 2018 edition

0.4.0 Feb 25, 2019
0.3.0 Sep 1, 2018
0.2.0 Jun 23, 2018
0.1.1 Apr 22, 2018
0.1.0 Apr 22, 2018

#25 in Parser implementations

Download history 63/week @ 2018-12-20 1/week @ 2018-12-27 29/week @ 2019-01-03 45/week @ 2019-01-10 43/week @ 2019-01-17 95/week @ 2019-01-24 61/week @ 2019-01-31 63/week @ 2019-02-07 8/week @ 2019-02-14 58/week @ 2019-02-21 45/week @ 2019-02-28 202/week @ 2019-03-07 323/week @ 2019-03-14 478/week @ 2019-03-21 319/week @ 2019-03-28

594 downloads per month

MIT/Apache

44KB
800 lines

ndarray-npy

Build status Coverage Dependencies status Crate Documentation

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 ReadableElement and WritableElement for your own types, but the next breaking release of this library will probably change those traits.

Future plans include support for:

  • Memory-mapped files.
  • 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.4"

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.4", 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.4"
default-features = false
features = ["npz"]

Library authors

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

[dependencies.ndarray-npy]
version = "0.4"
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

  • 0.4.0

    • Added support for reading/writing arrays of bool, by @tobni and @jturner314.
    • Updated to zip 0.5.
    • Updated to Rust 1.32.
    • Renamed the compressed_npz_default feature to compressed_npz because the zip crate no longer allows the user to select the compression backend.
  • 0.3.0

    • Updated to ndarray 0.12.
    • Updated to num-traits 0.2 (replacing dependency on num).
    • Updated to py_literal 0.2.
  • 0.2.0

    • Updated to zip 0.4.
    • Made the compression backend for compressed .npz files user-selectable.
    • Reworked how feature selection works. This should only affect you if you use default-features = false, features = ["compressed_npz"].
  • 0.1.1

    • Improved crate documentation (no functional changes).
  • 0.1.0

    • Initial release.

Contributing

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

License

Copyright 2018 Jim Turner

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.

Dependencies

~3MB
~64K SLoC