Reading array of compound datasets #276
-
I know this is similar to #217, but I still can't figure this thing out (I'm also a beginner). I have an h5 file with an attribute which holds an array of compound datasets:
This is the h5dump of that file attribute I've tried parsing this many different ways and seem to always get an array of large random numbers that change when I rerun the program indicating that I am getting some kind of address / indeterminate result. #[derive(hdf5::H5Type, Debug, Clone, PartialEq)]
#[repr(C)]
pub struct Coordinates {
a: i32,
b: i32,
c: i32,
d: i32,
}
#[derive(hdf5::H5Type, Debug, Clone, PartialEq)]
#[repr(C)]
pub struct Coordinates {
coords: [i32; 4]
} I'm trying to parse my attribute like this let values: Array1<Coordinates> = file.attr("path/to/Coordinates")?.read()?; I'm stumped. Any help would be appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The names of the compound type needs to match what is given by the datatype. You can achieve this by either using the names directly: #[derive(hdf5::H5Type, Debug, Clone, PartialEq)]
#[repr(C)]
pub struct Coordinates {
RowStart: i32,
ColumnStart: i32,
Width: i32,
Height: i32,
} Or by using the #[derive(hdf5::H5Type, Debug, Clone, PartialEq)]
#[repr(C)]
pub struct Coordinates {
#[hdf5(rename = "RowStart")]
a: i32,
#[hdf5(rename = "ColumnStart")]
b: i32,
#[hdf5(rename = "Width")]
c: i32,
#[hdf5(rename = "Height")]
d: i32,
} |
Beta Was this translation helpful? Give feedback.
The names of the compound type needs to match what is given by the datatype. You can achieve this by either using the names directly:
Or by using the
rename
functionality of the derive macro: