

def posify(eq):
    "Return eq (with generic symbols made positive) and a\n    dictionary containing the mapping between the old and new\n    symbols.\n\n    Any symbol that has positive=None will be replaced with a positive dummy\n    symbol having the same name. This replacement will allow more symbolic\n    processing of expressions, especially those involving powers and\n    logarithms.\n\n    A dictionary that can be sent to subs to restore eq to its original\n    symbols is also returned.\n\n    >>> from sympy import posify, Symbol, log, solve\n    >>> from sympy.abc import x\n    >>> posify(x + Symbol('p', positive=True) + Symbol('n', negative=True))\n    (_x + n + p, {_x: x})\n\n    >>> eq = 1/x\n    >>> log(eq).expand()\n    log(1/x)\n    >>> log(posify(eq)[0]).expand()\n    -log(_x)\n    >>> p, rep = posify(eq)\n    >>> log(p).expand().subs(rep)\n    -log(x)\n\n    It is possible to apply the same transformations to an iterable\n    of expressions:\n\n    >>> eq = x**2 - 4\n    >>> solve(eq, x)\n    [-2, 2]\n    >>> eq_x, reps = posify([eq, x]); eq_x\n    [_x**2 - 4, _x]\n    >>> solve(*eq_x)\n    [2]\n    "
    eq = sympify(eq)
    if iterable(eq):
        f = type(eq)
        eq = list(eq)
        syms = set()
        for e in eq:
            syms = syms.union(e.atoms(Symbol))
        reps = {
            
        }
        for s in syms:
            reps.update(dict(((v, k) for (k, v) in posify(s)[1].items())))
        for (i, e) in enumerate(eq):
            eq[i] = e.subs(reps)
        return (f(eq), {r: s for (s, r) in reps.items()})
    reps = dict([(s, Dummy(s.name, positive=True)) for s in eq.free_symbols if (s.is_positive is None)])
    eq = eq.subs(reps)
    return (eq, {r: s for (s, r) in reps.items()})

dataset/ETHPy150Open sympy/sympy/sympy/simplify/simplify.py posify/original