Hello.
I recently needed to make all variables in expression positive.
I do this like following:
f = log(x)
a=Wild('a')
symbols = f.free_symbols
for symbol in symbols:
f = f.subs(symbol, dummy)
f = f.subs(symbol, sympy.Symbol(symbol.name, positive=True))
Now, when I do f.replace(log(a), log(Abs(a))) it shows log(x) as expected,
since x is positive
Now, make inverse process: convert positive to any
for symbol in symbols:
f = f.subs(symbol, dummy)
f = f.subs(symbol, sympy.Symbol(symbol.name))
But f.replace(log(a), log(Abs(a))) shows log(x) and in debugger x is still
positive.
Setting f.subs(symbol, sympy.Symbol(symbol.name, positive=None)) doesn't
help.
Helps following:
f.subs(symbol, sympy.Symbol(symbol.name, positive=False))
But I don't want negative variable.
How can I just reset assumptions?
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/d2a2e43f-806a-4c18-9d21-8b10ad990205%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.