Of course, for Piecewise((True, x>0), (False, True)), you could just
replace it with x > 0. It seems ITE doesn't do this automatically but
it does if you call to_nnf() on it.

In [12]: ITE(x > 0, True, False).to_nnf()
Out[12]: x > 0

Aaron Meurer

On Thu, Aug 18, 2016 at 4:09 PM, Aaron Meurer <[email protected]> wrote:
> I would use ITE for this case. It's the boolean version of Piecewise.
>
> Aaron Meurer
>
> On Thu, Aug 18, 2016 at 9:51 AM, Vincent Noel <[email protected]> wrote:
>> Hi,
>>
>> I'm trying to represent a weird case using piecewise functions :
>>
>> z = sympy.Piecewise((True, x>0), (False, True))
>>
>> A piecewise function returning a boolean value... so far so good. The
>> problems comes when I want to use that as a condition inside another
>> Piecewise :
>>
>> z2 = sympy.Piecewise((1,z), (0, True), evaluate=False)
>> Traceback (most recent call last):
>>   File "<stdin>", line 1, in <module>
>>   File
>> "/usr/local/lib/python2.7/dist-packages/sympy/functions/elementary/piecewise.py",
>> line 104, in __new__
>>     " Boolean, or a built-in bool." % (cond, type(cond)))
>> TypeError: Cond Piecewise((True, x > 0), (False, True)) is of type
>> Piecewise, but must be a Relational, Boolean, or a built-in bool.
>>
>> z being obviously a boolean, is there no way for sympy to recognize that and
>> accept it as a condition ?
>>
>> Vincent
>>
>> --
>> 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 https://groups.google.com/group/sympy.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/sympy/d0a66ce7-d965-4810-bb33-eca9bb2bdc54%40googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.

-- 
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 https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAKgW%3D6LjgFbd4mU67ggxvz1Dk6ntGxrk8yVuxenc0WL4FWgOSA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to