Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relational operators always evaluate to True when cast to bool #312

Open
mlangiu opened this issue Mar 3, 2020 · 2 comments · May be fixed by #354
Open

Relational operators always evaluate to True when cast to bool #312

mlangiu opened this issue Mar 3, 2020 · 2 comments · May be fixed by #354

Comments

@mlangiu
Copy link

mlangiu commented Mar 3, 2020

With the current version of symengine (symengine-0.6.0) the following returns True

import symengine as se

x = se.S('x')
expr = se.Eq(x, 0)
print(bool(expr))

The outcome I expected was a TypeError as in sympy

@qthequartermasterman
Copy link

This is not a resolution to this issue, but is a useful workaround for some cases. If both sides of the expression can be evaluated (i.e. checking if 0==sqrt(2)), then running bool(expr.simplify()) will return False if the equality is indeed false.
This is not ideal for speed purposes, because as far as I can tell, it uses sympy's simplify features to do the simplification.

This does not help in the case that either side does not simplify, like in the original post.

qthequartermasterman added a commit to qthequartermasterman/symengine.py that referenced this issue Jun 5, 2021
…ean evaluation is, instead of always True. Resolves symengine#312
@qthequartermasterman qthequartermasterman linked a pull request Jun 5, 2021 that will close this issue
@qthequartermasterman
Copy link

This is fixed in PR #354. That Pull Request raises a TypeError if there are free variables, and will return True or False depending on the simplification of the relational if there are no free variables.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants