Preventing evaluation of boolean logic operators

39 views
Skip to first unread message

Vincent Noel

unread,
Mar 8, 2016, 4:35:46 PM3/8/16
to sympy
Hi !

I'm working on a project where I need to save expressions unevaluated. So far so good, but I'm having a problem with boolean operators.
Here is an example of expression (coming from test units, thus the apparent weirdness) :

True && False

which I'm writing in Sympy as :

sympy.And(sympy.true, sympy.false, evaluate=False)

Problem is that, contrary to other sympy operators/functions, the evaluate=False seems to have no effect. This always evaluate the expression
Is there any other way to prevent that ? Am I doing something wrong ?

Many thanks for what is already an awesome library :)

Vincent

Aaron Meurer

unread,
Mar 8, 2016, 4:48:46 PM3/8/16
to sy...@googlegroups.com
I think the evaluation of booleans happens in the superclass
(LatticeOp), which ignores the evaluate flag. It should probably be
considered a bug. A simple workaround would be to use Symbol("true")
and Symbol("false") instead of S.true and S.false (and replace them
with their true boolean counterparts when you wish to evaluate them).

Aaron Meurer
> --
> 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 https://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/9dcb1f6a-2f2c-4a2e-bd46-7d6fe19c9b82%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Vincent Noel

unread,
Mar 9, 2016, 1:16:14 PM3/9/16
to sympy
Many thanks Aaron !

What would be the best place to do a bug report ? Github ?

Vincent

Sartaj Singh

unread,
Mar 9, 2016, 2:08:01 PM3/9/16
to sy...@googlegroups.com
> What would be the best place to do a bug report ? Github ?

Yes, we have our bug tracker on github. File an issue [here](https://github.com/sympy/sympy/issues).


For more options, visit https://groups.google.com/d/optout.



--
Regards
Sartaj Singh

Mathematics and Computing,
Indian Institute of Technology,
Varanasi - 221 005 INDIA

Reply all
Reply to author
Forward
0 new messages