From 2e510337ccb62d272b013e5a4867aa11ed2e08b1 Mon Sep 17 00:00:00 2001 From: Shah Mahdi Hasan Date: Fri, 24 Nov 2023 11:51:30 +1100 Subject: [PATCH] Added "min" and "max" sympy mapping (#473) * Added "min" and "max" sympy mapping To overcome the sympy bug while using Min/Max operators as discussed under this issue: https://github.com/MilesCranmer/PySR/issues/183 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- pysr/export_sympy.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pysr/export_sympy.py b/pysr/export_sympy.py index 81142f48..e10609bd 100644 --- a/pysr/export_sympy.py +++ b/pysr/export_sympy.py @@ -47,6 +47,8 @@ "ceil": sympy.ceiling, "sign": sympy.sign, "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)), }