@@ -2313,21 +2313,31 @@ def setDatasetValuesByUuid(self, obj_uuid, data, slices=None, format="json"):
2313
2313
arr = arr .reshape (np_shape ) # conform to selection shape
2314
2314
2315
2315
else :
2316
- # data is json
2317
- if npoints == 1 and len (dset .dtype ) > 1 :
2316
+ # data is json
2317
+ if npoints == 1 and len (dset .dtype ) > 1 :
2318
2318
# convert to tuple for compound singleton writes
2319
2319
data = [tuple (data ),]
2320
2320
2321
- arr = np .array (data , dtype = dset .dtype )
2322
- # raise an exception of the array shape doesn't match the selection shape
2323
- # allow if the array is a scalar and the selection shape is one element,
2324
- # numpy is ok with this
2325
- if arr .shape == () and np_shape == (1 ,):
2326
- np_shape = ()
2327
- if arr .shape == (1 ,) and np_shape == ():
2328
- np_shape = (1 ,)
2329
-
2330
- if arr .shape != np_shape :
2321
+ arr = np .array (data , dtype = dset .dtype )
2322
+ # raise an exception of the array shape doesn't match the selection shape
2323
+ # allow if the array is a scalar and the selection shape is one element,
2324
+ # numpy is ok with this
2325
+ np_index = 0
2326
+ for dim in range (len (arr .shape )):
2327
+ data_extent = arr .shape [dim ]
2328
+ selection_extent = 1
2329
+ if np_index < len (np_shape ):
2330
+ selection_extent = np_shape [np_index ]
2331
+ if selection_extent == data_extent :
2332
+ np_index += 1
2333
+ continue # good
2334
+ if data_extent == 1 :
2335
+ continue # skip singleton selection
2336
+ if selection_extent == 1 :
2337
+ np_index += 1
2338
+ continue # skip singleton selection
2339
+
2340
+ # selection/data mismatch!
2331
2341
msg = "data shape doesn't match selection shape"
2332
2342
msg += "--data shape: " + str (arr .shape )
2333
2343
msg += "--selection shape: " + str (np_shape )
0 commit comments