From ad9f747c5b92e1e4dc2ed00d7202b5c51498a6cf Mon Sep 17 00:00:00 2001 From: mcDandy Date: Tue, 14 Apr 2026 13:31:04 +0200 Subject: [PATCH] Throw clearererror --- more_math/Parser/UnifiedMathVisitor.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/more_math/Parser/UnifiedMathVisitor.py b/more_math/Parser/UnifiedMathVisitor.py index 56d1b29..77a9c4d 100644 --- a/more_math/Parser/UnifiedMathVisitor.py +++ b/more_math/Parser/UnifiedMathVisitor.py @@ -2550,10 +2550,13 @@ class UnifiedMathVisitor(MathExprVisitor): def _bitwise_op(self, a, b, torch_op, scalar_op,ctx): """Binary bitwise operation handler supporting tensors, lists, and scalars.""" - if self._is_tensor(a) and a.numel() == 1: - a = int(a.flatten()[0].item()) - if self._is_tensor(b) and b.numel() == 1: - b = int(b.flatten()[0].item()) + try: + if self._is_tensor(a) and a.numel() == 1: + a = int(a.flatten()[0].item()) + if self._is_tensor(b) and b.numel() == 1: + b = int(b.flatten()[0].item()) + except Exception as e: + raise ValueError(f"Invalid tensor value for bitwise operation: {e}") # Handle tensor-list combinations if self._is_tensor(a) and self._is_list(b):