8000 `zarr.group` now accept the `meta_array` argument (#1489) · keller-mark/zarr-python@12af7f1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 12af7f1

Browse files
authored
zarr.group now accept the meta_array argument (zarr-developers#1489)
* group() now takes the meta_array * added tests
1 parent 0cedd98 commit 12af7f1

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

zarr/hierarchy.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1360,7 +1360,8 @@ def group(
13601360
synchronizer=None,
13611361
path=None,
13621362
*,
1363-
zarr_version=None
1363+
zarr_version=None,
1364+
meta_array=None
13641365
):
13651366
"""Create a group.
13661367
@@ -1382,6 +1383,11 @@ def group(
13821383
Array synchronizer.
13831384
path : string, optional
13841385
Group path within store.
1386+
meta_array : array-like, optional
1387+
An array instance to use for determining arrays to create and return
1388+
to users. Use `numpy.empty(())` by default.
1389+
1390+
.. versionadded:: 2.16.1
13851391
13861392
Returns
13871393
-------
@@ -1432,6 +1438,7 @@ def group(
14321438
synchronizer=synchronizer,
14331439
path=path,
14341440
zarr_version=zarr_version,
1441+
meta_array=meta_array,
14351442
)
14361443

14371444

zarr/tests/test_meta_array.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import zarr.codecs
1010
from zarr.core import Array
1111
from zarr.creation import array, empty, full, ones, open_array, zeros
12-
from zarr.hierarchy import open_group
12+
from zarr.hierarchy import open_group, group
1313
from zarr.storage import DirectoryStore, MemoryStore, Store, ZipStore
1414

1515

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

236236

237+
@pytest.mark.parametrize("group_create_function", [group, open_group])
237238
@pytest.mark.parametrize("module, compressor", param_module_and_compressor)
238239
@pytest.mark.parametrize("store_type", [None, DirectoryStore, MemoryStore, ZipStore])
239-
def test_group(tmp_path, module, compressor, store_type):
240+
def test_group(tmp_path, group_create_function, module, compressor, store_type):
240241
xp = ensure_module(module)
241242
store = init_store(tmp_path, store_type)
242-
g = open_group(store, meta_array=xp.empty(()))
243+
g = group_create_function(store, meta_array=xp.empty(()))
243244
g.ones("data", shape=(10, 11), dtype=int, compressor=compressor)
244245
a = g["data"]
245246
ass 3827 ert a.shape == (10, 11)

0 commit comments

Comments
 (0)
0