Skip to content

Commit 9712a0b

Browse files
committed
Fix for chained constructors
1 parent 77ab92e commit 9712a0b

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

src/blosc2/lazyexpr.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2561,11 +2561,20 @@ def shape(self):
25612561
return None
25622562

25632563
# Operands shape can change, so we always need to recompute this
2564-
_shape, chunks, blocks, fast_path = validate_inputs(self.operands, getattr(self, "_out", None))
2565-
if fast_path:
2566-
# fast_path ensure that all the operands have the same partitions
2567-
self._chunks = chunks
2568-
self._blocks = blocks
2564+
try:
2565+
_shape, chunks, blocks, fast_path = validate_inputs(self.operands, getattr(self, "_out", None))
2566+
if fast_path:
2567+
# fast_path ensure that all the operands have the same partitions
2568+
self._chunks = chunks
2569+
self._blocks = blocks
2570+
except ValueError as e:
2571+
if any(constructor in self.expression for constructor in constructors):
2572+
# might have an expression with pure constructors
2573+
opshapes = {k: v if not hasattr(v, "shape") else v.shape for k, v in self.operands.items()}
2574+
_shape = infer_shape(self.expression, opshapes) # infer shape, includes constructors
2575+
else:
2576+
raise e
2577+
25692578
self._shape_ = _shape
25702579
self._expression_ = self.expression
25712580
return _shape

0 commit comments

Comments
 (0)