HDFGroup / hsds

Cloud-native, service based access to HDF data
https://www.hdfgroup.org/solutions/hdf-kita/
Apache License 2.0
131 stars 53 forks source link

Error on array broadcasting #131

Open ajelenak opened 2 years ago

ajelenak commented 2 years ago

This code:

import h5pyd

with h5pyd.File('hdf5://home/userme/foo.h5', mode='w') as f:
    x = f.create_dataset('x', shape=(2, 3), dtype='i4')
    x[...] = [[1, 2, 3]]

Produces error: OSError: Expected: 24 bytes, but got: 12. The correct outcome should be for x to store an [[1, 2, 3][1, 2, 3]] array.

jreadey commented 2 years ago

A related error is:

import h5pyd

with h5pyd.File('hdf5://home/userme/foo.h5', mode='w') as f:
    x = f.create_dataset('x', shape=(2, 3), dtype='i4')
    x[1,2:5] = [1, 2, 3]

Produces error: OSError: Expected: 4 bytes, but got: 12

The same code with h5py gives: TypeError: Can't broadcast (3,) -> (1,) The HSDS error seems to be an effect of the array selection being limited to one element but h5pyd pushing 3 4-byte ints in the request. It would seem better if HSDS would return a 400 error once it sees the query parameters are not valid.

ajelenak commented 2 years ago

My example works with h5py. That's why I created this issue.