h5rs tools, browser reader, libhdf5 header checks, plugin filters, concurrency benchmark #14
@@ -144,6 +144,35 @@ mod tests {
|
|||||||
assert_eq!(ds.dtype().unwrap(), DType::I32);
|
assert_eq!(ds.dtype().unwrap(), DType::I32);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn dataset_raw_datatype() {
|
||||||
|
use clawhdf5_format::datatype::Datatype;
|
||||||
|
let bytes = make_simple_file();
|
||||||
|
let file = File::from_bytes(bytes).unwrap();
|
||||||
|
let dt = file.dataset("counts").unwrap().raw_datatype().unwrap();
|
||||||
|
assert!(
|
||||||
|
matches!(
|
||||||
|
dt,
|
||||||
|
Datatype::FixedPoint {
|
||||||
|
size: 4,
|
||||||
|
signed: true,
|
||||||
|
..
|
||||||
|
}
|
||||||
|
),
|
||||||
|
"{dt:?}"
|
||||||
|
);
|
||||||
|
// The full type pairs with read_selection's bytes.
|
||||||
|
let raw = file
|
||||||
|
.dataset("counts")
|
||||||
|
.unwrap()
|
||||||
|
.read_selection(&Selection::All)
|
||||||
|
.unwrap();
|
||||||
|
assert_eq!(
|
||||||
|
clawhdf5_format::data_read::read_as_i64(&raw, &dt).unwrap(),
|
||||||
|
vec![10, 20, 30]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn root_group_datasets() {
|
fn root_group_datasets() {
|
||||||
let bytes = make_simple_file();
|
let bytes = make_simple_file();
|
||||||
|
|||||||
@@ -416,6 +416,15 @@ impl<'f> Dataset<'f> {
|
|||||||
Ok(classify_datatype(&dt))
|
Ok(classify_datatype(&dt))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the dataset's full datatype as stored in the file (byte order,
|
||||||
|
/// string padding, compound layout, ...), with a committed datatype
|
||||||
|
/// resolved. Use it with the `clawhdf5_format::data_read` converters on
|
||||||
|
/// the bytes [`read_selection`](Self::read_selection) returns, for types
|
||||||
|
/// the typed `read_*` methods do not cover.
|
||||||
|
pub fn raw_datatype(&self) -> Result<Datatype, Error> {
|
||||||
|
self.datatype()
|
||||||
|
}
|
||||||
|
|
||||||
/// Read all data as `f64` values.
|
/// Read all data as `f64` values.
|
||||||
pub fn read_f64(&self) -> Result<Vec<f64>, Error> {
|
pub fn read_f64(&self) -> Result<Vec<f64>, Error> {
|
||||||
let dt = self.datatype()?;
|
let dt = self.datatype()?;
|
||||||
|
|||||||
Reference in New Issue
Block a user