Skip to content

Commit

Permalink
minor
Browse files Browse the repository at this point in the history
  • Loading branch information
kaizhang committed Dec 14, 2024
1 parent 8db0474 commit 69e11fc
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion anndata-hdf5/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ homepage = "https://github.com/kaizhang/anndata-rs"
[dependencies]
anndata = { workspace = true }
anyhow = "1.0"
hdf5 = { package = "hdf5-metno", version = "0.9", features = ["blosc"] }
hdf5 = { package = "hdf5-metno", version = "0.9", features = ["lzf", "blosc"] }
blosc-src = { version = "0.3.0", features = ["zstd"] }
hdf5-sys = { package = "hdf5-metno-sys", version = "0.9", features = ["static", "zlib", "threadsafe"] }
libz-sys = { version = "1", features = ["libc"], default-features = false }
Expand Down
10 changes: 7 additions & 3 deletions anndata-hdf5/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,13 @@ fn new_dataset<T: BackendData>(
};

builder = if let Some(compression) = config.compression {
match dtype {
ScalarType::String => builder.deflate(compression),
_ => builder.blosc_zstd(compression, hdf5::filters::BloscShuffle::Byte),
match compression {
Compression::Gzip(lvl) => builder.deflate(lvl),
Compression::Lzf => builder.lzf(),
Compression::Zstd(lvl) => match dtype {
ScalarType::String => builder.deflate(lvl),
_ => builder.blosc_zstd(lvl, hdf5::filters::BloscShuffle::Byte),
}
}
} else {
builder
Expand Down
12 changes: 9 additions & 3 deletions anndata/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,23 @@ use std::path::{Path, PathBuf};
pub use serde_json::Value;
use serde::Deserialize;

#[derive(Debug, Copy, Clone)]
pub enum Compression {
Gzip(u8),
Lzf,
Zstd(u8),
}

#[derive(Debug, Clone)]
pub struct WriteConfig {
pub compression: Option<u8>,
pub compression: Option<Compression>,
pub block_size: Option<Shape>,
}

impl Default for WriteConfig {
fn default() -> Self {
Self {
compression: Some(1),
//compression: None,
compression: Some(Compression::Zstd(3)),
block_size: None,
}
}
Expand Down
1 change: 1 addition & 0 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ dynamic = ["version"]

dependencies = [
'anndata >= 0.8.0, < 0.11.0',
'hdf5plugin >= 5.0.0',
"numpy>=1.16",
"pandas",
"pyarrow",
Expand Down

0 comments on commit 69e11fc

Please sign in to comment.