My initial problem was :
p1 = Piecewise((sin(x), x < 0), (0, True))
p2 = Piecewise((0, Eq(p1, 0)), (p1 / Abs(p1), True))
piecefold(p2)
TypeError: Cond Piecewise((sin(x) == 0, x < 0), (True, True)) is of type
Piecewise, but must be a Relational, Boolean, or a built-in bool.

This happen when piecewise_fold is recursively applied to Eq(p1, 0).
I could try :
1) (bad) Piecewise accepts bool as expr.
2) Handle this case into piecewise_fold.
3) The classmethod eval from Piecewise returns an appropriate Or/And
construction when it receives Boolean as expr.
4) ?

thanks for your precious time


2013/3/5 Julien Rioux <notifications@github.com>

> In sympy/functions/elementary/tests/test_piecewise.py:
>
> > @@ -301,6 +301,12 @@ def test_piecewise_fold():
> >          piecewise_fold(p), (x, -oo, oo)) == integrate(2*x + 2, (x, 0, 1))
> >
> >
> > +def test_piecewise_cond():
> > +    p = Piecewise((0, Piecewise((cos(x) < 0, x < 1),
> > +        (1/x > 0, x >= 1))), (1, True))
>
> First: it should be (1/x).subs(x, 0.0) == Float('inf'), but yes.
> Second: I don't understand this. The arguments of a Piecewise are (expr,
> cond) pairs where expr should be a subclass of Expr and cond should be a
> bool or a subclass of Boolean. On the other hand the arguments of a Andor
> Or should be a bool or a subclass of Boolean. I don't see how you could
> equate the two.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/sympy/sympy/pull/1868/files#r3243838>
> .
>