hsds icon indicating copy to clipboard operation
hsds copied to clipboard

Error on array broadcasting

Open ajelenak opened this issue 3 years ago • 2 comments

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.

ajelenak avatar Mar 28 '22 17:03 ajelenak

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.

jreadey avatar Apr 11 '22 01:04 jreadey

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

ajelenak avatar Apr 11 '22 20:04 ajelenak