From 88448fc2fbe5474a4a24cb6c83c4f09b652deefb Mon Sep 17 00:00:00 2001 From: "Mads R. B. Kristensen" Date: Mon, 7 Aug 2023 11:05:51 +0200 Subject: [PATCH 1/2] group() now takes the meta_array --- zarr/hierarchy.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/zarr/hierarchy.py b/zarr/hierarchy.py index c7cc5c6fe..3361969f0 100644 --- a/zarr/hierarchy.py +++ b/zarr/hierarchy.py @@ -1360,7 +1360,8 @@ def group( synchronizer=None, path=None, *, - zarr_version=None + zarr_version=None, + meta_array=None ): """Create a group. @@ -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 ------- @@ -1432,6 +1438,7 @@ def group( synchronizer=synchronizer, path=path, zarr_version=zarr_version, + meta_array=meta_array, ) From dd4a64d46c8a9b17ea75ea7688099672f5a0fe38 Mon Sep 17 00:00:00 2001 From: "Mads R. B. Kristensen" Date: Mon, 7 Aug 2023 11:14:57 +0200 Subject: [PATCH 2/2] added tests --- zarr/tests/test_meta_array.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/zarr/tests/test_meta_array.py b/zarr/tests/test_meta_array.py index 39394bd69..2545c6d62 100644 --- a/zarr/tests/test_meta_array.py +++ b/zarr/tests/test_meta_array.py @@ -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 @@ -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)