diff --git a/src/formulate/AST.py b/src/formulate/AST.py index d1a7ca6..d179c3f 100644 --- a/src/formulate/AST.py +++ b/src/formulate/AST.py @@ -186,6 +186,18 @@ def to_python(self): return "np.exp(1)" case "e": return "np.exp(1)" + case "max": + return f"root_max({self.arguments[0]})" + case "min": + return f"root_min({self.arguments[0]})" + case "sum": + return f"root_sum({self.arguments[0]})" + case "no_of_entries": + return f"root_length({self.arguments[0]})" + case "min_if": + return f"root_min_if({self.arguments[0]}, {self.arguments[1]})" + case "max_if": + return f"root_max_if({self.arguments[0]}, {self.arguments[1]})" case _ : raise ValueError("Not a valid function!") diff --git a/src/formulate/ttreeformula.py b/src/formulate/ttreeformula.py index 8c0d7ff..bd2ed70 100644 --- a/src/formulate/ttreeformula.py +++ b/src/formulate/ttreeformula.py @@ -42,7 +42,7 @@ func_name: CNAME | CNAME "::" func_name trailer: "(" [arglist] ")" arglist: expression ("," expression)* [","] -CNAME: /[A-Za-z_]([A-Za-z0-9_]|\s*\.\s*)*/ +CNAME: /[A-Za-z_$]([A-Za-z0-9_$]|\s*\.\s*)*/ %import common.NUMBER %import common.WS