Merge branch 'fix/p0-filters' into fix/phase0-correctness
# Conflicts: # crates/clawhdf5-format/src/filters.rs
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
# Filter conformance fixtures
|
||||
|
||||
Files written by libhdf5 (and its registered filter plugins), used by the
|
||||
filter regression tests in `src/filters.rs` to compare our decoders against
|
||||
the values h5py/libhdf5 read from the same bytes. Chunk byte ranges quoted in
|
||||
the tests come from h5py's `DatasetID.get_chunk_info`.
|
||||
|
||||
| File | Origin | Licence |
|
||||
|------|--------|---------|
|
||||
| `h5ex_d_lz4.h5` | HDF Group `HDF5Examples/C/H5FLT/tfiles/h5ex_d_lz4.h5` (hdf5 repository) | HDF5 licence (BSD-3-Clause style) |
|
||||
| `noencoder.h5` | HDF Group `test/testfiles/noencoder.h5` (hdf5 repository) | HDF5 licence (BSD-3-Clause style) |
|
||||
| `le_data.h5` | HDF Group `test/testfiles/le_data.h5` (hdf5 repository) | HDF5 licence (BSD-3-Clause style) |
|
||||
| `szip_h5py.h5` | Written for these tests with h5py 3 / libhdf5 2.0.0 (libaec szip): `f8` (8x10, chunks 4x10, `('nn', 8)`), `i8` (8x10, chunks 4x10, `('ec', 4)`), `u2` (70, chunks 35, `('nn', 8)`) | Same as this repository |
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -940,3 +940,61 @@ fn provenance_verify_written_file() {
|
||||
.unwrap();
|
||||
assert_eq!(result, clawhdf5_format::provenance::VerifyResult::Ok);
|
||||
}
|
||||
|
||||
// ---- hdf5plugin interop: registered third-party compression filters ----
|
||||
|
||||
/// Write `data` (f64, 1-D, chunked) with `configure` applied, then read it
|
||||
/// back with h5py + hdf5plugin (libhdf5's registered filter plugins) and
|
||||
/// return the values it decodes.
|
||||
#[cfg(any(feature = "lz4", feature = "zstd"))]
|
||||
fn hdf5plugin_roundtrip(
|
||||
tag: &str,
|
||||
data: &[f64],
|
||||
configure: impl FnOnce(&mut clawhdf5_format::type_builders::DatasetBuilder),
|
||||
) -> Vec<f64> {
|
||||
let mut fw = FileWriter::new();
|
||||
let ds = fw.create_dataset("data");
|
||||
ds.with_f64_data(data)
|
||||
.with_shape(&[data.len() as u64])
|
||||
.with_chunks(&[250]);
|
||||
configure(ds);
|
||||
let bytes = fw.finish().unwrap();
|
||||
let path = std::env::temp_dir().join(format!("clawhdf5_hdf5plugin_{tag}.h5"));
|
||||
std::fs::write(&path, &bytes).unwrap();
|
||||
let script = format!(
|
||||
"import h5py,hdf5plugin,json; f=h5py.File('{}','r'); print(json.dumps(f['data'][:].tolist()))",
|
||||
path.display()
|
||||
);
|
||||
let stdout = h5py_read(&path, &script);
|
||||
serde_json::from_str(&stdout).unwrap()
|
||||
}
|
||||
|
||||
/// libhdf5's LZ4 plugin must decode what we write (it could not while we
|
||||
/// wrote a private 4-byte-LE-size framing).
|
||||
#[cfg(feature = "lz4")]
|
||||
#[test]
|
||||
#[ignore = "requires Python h5py + hdf5plugin"]
|
||||
fn hdf5plugin_reads_our_lz4() {
|
||||
let data: Vec<f64> = (0..1000).map(|i| (i % 37) as f64 * 0.5).collect();
|
||||
let got = hdf5plugin_roundtrip("lz4", &data, |ds| {
|
||||
ds.with_lz4();
|
||||
});
|
||||
assert_eq!(got, data);
|
||||
let got = hdf5plugin_roundtrip("lz4_noshuffle", &data, |ds| {
|
||||
ds.with_lz4().without_shuffle();
|
||||
});
|
||||
assert_eq!(got, data);
|
||||
}
|
||||
|
||||
/// libhdf5's Zstandard plugin must decode what we write (it could not while
|
||||
/// our frames lacked the content size).
|
||||
#[cfg(feature = "zstd")]
|
||||
#[test]
|
||||
#[ignore = "requires Python h5py + hdf5plugin"]
|
||||
fn hdf5plugin_reads_our_zstd() {
|
||||
let data: Vec<f64> = (0..1000).map(|i| (i % 37) as f64 * 0.5).collect();
|
||||
let got = hdf5plugin_roundtrip("zstd", &data, |ds| {
|
||||
ds.with_zstd(3);
|
||||
});
|
||||
assert_eq!(got, data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user