Skip to content

Commit 128954c

Browse files
committed
Correct handling of disable_overloaded_equal
1 parent 3011ea4 commit 128954c

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/blosc2/lazyexpr.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ def to_cframe(self) -> bytes:
492492
def __bool__(self) -> bool:
493493
if math.prod(self.shape) != 1:
494494
raise ValueError(f"The truth value of a LazyArray of shape {self.shape} is ambiguous.")
495-
return bool(self[()])
495+
return self[()].__bool__()
496496

497497

498498
def convert_inputs(inputs):
@@ -2269,6 +2269,7 @@ def get_chunk(self, nchunk):
22692269
return out.schunk.get_chunk(nchunk)
22702270

22712271
def update_expr(self, new_op): # noqa: C901
2272+
original_disable = blosc2._disable_overloaded_equal
22722273
# We use a lot of the original NDArray.__eq__ as 'is', so deactivate the overloaded one
22732274
blosc2._disable_overloaded_equal = True
22742275
# One of the two operands are LazyExpr instances
@@ -2292,6 +2293,7 @@ def update_expr(self, new_op): # noqa: C901
22922293
# We converted some of the operands to NDArray (where() handling above)
22932294
new_operands = {"o0": value1, "o1": value2}
22942295
expression = f"(o0 {op} o1)"
2296+
blosc2._disable_overloaded_equal = original_disable
22952297
return self._new_expr(expression, new_operands, guess=False, out=None, where=None)
22962298
elif isinstance(value1, LazyExpr) and isinstance(value2, LazyExpr):
22972299
# Expression fusion
@@ -2333,7 +2335,7 @@ def update_expr(self, new_op): # noqa: C901
23332335
else:
23342336
expression = f"({op_name} {op} {self.expression})"
23352337
self.operands = value2.operands
2336-
blosc2._disable_overloaded_equal = False
2338+
blosc2._disable_overloaded_equal = original_disable
23372339
# Return a new expression
23382340
operands = self.operands | new_operands
23392341
return self._new_expr(expression, operands, guess=False, out=None, where=None)

0 commit comments

Comments
 (0)