HighFive
HighFive copied to clipboard
H5Easy does not support sliced load for xtensor type
Running this code returns a template resolution error.
int main()
{
const HighFive::File file = HighFive::File("example.h5", HighFive::File::ReadOnly);
auto A = H5Easy::load<xt::xtensor<float, 2>>(file, "/example", {0, 1})
}
Error output:
H5Easy_public.hpp(157): error C3861: 'load_part': identifier not found
using vcpkg to install libs:
- xtensor: 0.24.0
- xtensor-io: 0.13.0#1
- highfive: 2.3#2
The syntax you refer to is not a slice, but item (0, 1). It returns a scalar. So what does work is
auto A = H5Easy::load<float>(file, "/example", {0, 1});
and what might work (I cannot remember, if it does not please feel free to open a PR
auto A = H5Easy::load<xt::xtensor<float, 0>>(file, "/example", {0, 1});
I don't think that we support slicing in the basic HighFive API either, but that I'm not sure of. If you are interested to have it in in H5Easy: a PR would be welcomed!
HighFive core supports any hyperslabs and on the main branch also a more ergonomic API for tensorproduct selection, e.g. things like x[2:6, [1, 2, 3]]
in numpy syntax.
Reading/writing slices of an XTensor object should be supported, in code and via #1016 also in H5Easy.