-
Notifications
You must be signed in to change notification settings - Fork 157
Potential regression when writing booleans #713
Description
Describe the bug
A recent update (2.7.0?) appears to be have broken the ability of writing boolean attributes; the breakage appears to be limited to the conda package, as I am unable to reproduce it with the main branch.
To Reproduce
Among other data types, we use HighFive to write attributes containing booleans and boolean arrays. We use the following approach:
namespace h5 = HighFive;
enum class H5Boolean {
FALSE = 0,
TRUE = 1,
};
h5::EnumType<H5Boolean> create_enum_boolean() {
return {{"FALSE", H5Boolean::FALSE},
{"TRUE", H5Boolean::TRUE}};
}
HIGHFIVE_REGISTER_TYPE(H5Boolean, create_enum_boolean)which is used to eventually either write a scalar bool bValue
H5Boolean value = bValue ? H5Boolean::TRUE : H5Boolean::FALSE;
h5::Attribute attr = sub.createAttribute<H5Boolean>(
name, h5::DataSpace::From(value));
attr.write(value);or a vector<bool> bValue
vector<H5Boolean> values;
for (auto b : bValue) {
values.push_back(b ? H5Boolean::TRUE : H5Boolean::FALSE);
}
h5::Attribute attr = sub.createAttribute<H5Boolean>(
name, h5::DataSpace::From(values));
attr.write(values);In either case the following error is thrown when attempting to write:
Size of array type 4 != that of memory datatype 1
Expected behavior
Until March 31st, the above code worked for both conda package and compilations using the HighFive git submodule. At this point, it still works for the current main (559bd85), but fails as described above for the conda package. … update: after fixing a clash of function names (see thread below), the main branch no longer works.
Desktop (please complete the following information):
- OS: macOS (same failure also observed on linux)
- Version 2.7.0; conda package only(?)
Additional context
The problem may be limited to the conda package on conda-forge, with the following details
$ conda list
[...]
highfive 2.7.0 h0747e88_0 conda-forge
[...]