Re: [sympy] Boolean bug?

2015-05-15 Thread Joachim Durchholz
Am 15.05.2015 um 03:42 schrieb Duane Nykamp: I don't think this is the desired behavior. In [3]: a=Symbol('a') In [4]: bool(And(2>a, a>2)) Out[4]: True The `And` does not simplify, and the bool() conversion turns it into a Pythonic `True`. The former happens because assumptions don't know

[sympy] Re: Boolean bug?

2015-05-15 Thread Duane Nykamp
In the end, I would think that an expression like In [10]: bool(And(a>2, a<3)) Out[10]: True should raise a TypeError, like In [11]: bool(a>2) [snip] TypeError: cannot determine truth value of a > 2 I assume so as, as there is no way to know if a is between 2 and 3. Shouldn't it have the sam

Re: [sympy] Re: Boolean bug?

2015-05-15 Thread Joachim Durchholz
I agree that `bool(And(a>2, a<3))` and `bool(a>2)` should show analogous behaviour. At least that's what I'd assume from my current understanding of assumptions and evaluation in SymPy. I'd like to defer to the real experts on these components (I think that's @asmeurer and @certik). -- You rec

Re: [sympy] Re: Boolean bug?

2015-05-15 Thread Duane Nykamp
Yes, it turned out to mess it up for my use case. It would just confuse folks using my application if And(a>2, a<3) ended up always being true when a is symbolic. My solution was to make a derived class off And and add the methods def __nonzero__(self): raise TypeError("cannot dete

Re: [sympy] Re: Boolean bug?

2015-05-15 Thread Aaron Meurer
I agree. If bool(x > 2) raises TypeError then so should bool(And(a > 2, a < 2)). Aaron Meurer On Fri, May 15, 2015 at 5:01 PM, Duane Nykamp wrote: > Yes, it turned out to mess it up for my use case. It would just confuse > folks using my application if And(a>2, a<3) ended up always being true w

[sympy] Reliable Sympy

2015-05-15 Thread The Lartians
Hello, I'm a physics student from Göttingen and currently working on scientific simulation software in c++. I am currently using sympy in my python wrappers as it allows a convenient way for users to define and view simulation functions (they get compiled on-the-fly and are passed as function

Re: [sympy] Reliable Sympy

2015-05-15 Thread Ondřej Čertík
Hi Lars, On Fri, May 15, 2015 at 4:56 AM, The Lartians wrote: > Hello, > > I'm a physics student from Göttingen and currently working on scientific > simulation software in c++. I am currently using sympy in my python wrappers > as it allows a convenient way for users to define and view simulatio

Re: [sympy] Reliable Sympy

2015-05-15 Thread Ondřej Čertík
On Fri, May 15, 2015 at 6:09 PM, Ondřej Čertík wrote: > Hi Lars, > > On Fri, May 15, 2015 at 4:56 AM, The Lartians wrote: >> Hello, >> >> I'm a physics student from Göttingen and currently working on scientific >> simulation software in c++. I am currently using sympy in my python wrappers >> as

Re: [sympy] Numerical Evaluation of Discontinuous Integrals

2015-05-15 Thread Nathan Woods
All right, it took me longer than I had anticipated, but I have this project assembled in a more complete form now. To recap, the idea is to simplify allow for accurate evaluation of integrals of discontinuous functions, for which the form of the discontinuity is known beforehand. There is a pa

Re: [sympy] Re: Boolean bug?

2015-05-15 Thread Gaurav Dhingra
@asmeurer For this piece of code >>> x = Symbol('x', real=True) >>> bool( x > S(2) ) TypeError: can not determine the truth value of Relational I think, even if this returns an error then it should "not" be TypeError. Since a real number comparison is there in this. What are your views on this