(eq)
return eq, dict([(r, s) for s, r in reps.items()])
Return eq (with generic symbols made positive) and a restore
    dictionary.

    Any symbol that has positive=None will be replaced with a positive dummy
    symbol having the same name. This replacement will allow more symbolic
    processing of expressions, especially those involving powers and
    logarithms.

    A dictionary that can be sent to subs to restore eq to its original
    symbols is also returned.

    >>> from sympy import posify, Symbol, log
    >>> from sympy.abc import x
    >>> posify(x + Symbol('p', positive=True) + Symbol('n', negative=True))
    (_x + n + p, {_x: x})

    >> log(1/x).expand() # should be log(1/x) but it comes back as -log(x)
    log(1/x)

    >>> log(posify(1/x)[0]).expand() # take [0] and ignore replacements
    -log(_x)
    >>> eq, rep = posify(1/x)
    >>> log(eq).expand().subs(rep)
    -log(x)
    >>> posify([x, 1 + x])
    ([_x, _x + 1], {_x: x})
Return eq (with generic symbols made positive) and a restore
    dictionary.
Return eq ( with generic symbols made positive ) and a restore dictionary .
def posify(eq):
    """Return eq (with generic symbols made positive) and a restore
    dictionary.

    Any symbol that has positive=None will be replaced with a positive dummy
    symbol having the same name. This replacement will allow more symbolic
    processing of expressions, especially those involving powers and
    logarithms.

    A dictionary that can be sent to subs to restore eq to its original
    symbols is also returned.

    >>> from sympy import posify, Symbol, log
    >>> from sympy.abc import x
    >>> posify(x + Symbol('p', positive=True) + Symbol('n', negative=True))
    (_x + n + p, {_x: x})

    >> log(1/x).expand() # should be log(1/x) but it comes back as -log(x)
    log(1/x)

    >>> log(posify(1/x)[0]).expand() # take [0] and ignore replacements
    -log(_x)
    >>> eq, rep = posify(1/x)
    >>> log(eq).expand().subs(rep)
    -log(x)
    >>> posify([x, 1 + x])
    ([_x, _x + 1], {_x: x})
    """
    eq = sympify(eq)
    if iterable(eq):
        f = type(eq)
        eq = list(eq)
        syms = set()
        for e in eq:
            syms = syms.union(e.atoms(C.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), dict([(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, dict([(r, s) for s, r in reps.items()])
def posify ( eq ) : eq = sympify ( eq ) if iterable ( eq ) : f = type ( eq ) eq = list ( eq ) syms = set ( ) for e in eq : syms = syms . union ( e . atoms ( C . 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 ) , dict ( [ ( 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 , dict ( [ ( r , s ) for s , r in reps . items ( ) ] )