Skip to content

Commit

Permalink
Strictly forbid the use of chunks and blocks keys in cparams dict
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancescAlted committed Jul 25, 2023
1 parent 1f287bd commit c08e413
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions blosc2/ndarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,3 +658,7 @@ def _check_ndarray_kwargs(**kwargs):
f" keyword arguments"
f", and you passed {str(key)}"
)
if "cparams" in kwargs and "chunks" in kwargs["cparams"]:
raise ValueError("You cannot pass chunks in cparams, use `chunks` argument instead")
if "cparams" in kwargs and "blocks" in kwargs["cparams"]:
raise ValueError("You cannot pass chunks in cparams, use `blocks` argument instead")
13 changes: 13 additions & 0 deletions tests/ndarray/test_empty.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,16 @@ def test_empty_minimal(shape, dtype):
assert all(c >= b for c, b in zip(a.chunks, a.blocks))
assert a.dtype == dtype
assert a.schunk.typesize == dtype.itemsize


@pytest.mark.parametrize(
"shape, cparams",
[
(100, dict(chunks=(10,))),
((100,), dict(blocks=(10,))),
((100,), dict(chunks=(10,), blocks=(10,))),
],
)
def test_cparams_chunks_blocks(shape, cparams):
with pytest.raises(ValueError):
blosc2.empty(shape, cparams=cparams)

0 comments on commit c08e413

Please sign in to comment.