Comment #41 on issue 1026 by asmeurer: pypy doesn't run sympy
http://code.google.com/p/sympy/issues/detail?id=1026

The problem is

p1 = Piecewise((1,Interval(0,1,False,True)),(0,True))

p2 = piecewise_fold(expand((1-x)*p1))

The issue is that Python gives

In [4]: p2
Out[4]:
⎧    -x + 1       for [0, 1)
⎪
⎨⎧-x  for [0, 1)  otherwise
⎪⎨
⎩⎩0   otherwise

and PyPy gives:

p2
⎧    -x + 1      for [0, 1)
⎪
⎨⎧1  for [0, 1)  otherwise
⎪⎨
⎩⎩0  otherwise

But these are actually the same , since the part that's different is never true.

But there's actually a more serious issue with Piecewise demonstrated by this test failure. We have (from the test):

In [10]: p1 = Piecewise((1,Interval(0,1,False,True)),(0,True))

In [11]: p1
Out[11]:
⎧1  for [0, 1)
⎨
⎩0  otherwise

But this makes no sense. [0, 1) is not a conditional. It should be something like In(x, Interval(0, 1, False, True)).

If you use an actual conditional, you get the same answer in both Python and PyPy (though again, this is not guaranteed, as the second part is never true):

p1 = Piecewise((1,Or(x >= 0, x < 1)),(0,True))
p2 = piecewise_fold(expand((1-x)*p1))
p2
⎧       -x + 1          for x < 1 ∨ 0 ≤ x
⎪
⎨⎧1  for x < 1 ∨ 0 ≤ x      otherwise
⎪⎨
⎩⎩0      otherwise

In [19]: p1 = Piecewise((1,Or(x >= 0, x < 1)),(0,True))

In [20]: p2 = piecewise_fold(expand((1-x)*p1))

In [21]: p2
Out[21]:
⎧       -x + 1          for x < 1 ∨ 0 ≤ x
⎪
⎨⎧1  for x < 1 ∨ 0 ≤ x      otherwise
⎪⎨
⎩⎩0      otherwise


--
You received this message because you are subscribed to the Google Groups 
"sympy-issues" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy-issues?hl=en.

Reply via email to