@@ -79,8 +79,11 @@ def test_array_init(self):
79
79
def create_array (self , read_only = False , ** kwargs ):
80
80
store = dict ()
81
81
kwargs .setdefault ('compressor' , Zlib (level = 1 ))
82
+ cache_metadata = kwargs .pop ('cache_metadata' , True )
83
+ cache_attrs = kwargs .pop ('cache_attrs' , True )
82
84
init_array (store , ** kwargs )
83
- return Array (store , read_only = read_only )
85
+ return Array (store , read_only = read_only , cache_metadata = cache_metadata ,
86
+ cache_attrs = cache_attrs )
84
87
85
88
def test_nbytes_stored (self ):
86
89
@@ -655,7 +658,8 @@ def test_read_only(self):
655
658
656
659
def test_pickle (self ):
657
660
658
- z = self .create_array (shape = 1000 , chunks = 100 , dtype = int )
661
+ z = self .create_array (shape = 1000 , chunks = 100 , dtype = int , cache_metadata = False ,
662
+ cache_attrs = False )
659
663
z [:] = np .random .randint (0 , 1000 , 1000 )
660
664
z2 = pickle .loads (pickle .dumps (z ))
661
665
eq (z .shape , z2 .shape )
@@ -664,6 +668,8 @@ def test_pickle(self):
664
668
if z .compressor :
665
669
eq (z .compressor .get_config (), z2 .compressor .get_config ())
666
670
eq (z .fill_value , z2 .fill_value )
671
+ eq (z ._cache_metadata , z2 ._cache_metadata )
672
+ eq (z .attrs .cache , z2 .attrs .cache )
667
673
assert_array_equal (z [:], z2 [:])
668
674
669
675
def test_np_ufuncs (self ):
@@ -1081,8 +1087,11 @@ class TestArrayWithPath(TestArray):
1081
1087
@staticmethod
1082
1088
def create_array (read_only = False , ** kwargs ):
1083
1089
store = dict ()
1090
+ cache_metadata = kwargs .pop ('cache_metadata' , True )
1091
+ cache_attrs = kwargs .pop ('cache_attrs' , True )
1084
1092
init_array (store , path = 'foo/bar' , ** kwargs )
1085
- return Array (store , path = 'foo/bar' , read_only = read_only )
1093
+ return Array (store , path = 'foo/bar' , read_only = read_only ,
1094
+ cache_metadata = cache_metadata , cache_attrs = cache_attrs )
1086
1095
1087
1096
def test_hexdigest (self ):
1088
1097
# Check basic 1-D array
@@ -1133,8 +1142,11 @@ def create_array(read_only=False, **kwargs):
1133
1142
store = dict ()
1134
1143
# separate chunk store
1135
1144
chunk_store = dict ()
1145
+ cache_metadata = kwargs .pop ('cache_metadata' , True )
1146
+ cache_attrs = kwargs .pop ('cache_attrs' , True )
1136
1147
init_array (store , chunk_store = chunk_store , ** kwargs )
1137
- return Array (store , read_only = read_only , chunk_store = chunk_store )
1148
+ return Array (store , read_only = read_only , chunk_store = chunk_store ,
1149
+ cache_metadata = cache_metadata , cache_attrs = cache_attrs )
1138
1150
1139
1151
def test_hexdigest (self ):
1140
1152
# Check basic 1-D array
@@ -1184,9 +1196,12 @@ def create_array(read_only=False, **kwargs):
1184
1196
path = mkdtemp ()
1185
1197
atexit .register (shutil .rmtree , path )
1186
1198
store = DirectoryStore (path )
1199
+ cache_metadata = kwargs .pop ('cache_metadata' , True )
1200
+ cache_attrs = kwargs .pop ('cache_attrs' , True )
1187
1201
kwargs .setdefault ('compressor' , Zlib (1 ))
1188
1202
init_array (store , ** kwargs )
1189
- return Array (store , read_only = read_only )
1203
+ return Array (store , read_only = read_only , cache_metadata = cache_metadata ,
1204
+ cache_attrs = cache_attrs )
1190
1205
1191
1206
def test_nbytes_stored (self ):
1192
1207
@@ -1206,9 +1221,12 @@ def create_array(read_only=False, **kwargs):
1206
1221
path = mkdtemp ()
1207
1222
atexit .register (shutil .rmtree , path )
1208
1223
store = NestedDirectoryStore (path )
1224
+ cache_metadata = kwargs .pop ('cache_metadata' , True )
1225
+ cache_attrs = kwargs .pop ('cache_attrs' , True )
1209
1226
kwargs .setdefault ('compressor' , Zlib (1 ))
1210
1227
init_array (store , ** kwargs )
1211
- return Array (store , read_only = read_only )
1228
+ return Array (store , read_only = read_only , cache_metadata = cache_metadata ,
1229
+ cache_attrs = cache_attrs )
1212
1230
1213
1231
1214
1232
class TestArrayWithDBMStore (TestArray ):
@@ -1218,9 +1236,12 @@ def create_array(read_only=False, **kwargs):
1218
1236
path = mktemp (suffix = '.anydbm' )
1219
1237
atexit .register (atexit_rmglob , path + '*' )
1220
1238
store = DBMStore (path , flag = 'n' )
1239
+ cache_metadata = kwargs .pop ('cache_metadata' , True )
1240
+ cache_attrs = kwargs .pop ('cache_attrs' , True )
1221
1241
kwargs .setdefault ('compressor' , Zlib (1 ))
1222
1242
init_array (store , ** kwargs )
1223
- return Array (store , read_only = read_only )
1243
+ return Array (store , read_only = read_only , cache_attrs = cache_attrs ,
1244
+ cache_metadata = cache_metadata )
1224
1245
1225
1246
def test_nbytes_stored (self ):
1226
1247
pass # not implemented
@@ -1236,9 +1257,12 @@ def create_array(read_only=False, **kwargs):
1236
1257
path = mktemp (suffix = '.dbm' )
1237
1258
atexit .register (os .remove , path )
1238
1259
store = DBMStore (path , flag = 'n' , open = bsddb3 .btopen )
1260
+ cache_metadata = kwargs .pop ('cache_metadata' , True )
1261
+ cache_attrs = kwargs .pop ('cache_attrs' , True )
1239
1262
kwargs .setdefault ('compressor' , Zlib (1 ))
1240
1263
init_array (store , ** kwargs )
1241
- return Array (store , read_only = read_only )
1264
+ return Array (store , read_only = read_only , cache_metadata = cache_metadata ,
1265
+ cache_attrs = cache_attrs )
1242
1266
1243
1267
def test_nbytes_stored (self ):
1244
1268
pass # not implemented
@@ -1257,9 +1281,12 @@ def create_array(read_only=False, **kwargs):
1257
1281
store = LMDBStore (path , buffers = True )
1258
1282
except ImportError : # pragma: no cover
1259
1283
raise SkipTest ('lmdb not installed' )
1284
+ cache_metadata = kwargs .pop ('cache_metadata' , True )
1285
+ cache_attrs = kwargs .pop ('cache_attrs' , True )
1260
1286
kwargs .setdefault ('compressor' , Zlib (1 ))
1261
1287
init_array (store , ** kwargs )
1262
- return Array (store , read_only = read_only )
1288
+ return Array (store , read_only = read_only , cache_metadata = cache_metadata ,
1289
+ cache_attrs = cache_attrs )
1263
1290
1264
1291
def test_nbytes_stored (self ):
1265
1292
pass # not implemented
@@ -1275,9 +1302,12 @@ def create_array(read_only=False, **kwargs):
1275
1302
store = LMDBStore (path , buffers = False )
1276
1303
except ImportError : # pragma: no cover
1277
1304
raise SkipTest ('lmdb not installed' )
1305
+ cache_metadata = kwargs .pop ('cache_metadata' , True )
1306
+ cache_attrs = kwargs .pop ('cache_attrs' , True )
1278
1307
kwargs .setdefault ('compressor' , Zlib (1 ))
1279
1308
init_array (store , ** kwargs )
1280
- return Array (store , read_only = read_only )
1309
+ return Array (store , read_only = read_only , cache_metadata = cache_metadata ,
1310
+ cache_attrs = cache_attrs )
1281
1311
1282
1312
def test_nbytes_stored (self ):
1283
1313
pass # not implemented
@@ -1288,8 +1318,11 @@ class TestArrayWithNoCompressor(TestArray):
1288
1318
def create_array (self , read_only = False , ** kwargs ):
1289
1319
store = dict ()
1290
1320
kwargs .setdefault ('compressor' , None )
1321
+ cache_metadata = kwargs .pop ('cache_metadata' , True )
1322
+ cache_attrs = kwargs .pop ('cache_attrs' , True )
1291
1323
init_array (store , ** kwargs )
1292
- return Array (store , read_only = read_only )
1324
+ return Array (store , read_only = read_only , cache_metadata = cache_metadata ,
1325
+ cache_attrs = cache_attrs )
1293
1326
1294
1327
def test_hexdigest (self ):
1295
1328
# Check basic 1-D array
@@ -1321,8 +1354,11 @@ def create_array(self, read_only=False, **kwargs):
1321
1354
store = dict ()
1322
1355
compressor = BZ2 (level = 1 )
1323
1356
kwargs .setdefault ('compressor' , compressor )
1357
+ cache_metadata = kwargs .pop ('cache_metadata' , True )
1358
+ cache_attrs = kwargs .pop ('cache_attrs' , True )
1324
1359
init_array (store , ** kwargs )
1325
- return Array (store , read_only = read_only )
1360
+ return Array (store , read_only = read_only , cache_metadata = cache_metadata ,
1361
+ cache_attrs = cache_attrs )
1326
1362
1327
1363
def test_hexdigest (self ):
1328
1364
# Check basic 1-D array
@@ -1354,8 +1390,11 @@ def create_array(self, read_only=False, **kwargs):
1354
1390
store = dict ()
1355
1391
compressor = Blosc (cname = 'zstd' , clevel = 1 , shuffle = 1 )
1356
1392
kwargs .setdefault ('compressor' , compressor )
1393
+ cache_metadata = kwargs .pop ('cache_metadata' , True )
1394
+ cache_attrs = kwargs .pop ('cache_attrs' , True )
1357
1395
init_array (store , ** kwargs )
1358
- return Array (store , read_only = read_only )
1396
+ return Array (store , read_only = read_only , cache_metadata = cache_metadata ,
1397
+ cache_attrs = cache_attrs )
1359
1398
1360
1399
def test_hexdigest (self ):
1361
1400
# Check basic 1-D array
@@ -1392,8 +1431,11 @@ def create_array(self, read_only=False, **kwargs):
1392
1431
store = dict ()
1393
1432
compressor = LZMA (preset = 1 )
1394
1433
kwargs .setdefault ('compressor' , compressor )
1434
+ cache_metadata = kwargs .pop ('cache_metadata' , True )
1435
+ cache_attrs = kwargs .pop ('cache_attrs' , True )
1395
1436
init_array (store , ** kwargs )
1396
- return Array (store , read_only = read_only )
1437
+ return Array (store , read_only = read_only , cache_metadata = cache_metadata ,
1438
+ cache_attrs = cache_attrs )
1397
1439
1398
1440
def test_hexdigest (self ):
1399
1441
# Check basic 1-D array
@@ -1432,8 +1474,11 @@ def create_array(read_only=False, **kwargs):
1432
1474
kwargs .setdefault ('filters' , filters )
1433
1475
compressor = Zlib (1 )
1434
1476
kwargs .setdefault ('compressor' , compressor )
1477
+ cache_metadata = kwargs .pop ('cache_metadata' , True )
1478
+ cache_attrs = kwargs .pop ('cache_attrs' , True )
1435
1479
init_array (store , ** kwargs )
1436
- return Array (store , read_only = read_only )
1480
+ return Array (store , read_only = read_only , cache_attrs = cache_attrs ,
1481
+ cache_metadata = cache_metadata )
1437
1482
1438
1483
def test_hexdigest (self ):
1439
1484
# Check basic 1-D array
@@ -1555,8 +1600,11 @@ class TestArrayWithCustomMapping(TestArray):
1555
1600
def create_array (read_only = False , ** kwargs ):
1556
1601
store = CustomMapping ()
1557
1602
kwargs .setdefault ('compressor' , Zlib (1 ))
1603
+ cache_metadata = kwargs .pop ('cache_metadata' , True )
1604
+ cache_attrs = kwargs .pop ('cache_attrs' , True )
1558
1605
init_array (store , ** kwargs )
1559
- return Array (store , read_only = read_only )
1606
+ return Array (store , read_only = read_only , cache_metadata = cache_metadata ,
1607
+ cache_attrs = cache_attrs )
1560
1608
1561
1609
def test_nbytes_stored (self ):
1562
1610
z = self .create_array (shape = 1000 , chunks = 100 )
@@ -1571,12 +1619,14 @@ class TestArrayNoCache(TestArray):
1571
1619
def create_array (read_only = False , ** kwargs ):
1572
1620
store = dict ()
1573
1621
kwargs .setdefault ('compressor' , Zlib (level = 1 ))
1622
+ cache_metadata = kwargs .pop ('cache_metadata' , True )
1623
+ cache_attrs = kwargs .pop ('cache_attrs' , True )
1574
1624
init_array (store , ** kwargs )
1575
- return Array (store , read_only = read_only , cache_metadata = False ,
1576
- cache_attrs = False )
1625
+ return Array (store , read_only = read_only , cache_metadata = cache_metadata ,
1626
+ cache_attrs = cache_attrs )
1577
1627
1578
1628
def test_cache_metadata (self ):
1579
- a1 = self .create_array (shape = 100 , chunks = 10 , dtype = 'i1' )
1629
+ a1 = self .create_array (shape = 100 , chunks = 10 , dtype = 'i1' , cache_metadata = False )
1580
1630
a2 = Array (a1 .store , cache_metadata = True )
1581
1631
eq (a1 .shape , a2 .shape )
1582
1632
eq (a1 .size , a2 .size )
@@ -1616,7 +1666,7 @@ def test_cache_metadata(self):
1616
1666
eq (30 , a2 .nchunks )
1617
1667
1618
1668
def test_cache_attrs (self ):
1619
- a1 = self .create_array (shape = 100 , chunks = 10 , dtype = 'i1' )
1669
+ a1 = self .create_array (shape = 100 , chunks = 10 , dtype = 'i1' , cache_attrs = False )
1620
1670
a2 = Array (a1 .store , cache_attrs = True )
1621
1671
eq (a1 .attrs .asdict (), a2 .attrs .asdict ())
1622
1672
0 commit comments