From 5c3a3d2bdf88e31d4197d92c5288e1d84490de2f Mon Sep 17 00:00:00 2001 From: Shah Mahdi Hasan Date: Mon, 27 Nov 2023 09:57:12 +1100 Subject: [PATCH] Added "round" operator in the Sympy mappings Enabling a workaround to avoid the following type error: `raise TypeError("Cannot round symbolic expression")` while using `round` as a unary operator. This issue was raised in #269 the the PR contains the exact solution put forth in the subsequent discussion --- pysr/export_sympy.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pysr/export_sympy.py b/pysr/export_sympy.py index e10609bde..3c3c5f931 100644 --- a/pysr/export_sympy.py +++ b/pysr/export_sympy.py @@ -49,6 +49,7 @@ "gamma": sympy.gamma, "max": lambda x, y: sympy.Piecewise((y, x < y), (x, True)), "min": lambda x, y: sympy.Piecewise((x, x < y), (y, True)), + "round": lambda x: sympy.ceiling(x - 0.5), }