@@ -1970,6 +1970,7 @@ def test_basetype_commutative(self,):
1970
1970
assert (val != dset ) == (dset != val )
1971
1971
1972
1972
1973
+ @ut .skipIf (config .get ('use_h5py' ), "h5py does not support MultiManager" )
1973
1974
class TestMultiManager (BaseDataset ):
1974
1975
def test_multi_read_scalar_dataspaces (self ):
1975
1976
"""
@@ -2350,16 +2351,17 @@ def test_multi_write_mixed_shapes(self):
2350
2351
out = self .f ["data" + str (i )][...]
2351
2352
np .testing .assert_array_equal (out [sel_idx , sel_idx ], data_in + i )
2352
2353
2353
- def test_multi_selection_rw (self ):
2354
+ def test_multi_selection (self ):
2354
2355
"""
2355
- Test reading and writing a unique selection in each dataset
2356
+ Test using a different selection
2357
+ for each dataset in a MultiManager
2356
2358
"""
2357
2359
shape = (10 , 10 , 10 )
2358
2360
count = 3
2359
2361
dt = np .int32
2360
2362
2361
2363
# Create datasets
2362
- data_in = np .reshape (np .arange (np .prod (shape )), shape )
2364
+ data_in = np .reshape (np .arange (np .prod (shape ), dtype = dt ), shape )
2363
2365
data_in_original = data_in .copy ()
2364
2366
datasets = []
2365
2367
@@ -2368,7 +2370,7 @@ def test_multi_selection_rw(self):
2368
2370
dtype = dt , data = data_in )
2369
2371
datasets .append (dset )
2370
2372
2371
- mm = MultiManager (datasets = datasets )
2373
+ mm = h5py . MultiManager (datasets = datasets )
2372
2374
2373
2375
# Selections to read from
2374
2376
sel = [np .s_ [0 :10 , 0 :10 , 0 :10 ], np .s_ [0 :5 , 5 :10 , 1 :4 :2 ], np .s_ [4 , 5 , 6 ]]
@@ -2379,15 +2381,15 @@ def test_multi_selection_rw(self):
2379
2381
2380
2382
# If selection list has only a single element, apply it to all dsets
2381
2383
sel = [np .s_ [0 :10 , 0 :10 , 0 :10 ]]
2382
- data_out = mm [sel [ 0 ] ]
2384
+ data_out = mm [sel ]
2383
2385
2384
2386
for d in data_out :
2385
2387
np .testing .assert_array_equal (d , data_in [sel [0 ]])
2386
2388
2387
2389
# Selections to write to
2388
2390
sel = [np .s_ [0 :10 , 0 :10 , 0 :10 ], np .s_ [0 :5 , 0 :5 , 0 :5 ], np .s_ [0 , 0 , 0 ]]
2389
2391
data_in = [np .zeros_like (data_in ), np .ones_like (data_in ), np .full_like (data_in , 2 )]
2390
- mm [sel ] = data_in
2392
+ mm [sel ] = [ data_in [ i ][ sel [ i ]] for i in range ( count )]
2391
2393
2392
2394
for i in range (count ):
2393
2395
np .testing .assert_array_equal (self .f ["data" + str (i )][sel [i ]], data_in [i ][sel [i ]])
0 commit comments