Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zarr.group now accept the meta_array argument #1489

Merged
merged 2 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion zarr/hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1360,7 +1360,8 @@ def group(
synchronizer=None,
path=None,
*,
zarr_version=None
zarr_version=None,
meta_array=None
):
"""Create a group.

Expand All @@ -1382,6 +1383,11 @@ def group(
Array synchronizer.
path : string, optional
Group path within store.
meta_array : array-like, optional
An array instance to use for determining arrays to create and return
to users. Use `numpy.empty(())` by default.

.. versionadded:: 2.16.1

Returns
-------
Expand Down Expand Up @@ -1432,6 +1438,7 @@ def group(
synchronizer=synchronizer,
path=path,
zarr_version=zarr_version,
meta_array=meta_array,
)


Expand Down
7 changes: 4 additions & 3 deletions zarr/tests/test_meta_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import zarr.codecs
from zarr.core import Array
from zarr.creation import array, empty, full, ones, open_array, zeros
from zarr.hierarchy import open_group
from zarr.hierarchy import open_group, group
from zarr.storage import DirectoryStore, MemoryStore, Store, ZipStore


Expand Down Expand Up @@ -234,12 +234,13 @@ def test_full(module, compressor):
assert np.all(np.isnan(z[:]))


@pytest.mark.parametrize("group_create_function", [group, open_group])
@pytest.mark.parametrize("module, compressor", param_module_and_compressor)
@pytest.mark.parametrize("store_type", [None, DirectoryStore, MemoryStore, ZipStore])
def test_group(tmp_path, module, compressor, store_type):
def test_group(tmp_path, group_create_function, module, compressor, store_type):
xp = ensure_module(module)
store = init_store(tmp_path, store_type)
g = open_group(store, meta_array=xp.empty(()))
g = group_create_function(store, meta_array=xp.empty(()))
g.ones("data", shape=(10, 11), dtype=int, compressor=compressor)
a = g["data"]
assert a.shape == (10, 11)
Expand Down