Skip to content

Commit 897b708

Browse files
committed
Deal with chunks/blocks set to None
1 parent cb5f638 commit 897b708

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/blosc2/lazyexpr.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -912,10 +912,15 @@ def fast_eval( # noqa: C901
912912

913913
# Get the shape of the base array
914914
shape = basearr.shape
915-
chunks = basearr.chunks
915+
chunks = kwargs.pop("chunks", None)
916+
if chunks is None:
917+
chunks = basearr.chunks
918+
blocks = kwargs.pop("blocks", None)
919+
if blocks is None:
920+
blocks = basearr.blocks
916921
# Check whether the partitions are aligned and behaved
917-
aligned = blosc2.are_partitions_aligned(shape, chunks, basearr.blocks)
918-
behaved = blosc2.are_partitions_behaved(shape, chunks, basearr.blocks)
922+
aligned = blosc2.are_partitions_aligned(shape, chunks, blocks)
923+
behaved = blosc2.are_partitions_behaved(shape, chunks, blocks)
919924

920925
# Check that all operands are NDArray for fast path
921926
all_ndarray = all(isinstance(value, blosc2.NDArray) and value.shape != () for value in operands.values())
@@ -972,7 +977,7 @@ def fast_eval( # noqa: C901
972977
if getitem:
973978
out = np.empty(shape, dtype=dtype)
974979
else:
975-
out = blosc2.empty(shape, chunks=chunks, blocks=basearr.blocks, dtype=dtype, **kwargs)
980+
out = blosc2.empty(shape, chunks=chunks, blocks=blocks, dtype=dtype, **kwargs)
976981

977982
# Store the result in the output array
978983
if getitem:

src/blosc2/ndarray.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3521,7 +3521,10 @@ def _check_ndarray_kwargs(**kwargs): # noqa: C901
35213521
)
35223522

35233523
if "cparams" in kwargs:
3524-
if isinstance(kwargs["cparams"], blosc2.CParams):
3524+
cparams = kwargs["cparams"]
3525+
if cparams is None:
3526+
kwargs["cparams"] = blosc2.cparams_dflts
3527+
if isinstance(cparams, blosc2.CParams):
35253528
kwargs["cparams"] = asdict(kwargs["cparams"])
35263529
else:
35273530
if "chunks" in kwargs["cparams"]:

0 commit comments

Comments
 (0)