HighFive icon indicating copy to clipboard operation
HighFive copied to clipboard

H5Easy does not support sliced load for xtensor type

Open jamesbrownnz opened this issue 2 years ago • 1 comments

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

jamesbrownnz avatar Jul 05 '22 15:07 jamesbrownnz

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!

tdegeus avatar Jul 27 '22 14:07 tdegeus

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.

1uc avatar Jun 21 '24 06:06 1uc