@@ -900,13 +900,20 @@ def mock_walker_no_slash(_path):
900
900
@pytest .mark .skipif (have_fsspec is False , reason = "needs fsspec" )
901
901
class TestFSStore (StoreTests ):
902
902
903
- def create_store (self , normalize_keys = False , dimension_separator = "." ):
904
- path = tempfile .mkdtemp ()
905
- atexit .register (atexit_rmtree , path )
903
+ def create_store (self , normalize_keys = False ,
904
+ dimension_separator = "." ,
905
+ path = None ,
906
+ ** kwargs ):
907
+
908
+ if path is None :
909
+ path = tempfile .mkdtemp ()
910
+ atexit .register (atexit_rmtree , path )
911
+
906
912
store = FSStore (
907
913
path ,
908
914
normalize_keys = normalize_keys ,
909
- dimension_separator = dimension_separator )
915
+ dimension_separator = dimension_separator ,
916
+ ** kwargs )
910
917
return store
911
918
912
919
def test_init_array (self ):
@@ -937,8 +944,9 @@ def test_dimension_separator(self):
937
944
def test_complex (self ):
938
945
path1 = tempfile .mkdtemp ()
939
946
path2 = tempfile .mkdtemp ()
940
- store = FSStore ("simplecache::file://" + path1 ,
941
- simplecache = {"same_names" : True , "cache_storage" : path2 })
947
+ store = self .create_store (path = "simplecache::file://" + path1 ,
948
+ simplecache = {"same_names" : True ,
949
+ "cache_storage" : path2 })
942
950
assert not store
943
951
assert not os .listdir (path1 )
944
952
assert not os .listdir (path2 )
@@ -949,6 +957,20 @@ def test_complex(self):
949
957
assert store ["foo" ] == b"hello"
950
958
assert 'foo' in os .listdir (path2 )
951
959
960
+ def test_deep_ndim (self ):
961
+ import zarr
962
+
963
+ store = self .create_store ()
964
+ foo = zarr .open_group (store = store )
965
+ bar = foo .create_group ("bar" )
966
+ baz = bar .create_dataset ("baz" ,
967
+ shape = (4 , 4 , 4 ),
968
+ chunks = (2 , 2 , 2 ),
969
+ dtype = "i8" )
970
+ baz [:] = 1
971
+ assert set (store .listdir ()) == set ([".zgroup" , "bar" ])
972
+ assert foo ["bar" ]["baz" ][(0 , 0 , 0 )] == 1
973
+
952
974
def test_not_fsspec (self ):
953
975
import zarr
954
976
path = tempfile .mkdtemp ()
@@ -979,10 +1001,10 @@ def test_create(self):
979
1001
def test_read_only (self ):
980
1002
path = tempfile .mkdtemp ()
981
1003
atexit .register (atexit_rmtree , path )
982
- store = FSStore ( path )
1004
+ store = self . create_store ( path = path )
983
1005
store ['foo' ] = b"bar"
984
1006
985
- store = FSStore ( path , mode = 'r' )
1007
+ store = self . create_store ( path = path , mode = 'r' )
986
1008
987
1009
with pytest .raises (PermissionError ):
988
1010
store ['foo' ] = b"hex"
@@ -1000,11 +1022,11 @@ def test_read_only(self):
1000
1022
1001
1023
filepath = os .path .join (path , "foo" )
1002
1024
with pytest .raises (ValueError ):
1003
- FSStore ( filepath , mode = 'r' )
1025
+ self . create_store ( path = filepath , mode = 'r' )
1004
1026
1005
1027
def test_eq (self ):
1006
- store1 = FSStore ( "anypath" )
1007
- store2 = FSStore ( "anypath" )
1028
+ store1 = self . create_store ( path = "anypath" )
1029
+ store2 = self . create_store ( path = "anypath" )
1008
1030
assert store1 == store2
1009
1031
1010
1032
@pytest .mark .usefixtures ("s3" )
@@ -1300,10 +1322,13 @@ def test_filters(self):
1300
1322
1301
1323
@pytest .mark .skipif (have_fsspec is False , reason = "needs fsspec" )
1302
1324
class TestN5FSStore (TestFSStore ):
1303
- def create_store (self , normalize_keys = False ):
1304
- path = tempfile .mkdtemp ()
1305
- atexit .register (atexit_rmtree , path )
1306
- store = N5FSStore (path , normalize_keys = normalize_keys )
1325
+ def create_store (self , normalize_keys = False , path = None , ** kwargs ):
1326
+
1327
+ if path is None :
1328
+ path = tempfile .mkdtemp ()
1329
+ atexit .register (atexit_rmtree , path )
1330
+
1331
+ store = N5FSStore (path , normalize_keys = normalize_keys , ** kwargs )
1307
1332
return store
1308
1333
1309
1334
def test_equal (self ):
@@ -1375,8 +1400,9 @@ def test_init_group_overwrite_chunk_store(self):
1375
1400
self ._test_init_group_overwrite_chunk_store ('C' )
1376
1401
1377
1402
def test_dimension_separator (self ):
1378
- with pytest .raises (TypeError ):
1379
- self .create_store (key_separator = '.' )
1403
+
1404
+ with pytest .warns (UserWarning , match = 'dimension_separator' ):
1405
+ self .create_store (dimension_separator = '/' )
1380
1406
1381
1407
1382
1408
@pytest .mark .skipif (have_fsspec is False , reason = "needs fsspec" )
0 commit comments