File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -304,13 +304,18 @@ def invert_chunk_coords(key):
304
304
def group_metadata_to_n5 (group_metadata ):
305
305
'''Convert group metadata from zarr to N5 format.'''
306
306
del group_metadata ['zarr_format' ]
307
+ # TODO: This should only exist at the top-level
307
308
group_metadata ['n5' ] = '2.0.0'
308
309
return group_metadata
309
310
310
311
311
312
def group_metadata_to_zarr (group_metadata ):
312
313
'''Convert group metadata from N5 to zarr format.'''
313
- del group_metadata ['n5' ]
314
+ try :
315
+ group_metadata .pop ('n5' )
316
+ except KeyError :
317
+ # This only exists at the top level
318
+ pass
314
319
group_metadata ['zarr_format' ] = ZARR_FORMAT
315
320
return group_metadata
316
321
Original file line number Diff line number Diff line change @@ -252,6 +252,24 @@ def test_open_array():
252
252
assert (10 ,) == z .chunks
253
253
assert_array_equal (np .full (100 , fill_value = 42 ), z [:])
254
254
255
+ store = 'data/group.n5'
256
+ z = open_group (store , mode = 'w' )
257
+ i = z .create_group ('inner' )
258
+ a = i .zeros ("array" , shape = 100 , chunks = 10 )
259
+ a [:] = 42
260
+
261
+ # Edit inner/attributes.json to not include "n5"
262
+ with open ('data/group.n5/inner/attributes.json' , 'w' ) as o :
263
+ o .write ("{}" )
264
+
265
+ # Re-open
266
+ a = open_group (store )["inner" ]["array" ]
267
+ assert isinstance (a , Array )
268
+ assert isinstance (z .store , N5Store )
269
+ assert (100 ,) == a .shape
270
+ assert (10 ,) == a .chunks
271
+ assert_array_equal (np .full (100 , fill_value = 42 ), a [:])
272
+
255
273
256
274
def test_empty_like ():
257
275
You can’t perform that action at this time.
0 commit comments