Skip to content

Commit f50e9cd

Browse files
committed
Test public API
1 parent db731e8 commit f50e9cd

File tree

1 file changed

+34
-3
lines changed

1 file changed

+34
-3
lines changed

tests/test_api.py

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,7 +1303,38 @@ def test_no_overwrite_load(tmp_path: Path) -> None:
13031303
assert existing_fpath.exists()
13041304

13051305

1306-
def test_auto_chunks() -> None:
1307-
# Check chunks are automatically set to a sensible default
1308-
a = zarr.ones(shape=(1000, 1000), dtype=np.uint8)
1306+
@pytest.mark.parametrize(
1307+
"f",
1308+
[
1309+
zarr.array,
1310+
zarr.create,
1311+
zarr.create_array,
1312+
zarr.ones,
1313+
zarr.ones_like,
1314+
zarr.empty,
1315+
zarr.empty_like,
1316+
zarr.full,
1317+
zarr.full_like,
1318+
zarr.zeros,
1319+
zarr.zeros_like,
1320+
],
1321+
)
1322+
def test_auto_chunks(f: Callable[..., Array]) -> None:
1323+
# Make sure chunks are set automatically across the public API
1324+
shape = (1000, 1000)
1325+
dtype = np.uint8
1326+
kwargs = {"shape": shape, "dtype": dtype}
1327+
array = np.zeros(shape, dtype=dtype)
1328+
store = zarr.storage.MemoryStore()
1329+
1330+
if f in [zarr.full, zarr.full_like]:
1331+
kwargs["fill_value"] = 0
1332+
if f in [zarr.array]:
1333+
kwargs["data"] = array
1334+
if f in [zarr.empty_like, zarr.full_like, zarr.empty_like, zarr.ones_like, zarr.zeros_like]:
1335+
kwargs["a"] = array
1336+
if f in [zarr.create_array]:
1337+
kwargs["store"] = store
1338+
1339+
a = f(**kwargs)
13091340
assert a.chunks == (500, 500)

0 commit comments

Comments
 (0)