From f0b3cb3f3eb8871c2c40952348a7194e322e4777 Mon Sep 17 00:00:00 2001 From: Aravindh Krishnamoorthy Date: Fri, 14 Feb 2025 17:26:57 +0000 Subject: [PATCH 1/4] Fix `Gamma[]` simplification rules. --- mathics/builtin/specialfns/gamma.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mathics/builtin/specialfns/gamma.py b/mathics/builtin/specialfns/gamma.py index 485b21020..968f7b4f0 100644 --- a/mathics/builtin/specialfns/gamma.py +++ b/mathics/builtin/specialfns/gamma.py @@ -323,7 +323,7 @@ class Gamma(MPMathMultiFunction): rules = { "Gamma[z_, x0_, x1_]": "Gamma[z, x0] - Gamma[z, x1]", - "Gamma[1 + z_]": "z!", + "Gamma[1 + z_?IntegerQ]": "z!", "Gamma[Undefined]": "Undefined", "Gamma[x_, Undefined]": "Undefined", "Gamma[Undefined, y_]": "Undefined", From b3ff8b5b5b3f69f59ec4ae177603ae6ddb557fd9 Mon Sep 17 00:00:00 2001 From: Aravindh Krishnamoorthy Date: Fri, 14 Feb 2025 17:35:59 +0000 Subject: [PATCH 2/4] Test for `Gamma[1+x]` --- test/builtin/specialfns/test_gamma.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/builtin/specialfns/test_gamma.py b/test/builtin/specialfns/test_gamma.py index b5d1d4148..af7e0cbbc 100644 --- a/test/builtin/specialfns/test_gamma.py +++ b/test/builtin/specialfns/test_gamma.py @@ -31,6 +31,12 @@ "Overflow", ), ("Gamma[1., 2.]", None, "Gamma[1., 2.]", "needs mpmath for lowergamma"), + ( + "Gamma[1 + x]", + None, + "Gamma[1 + x]", + None + ) ], ) def test_private_doctests_gamma(str_expr, msgs, str_expected, fail_msg): From 5640dff4c4caf5c76b7f5ac1b2814542dbe4537b Mon Sep 17 00:00:00 2001 From: Aravindh Krishnamoorthy Date: Fri, 14 Feb 2025 17:37:50 +0000 Subject: [PATCH 3/4] Black and iSort for test. --- test/builtin/specialfns/test_gamma.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/test/builtin/specialfns/test_gamma.py b/test/builtin/specialfns/test_gamma.py index af7e0cbbc..8e7904949 100644 --- a/test/builtin/specialfns/test_gamma.py +++ b/test/builtin/specialfns/test_gamma.py @@ -31,12 +31,7 @@ "Overflow", ), ("Gamma[1., 2.]", None, "Gamma[1., 2.]", "needs mpmath for lowergamma"), - ( - "Gamma[1 + x]", - None, - "Gamma[1 + x]", - None - ) + ("Gamma[1 + x]", None, "Gamma[1 + x]", None), ], ) def test_private_doctests_gamma(str_expr, msgs, str_expected, fail_msg): From c6b2c6bfc418b5549b9eb90f694d759edf608e80 Mon Sep 17 00:00:00 2001 From: Aravindh Krishnamoorthy Date: Sat, 15 Feb 2025 12:53:11 +0000 Subject: [PATCH 4/4] Update mathics/builtin/specialfns/gamma.py --- mathics/builtin/specialfns/gamma.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mathics/builtin/specialfns/gamma.py b/mathics/builtin/specialfns/gamma.py index 968f7b4f0..9617a834f 100644 --- a/mathics/builtin/specialfns/gamma.py +++ b/mathics/builtin/specialfns/gamma.py @@ -323,7 +323,7 @@ class Gamma(MPMathMultiFunction): rules = { "Gamma[z_, x0_, x1_]": "Gamma[z, x0] - Gamma[z, x1]", - "Gamma[1 + z_?IntegerQ]": "z!", + "Gamma[1 + z_Integer]": "z!", "Gamma[Undefined]": "Undefined", "Gamma[x_, Undefined]": "Undefined", "Gamma[Undefined, y_]": "Undefined",