But then, when I substitute positive symbol back to normal:
> symbols = f.free_symbols 
> for symbol in symbols: 
> f = f.subs(symbol, sympy.Symbol(symbol.name)) 

It still shows log(x), isntead of log(|x|)

On Wednesday, February 25, 2015 at 10:18:06 PM UTC+2, Joachim Durchholz 
wrote:
>
> Am 25.02.2015 um 18:10 schrieb Paul Royik: 
> > I mean in multithreaded environment, do people share same cache (and 
> same 
> > symbols) 
> > If person1 created x=Symbol('x') and this is cached, and person2 created 
> > x=Symbol('x', positive=True), do they have separate x's or they mixed, 
> so 
> > person1 can get positive x if it was overwritten in cache by person 2? 
>
> If that's different persons (or, more precisely, shell sessions), they 
> get different copies of the SymPy process anyway, and there's no 
> confusion possible at all. 
>
> > Reproduction. 
> > 
> > from sympy import * 
> > x = Symbol('x') 
> > f = log(x) 
> > a=Wild('a') 
> > symbols = f.free_symbols 
> > for symbol in symbols: 
> >     f = f.subs(symbol, sympy.Symbol(symbol.name, positive=True)) 
> > 
>
> Nit to pick: This wouldn't work for me, I'd have to do "import sympy" 
> first. 
>
> > print f.replace(log(a),log(Abs(a))) # prints log(x) as expected 
> > 
> > # clear_cache() solves the problem 
> > 
> > symbols = f.free_symbols 
> > for symbol in symbols: 
> >     f = f.subs(symbol, sympy.Symbol(symbol.name)) 
> > 
> > print f.replace(log(a),log(Abs(a))) # OOPS! prints log(x) instead of 
> > log(|x|) 
>
> Yes, that's happening for me, too, without any multithreading. 
>
> It's okay though. You replaced that x in the original f==log(x) with a 
> new x constructed as 
>
>    sympy.Symbol('x', positive=True) 
>
> so you now have a new f, with an x that's already under an assumption 
> that it must be positive. 
> So I think what happens is that SymPy smartly infers that substituting 
> an Abs(x) around an already-positive x is a nop and can be simplified out. 
>
> Now I'd like to see a transcript of what happens with clear_cache(). 
> If my theory is correct, then clear_cache should not affect the outcome. 
>

-- 
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/9f538d89-3aa5-4f38-8333-63ea161db943%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to