@@ -187,14 +187,16 @@ def test_full_additional_dtypes(zarr_version):
187
187
full (100 , chunks = 10 , fill_value = v , dtype = 'U3' )
188
188
189
189
190
+ @pytest .mark .parametrize ('dimension_separator' , ['.' , '/' , None ])
190
191
@pytest .mark .parametrize ('zarr_version' , [None , 2 , 3 ])
191
- def test_open_array (zarr_version ):
192
+ def test_open_array (zarr_version , dimension_separator ):
192
193
193
194
store = 'data/array.zarr'
194
195
kwargs = _init_creation_kwargs (zarr_version )
195
196
196
197
# 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 )
198
200
z [:] = 42
199
201
assert isinstance (z , Array )
200
202
if z ._store ._store_version == 2 :
@@ -205,6 +207,11 @@ def test_open_array(zarr_version):
205
207
assert (10 ,) == z .chunks
206
208
assert_array_equal (np .full (100 , fill_value = 42 ), z [:])
207
209
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
+
208
215
# mode in 'r', 'r+'
209
216
group_kwargs = kwargs .copy ()
210
217
if zarr_version == 3 :
@@ -299,6 +306,37 @@ def test_open_array(zarr_version):
299
306
assert os .path .abspath (chunk_store ) == z .chunk_store .path
300
307
301
308
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
+
302
340
# TODO: N5 support for v3
303
341
@pytest .mark .parametrize ('zarr_version' , [None , 2 ])
304
342
def test_open_array_n5 (zarr_version ):
0 commit comments