Skip to content

Commit 0ba5298

Browse files
committed
fix for scalar array type
1 parent 5044d80 commit 0ba5298

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

h5json/hdf5db.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2496,9 +2496,17 @@ def setDatasetValuesByUuid(self, obj_uuid, data, slices=None, format="json"):
24962496
msg = "Expected: " + str(npoints*itemSize) + " bytes, but got: " + str(len(data))
24972497
self.log.info(msg)
24982498
raise IOError(errno.EINVAL, msg)
2499-
arr = np.fromstring(data, dtype=dset.dtype)
2500-
arr = arr.reshape(np_shape) # conform to selection shape
2501-
2499+
if dset.dtype.shape == ():
2500+
arr = np.fromstring(data, dtype=dset.dtype)
2501+
arr = arr.reshape(np_shape) # conform to selection shape
2502+
else:
2503+
# tricy array type!
2504+
arr = np.empty(np_shape, dtype=dset.dtype)
2505+
base_arr = np.fromstring(data, dtype=dset.dtype.base)
2506+
base_shape = list(np_shape)
2507+
base_shape.extend(dset.dtype.shape) # add on the type dimensions
2508+
base_arr = base_arr.reshape(base_shape)
2509+
arr[...] = base_arr
25022510
else:
25032511
# data is json
25042512
if npoints == 1 and len(dset.dtype) > 1:

0 commit comments

Comments
 (0)