Skip to content

Commit

Permalink
Add NpzWriter::new_with_options (#66)
Browse files Browse the repository at this point in the history
* Add zstd-compressed archives support

* Replace `new_zstd_compressed` with a more flexible `new_with_options`
  • Loading branch information
DCNick3 authored Sep 14, 2024
1 parent dd0dc26 commit 9574a2f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/npz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,18 @@ impl<W: Write + Seek> NpzWriter<W> {
}
}

/// Creates a new `.npz` file with the specified options.
///
/// This allows you to use a custom compression method, such as [`CompressionMethod::Zstd`] or set other options.
///
/// Make sure to enable the `zstd` feature of the `zip` crate to use [`CompressionMethod::Zstd`] or other relevant features.
pub fn new_with_options(writer: W, options: FileOptions) -> NpzWriter<W> {
NpzWriter {
zip: ZipWriter::new(writer),
options,
}
}

/// Adds an array with the specified `name` to the `.npz` file.
///
/// Note that a `.npy` extension will be appended to `name`; this matches NumPy's behavior.
Expand Down

0 comments on commit 9574a2f

Please sign in to comment.