@@ -2071,9 +2071,12 @@ def createRegionReference(self, item):
2071
2071
Convert a list to a tuple, recursively.
2072
2072
Example. [[1,2],[3,4]] -> ((1,2),(3,4))
2073
2073
"""
2074
- def toTuple (self , data ):
2074
+ def toTuple (self , rank , data ):
2075
2075
if type (data ) in (list , tuple ):
2076
- return tuple (self .toTuple (x ) for x in data )
2076
+ if rank > 0 :
2077
+ return list (self .toTuple (rank - 1 , x ) for x in data )
2078
+ else :
2079
+ return tuple (self .toTuple (rank - 1 , x ) for x in data )
2077
2080
else :
2078
2081
return data
2079
2082
@@ -2421,25 +2424,6 @@ def setDatasetValuesByUuid(self, obj_uuid, data, slices=None, format="json"):
2421
2424
msg = "Only JSON is supported for for this data type"
2422
2425
self .log .info (msg )
2423
2426
raise IOError (errno .EINVAL , msg )
2424
-
2425
-
2426
- # need some special conversion for compound types --
2427
- # each element must be a tuple, but the JSON decoder
2428
- # gives us a list instead.
2429
- if format != "binary" and len (dset .dtype ) > 1 and type (data ) in (list , tuple ):
2430
- converted_data = []
2431
- for i in range (len (data )):
2432
- converted_data .append (self .toTuple (data [i ]))
2433
- data = converted_data
2434
- else :
2435
- h5t_check = h5py .check_dtype (ref = dset .dtype )
2436
- if h5t_check in (h5py .Reference , h5py .RegionReference ):
2437
- # convert data to data refs
2438
- if format == "binary" :
2439
- msg = "Only JSON is supported for for this data type"
2440
- self .log .info (msg )
2441
- raise IOError (errno .EINVAL , msg )
2442
- data = self .listToRef (data )
2443
2427
2444
2428
if slices is None :
2445
2429
slices = []
@@ -2487,6 +2471,25 @@ def setDatasetValuesByUuid(self, obj_uuid, data, slices=None, format="json"):
2487
2471
np_shape = tuple (np_shape ) # for comparison with ndarray shape
2488
2472
2489
2473
self .log .info ("selection shape:" + str (np_shape ))
2474
+
2475
+
2476
+ # need some special conversion for compound types --
2477
+ # each element must be a tuple, but the JSON decoder
2478
+ # gives us a list instead.
2479
+ if format != "binary" and len (dset .dtype ) > 1 and type (data ) in (list , tuple ):
2480
+ data = self .toTuple (rank , data )
2481
+ #for i in range(len(data)):
2482
+ # converted_data.append(self.toTuple(data[i]))
2483
+ #data = converted_data
2484
+ else :
2485
+ h5t_check = h5py .check_dtype (ref = dset .dtype )
2486
+ if h5t_check in (h5py .Reference , h5py .RegionReference ):
2487
+ # convert data to data refs
2488
+ if format == "binary" :
2489
+ msg = "Only JSON is supported for for this data type"
2490
+ self .log .info (msg )
2491
+ raise IOError (errno .EINVAL , msg )
2492
+ data = self .listToRef (data )
2490
2493
2491
2494
if format == "binary" :
2492
2495
if npoints * itemSize != len (data ):
@@ -2577,17 +2580,17 @@ def setDatasetValuesByPointSelection(self, obj_uuid, data, points, format="json"
2577
2580
msg = "Only JSON is supported for for this data type"
2578
2581
self .log .info (msg )
2579
2582
raise IOError (errno .EINVAL , msg )
2580
-
2583
+
2584
+ rank = len (dset .shape )
2585
+
2581
2586
# need some special conversion for compound types --
2582
2587
# each element must be a tuple, but the JSON decoder
2583
2588
# gives us a list instead.
2584
2589
if format == "json" and len (dset .dtype ) > 1 and type (data ) in (list , tuple ):
2585
- converted_data = []
2586
- for i in range (len (data )):
2587
- converted_data .append (self .toTuple (data [i ]))
2588
- data = converted_data
2589
-
2590
- rank = len (dset .shape )
2590
+ converted_data = self .toTuple (rank , data )
2591
+ #for i in range(len(data)):
2592
+ # converted_data.append(self.toTuple(data[i]))
2593
+ #data = converted_data
2591
2594
2592
2595
if format == "json" :
2593
2596
@@ -2741,7 +2744,7 @@ def createDataset(self, datatype, datashape, max_shape=None,
2741
2744
ndscalar = np .zeros ((), dtype = dt )
2742
2745
for i in range (len (fillvalue )):
2743
2746
field = dt .names [i ]
2744
- ndscalar [field ] = self .toTuple (fillvalue [i ])
2747
+ ndscalar [field ] = self .toTuple (0 , fillvalue [i ])
2745
2748
fillvalue = ndscalar
2746
2749
2747
2750
if fillvalue :
0 commit comments