Skip to content

Commit

Permalink
Mode is not one of the kwargs create_dataset takes
Browse files Browse the repository at this point in the history
It triggers a warnings that make the test-suite fails on strict mode.
  • Loading branch information
Carreau committed Dec 2, 2020
1 parent 676b310 commit 28ed49d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
12 changes: 10 additions & 2 deletions zarr/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,16 @@ class Array(object):
"""

def __init__(self, store:Store, path=None, read_only=False, chunk_store=None,
synchronizer=None, cache_metadata=True, cache_attrs=True):
def __init__(
self,
store: Store,
path=None,
read_only=False,
chunk_store=None,
synchronizer=None,
cache_metadata=True,
cache_attrs=True,
):
# N.B., expect at this point store is fully initialized with all
# configuration metadata fully specified and normalized

Expand Down
2 changes: 2 additions & 0 deletions zarr/hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -816,11 +816,13 @@ def create_dataset(self, name, **kwargs):
<zarr.core.Array '/bar/baz/qux' (100, 100, 100) float64>
"""
assert "mode" not in kwargs

return self._write_op(self._create_dataset_nosync, name, **kwargs)

def _create_dataset_nosync(self, name, data=None, **kwargs):

assert "mode" not in kwargs
path = self._item_path(name)

# determine synchronizer
Expand Down
10 changes: 6 additions & 4 deletions zarr/tests/test_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -1033,11 +1033,13 @@ def test_s3_complex(self):

with pytest.raises(PermissionError):
# even though overwrite=True, store is read-only, so fails
g2.create_dataset("data", shape=(8, 8, 8), mode='w',
fill_value=-1, chunks=(1, 1, 1), overwrite=True)
g2.create_dataset(
"data", shape=(8, 8, 8), fill_value=-1, chunks=(1, 1, 1), overwrite=True
)

a = g.create_dataset("data", shape=(8, 8, 8), mode='w',
fill_value=-1, chunks=(1, 1, 1), overwrite=True)
a = g.create_dataset(
"data", shape=(8, 8, 8), fill_value=-1, chunks=(1, 1, 1), overwrite=True
)
assert (a[:] == -np.ones((8, 8, 8))).all()


Expand Down

0 comments on commit 28ed49d

Please sign in to comment.