Skip to content

Commit

Permalink
Deal with chunks/blocks set to None
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancescAlted committed Jan 22, 2025
1 parent cb5f638 commit 897b708
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
13 changes: 9 additions & 4 deletions src/blosc2/lazyexpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -912,10 +912,15 @@ def fast_eval( # noqa: C901

# Get the shape of the base array
shape = basearr.shape
chunks = basearr.chunks
chunks = kwargs.pop("chunks", None)
if chunks is None:
chunks = basearr.chunks
blocks = kwargs.pop("blocks", None)
if blocks is None:
blocks = basearr.blocks
# Check whether the partitions are aligned and behaved
aligned = blosc2.are_partitions_aligned(shape, chunks, basearr.blocks)
behaved = blosc2.are_partitions_behaved(shape, chunks, basearr.blocks)
aligned = blosc2.are_partitions_aligned(shape, chunks, blocks)
behaved = blosc2.are_partitions_behaved(shape, chunks, blocks)

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

# Store the result in the output array
if getitem:
Expand Down
5 changes: 4 additions & 1 deletion src/blosc2/ndarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -3521,7 +3521,10 @@ def _check_ndarray_kwargs(**kwargs): # noqa: C901
)

if "cparams" in kwargs:
if isinstance(kwargs["cparams"], blosc2.CParams):
cparams = kwargs["cparams"]
if cparams is None:
kwargs["cparams"] = blosc2.cparams_dflts
if isinstance(cparams, blosc2.CParams):
kwargs["cparams"] = asdict(kwargs["cparams"])
else:
if "chunks" in kwargs["cparams"]:
Expand Down

0 comments on commit 897b708

Please sign in to comment.