Skip to content

Commit c08e413

Browse files
committed
Strictly forbid the use of chunks and blocks keys in cparams dict
1 parent 1f287bd commit c08e413

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

blosc2/ndarray.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,3 +658,7 @@ def _check_ndarray_kwargs(**kwargs):
658658
f" keyword arguments"
659659
f", and you passed {str(key)}"
660660
)
661+
if "cparams" in kwargs and "chunks" in kwargs["cparams"]:
662+
raise ValueError("You cannot pass chunks in cparams, use `chunks` argument instead")
663+
if "cparams" in kwargs and "blocks" in kwargs["cparams"]:
664+
raise ValueError("You cannot pass chunks in cparams, use `blocks` argument instead")

tests/ndarray/test_empty.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,16 @@ def test_empty_minimal(shape, dtype):
110110
assert all(c >= b for c, b in zip(a.chunks, a.blocks))
111111
assert a.dtype == dtype
112112
assert a.schunk.typesize == dtype.itemsize
113+
114+
115+
@pytest.mark.parametrize(
116+
"shape, cparams",
117+
[
118+
(100, dict(chunks=(10,))),
119+
((100,), dict(blocks=(10,))),
120+
((100,), dict(chunks=(10,), blocks=(10,))),
121+
],
122+
)
123+
def test_cparams_chunks_blocks(shape, cparams):
124+
with pytest.raises(ValueError):
125+
blosc2.empty(shape, cparams=cparams)

0 commit comments

Comments
 (0)