From 8fadd002e24618fbb9bc1ac21cfa785372df00b1 Mon Sep 17 00:00:00 2001 From: Leon Maksin Date: Thu, 7 Aug 2025 09:59:23 -0700 Subject: [PATCH 1/2] test gamma func --- tests/test_gamma_func.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tests/test_gamma_func.py diff --git a/tests/test_gamma_func.py b/tests/test_gamma_func.py new file mode 100644 index 0000000..0ebb727 --- /dev/null +++ b/tests/test_gamma_func.py @@ -0,0 +1,24 @@ +import sympy +from math_verify import parser + +def add_math_mode_if_not_present(x: str) -> str: + x = x.strip() + if x.startswith("$"): + return x + if x.startswith("\\("): + return x + if x.startswith("\\["): + return x + return r"\(" + x + r"\)" + +def test_gamma_as_function(): + latex_str = r"\(\Gamma(\frac{\pi}{12})\)" + [parsed_str] = parser.parse(latex_str, fallback_mode="no_fallback") + expected = sympy.gamma(sympy.pi/12) + assert sympy.simplify(parsed_str - expected) == 0 + +def test_gamma_as_constant(): + latex_str = r"\(\Gamma * (\frac{\pi}{12})\)" + [parsed_str] = parser.parse(latex_str, fallback_mode="no_fallback") + expected = sympy.EulerGamma * sympy.pi/12 + assert sympy.simplify(parsed_str - expected) == 0 From 939ce339405c5f27cb8153605ee8fe1f81f40517 Mon Sep 17 00:00:00 2001 From: Leon Maksin Date: Thu, 7 Aug 2025 10:03:28 -0700 Subject: [PATCH 2/2] simplify --- tests/test_gamma_func.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/tests/test_gamma_func.py b/tests/test_gamma_func.py index 0ebb727..2f4c68f 100644 --- a/tests/test_gamma_func.py +++ b/tests/test_gamma_func.py @@ -1,16 +1,6 @@ import sympy from math_verify import parser -def add_math_mode_if_not_present(x: str) -> str: - x = x.strip() - if x.startswith("$"): - return x - if x.startswith("\\("): - return x - if x.startswith("\\["): - return x - return r"\(" + x + r"\)" - def test_gamma_as_function(): latex_str = r"\(\Gamma(\frac{\pi}{12})\)" [parsed_str] = parser.parse(latex_str, fallback_mode="no_fallback")