@@ -187,14 +187,16 @@ def test_full_additional_dtypes(zarr_version):
187187 full (100 , chunks = 10 , fill_value = v , dtype = 'U3' )
188188
189189
190+ @pytest .mark .parametrize ('dimension_separator' , ['.' , '/' , None ])
190191@pytest .mark .parametrize ('zarr_version' , [None , 2 , 3 ])
191- def test_open_array (zarr_version ):
192+ def test_open_array (zarr_version , dimension_separator ):
192193
193194 store = 'data/array.zarr'
194195 kwargs = _init_creation_kwargs (zarr_version )
195196
196197 # mode == 'w'
197- z = open_array (store , mode = 'w' , shape = 100 , chunks = 10 , ** kwargs )
198+ z = open_array (store , mode = 'w' , shape = 100 , chunks = 10 ,
199+ dimension_separator = dimension_separator , ** kwargs )
198200 z [:] = 42
199201 assert isinstance (z , Array )
200202 if z ._store ._store_version == 2 :
@@ -205,6 +207,11 @@ def test_open_array(zarr_version):
205207 assert (10 ,) == z .chunks
206208 assert_array_equal (np .full (100 , fill_value = 42 ), z [:])
207209
210+ if dimension_separator is None :
211+ assert z ._dimension_separator == '/' if zarr_version == 3 else '.'
212+ else :
213+ assert z ._dimension_separator == dimension_separator
214+
208215 # mode in 'r', 'r+'
209216 group_kwargs = kwargs .copy ()
210217 if zarr_version == 3 :
@@ -299,6 +306,37 @@ def test_open_array(zarr_version):
299306 assert os .path .abspath (chunk_store ) == z .chunk_store .path
300307
301308
309+ @pytest .mark .parametrize ('dimension_separator' , ['.' , '/' , None ])
310+ @pytest .mark .parametrize ('zarr_version' , [2 , 3 ])
311+ def test_open_array_infer_separator_from_store (zarr_version , dimension_separator ):
312+
313+ if zarr_version == 3 :
314+ StoreClass = DirectoryStoreV3
315+ path = 'data'
316+ else :
317+ StoreClass = DirectoryStore
318+ path = None
319+ store = StoreClass ('data/array.zarr' , dimension_separator = dimension_separator )
320+
321+ # Note: no dimension_separator kwarg to open_array
322+ # we are testing here that it gets inferred from store
323+ z = open_array (store , path = path , mode = 'w' , shape = 100 , chunks = 10 )
324+ z [:] = 42
325+ assert isinstance (z , Array )
326+ if z ._store ._store_version == 2 :
327+ assert isinstance (z .store , DirectoryStore )
328+ else :
329+ assert isinstance (z .store , DirectoryStoreV3 )
330+ assert (100 ,) == z .shape
331+ assert (10 ,) == z .chunks
332+ assert_array_equal (np .full (100 , fill_value = 42 ), z [:])
333+
334+ if dimension_separator is None :
335+ assert z ._dimension_separator == '/' if zarr_version == 3 else '.'
336+ else :
337+ assert z ._dimension_separator == dimension_separator
338+
339+
302340# TODO: N5 support for v3
303341@pytest .mark .parametrize ('zarr_version' , [None , 2 ])
304342def test_open_array_n5 (zarr_version ):
0 commit comments