Skip to content

Commit 0ae77c7

Browse files
manztjoshmoore
andauthored
Only inspect alternate node type if desired isn't present (#696)
Co-authored-by: Josh Moore <j.a.moore@dundee.ac.uk>
1 parent e40c51e commit 0ae77c7

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

zarr/creation.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -507,9 +507,9 @@ def open_array(
507507
# ensure store is initialized
508508

509509
if mode in ['r', 'r+']:
510-
if contains_group(store, path=path):
511-
raise ContainsGroupError(path)
512-
elif not contains_array(store, path=path):
510+
if not contains_array(store, path=path):
511+
if contains_group(store, path=path):
512+
raise ContainsGroupError(path)
513513
raise ArrayNotFoundError(path)
514514

515515
elif mode == 'w':
@@ -519,9 +519,9 @@ def open_array(
519519
object_codec=object_codec, chunk_store=chunk_store)
520520

521521
elif mode == 'a':
522-
if contains_group(store, path=path):
523-
raise ContainsGroupError(path)
524-
elif not contains_array(store, path=path):
522+
if not contains_array(store, path=path):
523+
if contains_group(store, path=path):
524+
raise ContainsGroupError(path)
525525
init_array(store, shape=shape, chunks=chunks, dtype=dtype,
526526
compressor=compressor, fill_value=fill_value,
527527
order=order, filters=filters, path=path,

zarr/hierarchy.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,18 +1162,18 @@ def open_group(store=None, mode='a', cache_attrs=True, synchronizer=None, path=N
11621162
# ensure store is initialized
11631163

11641164
if mode in ['r', 'r+']:
1165-
if contains_array(store, path=path):
1166-
raise ContainsArrayError(path)
1167-
elif not contains_group(store, path=path):
1165+
if not contains_group(store, path=path):
1166+
if contains_array(store, path=path):
1167+
raise ContainsArrayError(path)
11681168
raise GroupNotFoundError(path)
11691169

11701170
elif mode == 'w':
11711171
init_group(store, overwrite=True, path=path, chunk_store=chunk_store)
11721172

11731173
elif mode == 'a':
1174-
if contains_array(store, path=path):
1175-
raise ContainsArrayError(path)
11761174
if not contains_group(store, path=path):
1175+
if contains_array(store, path=path):
1176+
raise ContainsArrayError(path)
11771177
init_group(store, path=path, chunk_store=chunk_store)
11781178

11791179
elif mode in ['w-', 'x']:

0 commit comments

Comments
 (0)