

def signsimp(expr, evaluate=None):
    "Make all Add sub-expressions canonical wrt sign.\n\n    If an Add subexpression, ``a``, can have a sign extracted,\n    as determined by could_extract_minus_sign, it is replaced\n    with Mul(-1, a, evaluate=False). This allows signs to be\n    extracted from powers and products.\n\n    Examples\n    ========\n\n    >>> from sympy import signsimp, exp, symbols\n    >>> from sympy.abc import x, y\n    >>> i = symbols('i', odd=True)\n    >>> n = -1 + 1/x\n    >>> n/x/(-n)**2 - 1/n/x\n    (-1 + 1/x)/(x*(1 - 1/x)**2) - 1/(x*(-1 + 1/x))\n    >>> signsimp(_)\n    0\n    >>> x*n + x*-n\n    x*(-1 + 1/x) + x*(1 - 1/x)\n    >>> signsimp(_)\n    0\n\n    Since powers automatically handle leading signs\n\n    >>> (-2)**i\n    -2**i\n\n    signsimp can be used to put the base of a power with an integer\n    exponent into canonical form:\n\n    >>> n**i\n    (-1 + 1/x)**i\n\n    By default, signsimp doesn't leave behind any hollow simplification:\n    if making an Add canonical wrt sign didn't change the expression, the\n    original Add is restored. If this is not desired then the keyword\n    ``evaluate`` can be set to False:\n\n    >>> e = exp(y - x)\n    >>> signsimp(e) == e\n    True\n    >>> signsimp(e, evaluate=False)\n    exp(-(x - y))\n\n    "
    if (evaluate is None):
        evaluate = global_evaluate[0]
    expr = sympify(expr)
    if ((not isinstance(expr, Expr)) or expr.is_Atom):
        return expr
    e = sub_post(sub_pre(expr))
    if ((not isinstance(e, Expr)) or e.is_Atom):
        return e
    if e.is_Add:
        return e.func(*[signsimp(a) for a in e.args])
    if evaluate:
        e = a.xreplace({m: (- (- m)) for m in e.atoms(Mul) if ((- (- m)) != m)})
    return e

dataset/ETHPy150Open sympy/sympy/sympy/simplify/simplify.py signsimp/VarMisuse@131/750 `e`->`a`