Skip to content

Commit

Permalink
zarr.group now accept the meta_array argument (#1489)
Browse files Browse the repository at this point in the history
* group() now takes the meta_array

* added tests
  • Loading branch information
madsbk authored Aug 11, 2023
1 parent 0cedd98 commit 12af7f1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
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

0 comments on commit 12af7f1

Please sign in to comment.