@@ -1421,45 +1421,47 @@ def test_hexdigest(self):
1421
1421
assert '95d40c391f167db8b1290e3c39d9bf741edacdf6' == z .hexdigest ()
1422
1422
1423
1423
1424
- # TODO rely on backports and remove the PY2 exclusion
1425
- if not PY2 : # pragma: py2 no cover
1426
-
1427
- from zarr .codecs import LZMA
1428
-
1429
- class TestArrayWithLZMACompressor (TestArray ):
1430
-
1431
- def create_array (self , read_only = False , ** kwargs ):
1432
- store = dict ()
1433
- compressor = LZMA (preset = 1 )
1434
- kwargs .setdefault ('compressor' , compressor )
1435
- cache_metadata = kwargs .pop ('cache_metadata' , True )
1436
- cache_attrs = kwargs .pop ('cache_attrs' , True )
1437
- init_array (store , ** kwargs )
1438
- return Array (store , read_only = read_only , cache_metadata = cache_metadata ,
1439
- cache_attrs = cache_attrs )
1440
-
1441
- def test_hexdigest (self ):
1442
- # Check basic 1-D array
1443
- z = self .create_array (shape = (1050 ,), chunks = 100 , dtype = 'i4' )
1444
- assert '93ecaa530a1162a9d48a3c1dcee4586ccfc59bae' == z .hexdigest ()
1445
-
1446
- # Check basic 1-D array with different type
1447
- z = self .create_array (shape = (1050 ,), chunks = 100 , dtype = 'f4' )
1448
- assert '04a9755a0cd638683531b7816c7fa4fbb6f577f2' == z .hexdigest ()
1449
-
1450
- # Check basic 2-D array
1451
- z = self .create_array (shape = (20 , 35 ,), chunks = 10 , dtype = 'i4' )
1452
- assert 'b93b163a21e8500519250a6defb821d03eb5d9e0' == z .hexdigest ()
1453
-
1454
- # Check basic 1-D array with some data
1455
- z = self .create_array (shape = (1050 ,), chunks = 100 , dtype = 'i4' )
1456
- z [200 :400 ] = np .arange (200 , 400 , dtype = 'i4' )
1457
- assert 'cde499f3dc945b4e97197ff8e3cf8188a1262c35' == z .hexdigest ()
1458
-
1459
- # Check basic 1-D array with attributes
1460
- z = self .create_array (shape = (1050 ,), chunks = 100 , dtype = 'i4' )
1461
- z .attrs ['foo' ] = 'bar'
1462
- assert 'e2cf3afbf66ad0e28a2b6b68b1b07817c69aaee2' == z .hexdigest ()
1424
+ try :
1425
+ from numcodecs import LZMA
1426
+ except ImportError : # pragma: no cover
1427
+ LZMA = None
1428
+
1429
+
1430
+ @unittest .skipIf (LZMA is None , 'LZMA codec not available' )
1431
+ class TestArrayWithLZMACompressor (TestArray ):
1432
+
1433
+ def create_array (self , read_only = False , ** kwargs ):
1434
+ store = dict ()
1435
+ compressor = LZMA (preset = 1 )
1436
+ kwargs .setdefault ('compressor' , compressor )
1437
+ cache_metadata = kwargs .pop ('cache_metadata' , True )
1438
+ cache_attrs = kwargs .pop ('cache_attrs' , True )
1439
+ init_array (store , ** kwargs )
1440
+ return Array (store , read_only = read_only , cache_metadata = cache_metadata ,
1441
+ cache_attrs = cache_attrs )
1442
+
1443
+ def test_hexdigest (self ):
1444
+ # Check basic 1-D array
1445
+ z = self .create_array (shape = (1050 ,), chunks = 100 , dtype = 'i4' )
1446
+ assert '93ecaa530a1162a9d48a3c1dcee4586ccfc59bae' == z .hexdigest ()
1447
+
1448
+ # Check basic 1-D array with different type
1449
+ z = self .create_array (shape = (1050 ,), chunks = 100 , dtype = 'f4' )
1450
+ assert '04a9755a0cd638683531b7816c7fa4fbb6f577f2' == z .hexdigest ()
1451
+
1452
+ # Check basic 2-D array
1453
+ z = self .create_array (shape = (20 , 35 ,), chunks = 10 , dtype = 'i4' )
1454
+ assert 'b93b163a21e8500519250a6defb821d03eb5d9e0' == z .hexdigest ()
1455
+
1456
+ # Check basic 1-D array with some data
1457
+ z = self .create_array (shape = (1050 ,), chunks = 100 , dtype = 'i4' )
1458
+ z [200 :400 ] = np .arange (200 , 400 , dtype = 'i4' )
1459
+ assert 'cde499f3dc945b4e97197ff8e3cf8188a1262c35' == z .hexdigest ()
1460
+
1461
+ # Check basic 1-D array with attributes
1462
+ z = self .create_array (shape = (1050 ,), chunks = 100 , dtype = 'i4' )
1463
+ z .attrs ['foo' ] = 'bar'
1464
+ assert 'e2cf3afbf66ad0e28a2b6b68b1b07817c69aaee2' == z .hexdigest ()
1463
1465
1464
1466
1465
1467
class TestArrayWithFilters (TestArray ):
0 commit comments