Checking an expression is an inequality

15 views
Skip to first unread message

Amit Saha

unread,
May 11, 2015, 1:05:51 AM5/11/15
to sy...@googlegroups.com
Hi all,

Is this the best way to check whether an expression is an inequality ?

>>> expr = x - 4 > 0
>>> isinstance(expr, Relational)
True
>>> expr = x - 4 >= 0
>>> isinstance(expr, Relational)
True
>>> expr = x - 4 <= 0
>>> isinstance(expr, Relational)
True


Also, can I submit a change to allow "Relational" to be imported from
sympy instead of having to do:
from sympy.core.relational import Relational ?


Thanks,
Amit.


--
http://echorand.me

Aaron Meurer

unread,
May 11, 2015, 1:28:19 AM5/11/15
to sy...@googlegroups.com
On Mon, May 11, 2015 at 12:05 AM, Amit Saha <amits...@gmail.com> wrote:
> Hi all,
>
> Is this the best way to check whether an expression is an inequality ?

Yes, except note that Relational can also be Eq().

>
>>>> expr = x - 4 > 0
>>>> isinstance(expr, Relational)
> True
>>>> expr = x - 4 >= 0
>>>> isinstance(expr, Relational)
> True
>>>> expr = x - 4 <= 0
>>>> isinstance(expr, Relational)
> True
>
>
> Also, can I submit a change to allow "Relational" to be imported from
> sympy instead of having to do:
> from sympy.core.relational import Relational ?

Are there other examples of base classes being importable directly from sympy?

Aaron Meurer

>
>
> Thanks,
> Amit.
>
>
> --
> http://echorand.me
>
> --
> 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 sympy+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> 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/CANODV3%3DvucTS_UEXT0Bxgy0%3D7YFGxrAsTcPBTN5ac057uDZUyA%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

Amit Saha

unread,
May 11, 2015, 9:30:52 AM5/11/15
to sy...@googlegroups.com
On Mon, May 11, 2015 at 3:27 PM, Aaron Meurer <asme...@gmail.com> wrote:
> On Mon, May 11, 2015 at 12:05 AM, Amit Saha <amits...@gmail.com> wrote:
>> Hi all,
>>
>> Is this the best way to check whether an expression is an inequality ?
>
> Yes, except note that Relational can also be Eq().

Thanks for pointing that out.


>
>>
>>>>> expr = x - 4 > 0
>>>>> isinstance(expr, Relational)
>> True
>>>>> expr = x - 4 >= 0
>>>>> isinstance(expr, Relational)
>> True
>>>>> expr = x - 4 <= 0
>>>>> isinstance(expr, Relational)
>> True
>>
>>
>> Also, can I submit a change to allow "Relational" to be imported from
>> sympy instead of having to do:
>> from sympy.core.relational import Relational ?
>
> Are there other examples of base classes being importable directly from sympy?

I am not sure, but i understand why it isn't already.



--
http://echorand.me
Reply all
Reply to author
Forward
0 new messages