Skip to content

Commit

Permalink
Ensure zarr.create uses writeable mode (#1309)
Browse files Browse the repository at this point in the history
* Ensure zarr.create uses writeable mode

* Update release.rst

Added release notes for [#1309](#1309)

* Switch to bug fix

Co-authored-by: Josh Moore <[email protected]>
Co-authored-by: Sanket Verma <[email protected]>
  • Loading branch information
3 people committed Jan 16, 2023
1 parent 876ccf2 commit 1fd607a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
9 changes: 9 additions & 0 deletions docs/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ Release notes
.. _release_2.13.4:

2.13.5
------

Bug fixes
~~~~~~~~~

* Ensure ``zarr.create`` uses writeable mode to fix issue with :issue:`1304`.
By :user:`James Bourbeau <jrbourbeau>` :issue:`1309`.

2.13.4
------

Expand Down
2 changes: 1 addition & 1 deletion zarr/creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def create(shape, chunks=True, dtype=None, compressor='default',
zarr_version = getattr(chunk_store, '_store_version', DEFAULT_ZARR_VERSION)

# handle polymorphic store arg
store = normalize_store_arg(store, zarr_version=zarr_version)
store = normalize_store_arg(store, zarr_version=zarr_version, mode="w")
zarr_version = getattr(store, '_store_version', DEFAULT_ZARR_VERSION)

# API compatibility with h5py
Expand Down
14 changes: 13 additions & 1 deletion zarr/tests/test_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from zarr._storage.store import v3_api_available
from zarr._storage.v3 import DirectoryStoreV3, KVStoreV3
from zarr.sync import ThreadSynchronizer
from zarr.tests.util import mktemp
from zarr.tests.util import mktemp, have_fsspec

_VERSIONS = ((None, 2, 3) if v3_api_available else (None, 2))
_VERSIONS2 = ((2, 3) if v3_api_available else (2, ))
Expand Down Expand Up @@ -429,6 +429,18 @@ def test_create_in_dict(zarr_version, at_root):
assert isinstance(a.store, expected_store_type)


@pytest.mark.skipif(have_fsspec is False, reason="needs fsspec")
@pytest.mark.parametrize('zarr_version', _VERSIONS)
@pytest.mark.parametrize('at_root', [False, True])
def test_create_writeable_mode(zarr_version, at_root, tmp_path):
# Regression test for https://github.com/zarr-developers/zarr-python/issues/1306
import fsspec
kwargs = _init_creation_kwargs(zarr_version, at_root)
store = fsspec.get_mapper(str(tmp_path))
z = create(100, store=store, **kwargs)
assert z.store.map == store


@pytest.mark.parametrize('zarr_version', _VERSIONS)
@pytest.mark.parametrize('at_root', [False, True])
def test_empty_like(zarr_version, at_root):
Expand Down

0 comments on commit 1fd607a

Please sign in to comment.