Skip to content

Reading slices fails with negative indices #45

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
SuperFluffy opened this issue Jun 27, 2019 · 2 comments · Fixed by #140
Closed

Reading slices fails with negative indices #45

SuperFluffy opened this issue Jun 27, 2019 · 2 comments · Fixed by #140

Comments

@SuperFluffy
Copy link
Contributor

Say you have a simple one-dimensional dataset with shape [64]. If you try to read the last entry with dataset.read_slice_1d(s![-1]) hdf5 will error out (of course, the same happens with any dimensional dataset). A current workaround is to set let shape = dataset.shape(); and then execute dataset.read_slice_1d(s![shape[0]-1]).

I will come up with a minimum working example, but just wanted to note this here already, in case somebody encounters the same issue.

@elbaro
Copy link

elbaro commented Jan 2, 2021

Hit the same.

HDF5-DIAG: Error detected in HDF5 (1.12.0) thread 0:
  #000: H5Dio.c line 192 in H5Dread(): can't read data
    major: Dataset
    minor: Read failed
  #001: H5VLcallback.c line 2080 in H5VL_dataset_read(): dataset read failed
    major: Virtual Object Layer
    minor: Read failed
  #002: H5VLcallback.c line 2046 in H5VL__dataset_read(): dataset read failed
    major: Virtual Object Layer
    minor: Read failed
  #003: H5VLnative_dataset.c line 163 in H5VL__native_dataset_read(): could not get a validated dataspace from file_space_id
    major: Invalid arguments to routine
    minor: Bad value
  #004: H5S.c line 279 in H5S_get_validated_dataspace(): selection + offset not within extent
    major: Dataspace
    minor: Out of range

@mulimoen
Copy link
Collaborator

mulimoen commented Feb 9, 2021

Negative indices are not allowed in hdf5. Using negative slices is a python (and others?) speciality. The dcpl-branch replaces the s macro with an Extents type which restricts datatypes to usize

magnusuMET added a commit to magnusuMET/hdf5-rust that referenced this issue Jan 10, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants