From af9aeecb585c76bd2180c79307986cf79ab12dc8 Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Wed, 20 Mar 2024 11:44:11 +0100 Subject: Remove Expression.__getattr__ to avoid unexpected behaviour --- mdpoly/expressions.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/mdpoly/expressions.py b/mdpoly/expressions.py index 88baedf..71c94b2 100644 --- a/mdpoly/expressions.py +++ b/mdpoly/expressions.py @@ -59,10 +59,11 @@ class Expression: def __str__(self): return f"Expression{str(self.expr)}" - def __getattr__(self, attr): - # Behave transparently - # TODO: replace with selected attributes to expose? - return getattr(self.unwrap(), attr) + # TODO: is this actually a good idea? probably not. + # def __getattr__(self, attr): + # # Behave transparently + # # TODO: replace with selected attributes to expose? + # return getattr(self.unwrap(), attr) # -- Monadic operations -- @@ -264,7 +265,7 @@ class Expression: return rep, state except Exception as e: - bad = find_bad(self) + bad = find_bad(self.unwrap()) # for frame in bad._stack: # print(bad, frame.function, frame.filename, frame.lineno) @@ -285,7 +286,7 @@ class Expression: clear_stack(expr.left) clear_stack(expr.right) - clear_stack(self.expr) + clear_stack(self.unwrap()) def to_sparse(self, state: State) -> tuple[SparseRepr, State]: """ Make a sparse representation. -- cgit v1.2.1