From 7d284661fecc33512073e44cfa02c4e1e11c57d8 Mon Sep 17 00:00:00 2001 From: rocky Date: Sat, 14 Jan 2023 22:10:29 -0500 Subject: [PATCH] Remove duplicate cancel and sympy_factor... it have been moved to mathics.eval.numbers --- mathics/builtin/numbers/algebra.py | 31 +----------------------------- 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/mathics/builtin/numbers/algebra.py b/mathics/builtin/numbers/algebra.py index 481c07efe..bec268b65 100644 --- a/mathics/builtin/numbers/algebra.py +++ b/mathics/builtin/numbers/algebra.py @@ -62,36 +62,7 @@ SymbolTable, SymbolTanh, ) - - -def sympy_factor(expr_sympy): - try: - result = sympy.together(expr_sympy) - result = sympy.factor(result) - except sympy.PolynomialError: - return expr_sympy - return result - - -def cancel(expr): - if expr.has_form("Plus", None): - return Expression(SymbolPlus, *[cancel(element) for element in expr.elements]) - else: - try: - result = expr.to_sympy() - if result is None: - return None - - # result = sympy.powsimp(result, deep=True) - result = sympy.cancel(result) - - # cancel factors out rationals, so we factor them again - result = sympy_factor(result) - - return from_sympy(result) - except sympy.PolynomialError: - # e.g. for non-commutative expressions - return expr +from mathics.eval.numbers import cancel, sympy_factor def expand(expr, numer=True, denom=False, deep=False, **kwargs):