-
Notifications
You must be signed in to change notification settings - Fork 65
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
Relationals and BooleanAtom #159
Conversation
symengine/lib/symengine_wrapper.pyx
Outdated
if self == BooleanTrue: | ||
return sympy.S.true | ||
else: | ||
return sympy.S.false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SymPy has two classes.
In [5]: sympy.S.false.__class__.__mro__
Out[5]:
(sympy.logic.boolalg.BooleanFalse,
sympy.logic.boolalg.BooleanAtom,
sympy.logic.boolalg.Boolean,
sympy.core.basic.Basic,
object)
symengine/__init__.py
Outdated
DictBasic, symarray, series, diff, zeros, eye, diag, ones, | ||
Derivative, Subs, add, expand, has_symbol, UndefFunction, | ||
Function, FunctionSymbol as AppliedUndef) | ||
zoo, nan, BooleanTrue, BooleanFalse, have_mpfr, have_mpc, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can add these to the bottom of the list instead of updating all the lines
@isuruf What can be done to fix the build failure? |
Ping @isuruf. |
symengine/lib/symengine_wrapper.pyx
Outdated
pass | ||
|
||
|
||
class BooleanTrue(Boolean): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have a common parent BooleanAtom
for these 2 classes.
symengine/lib/symengine_wrapper.pyx
Outdated
Ne = Unequality | ||
|
||
|
||
class GreaterThan(Relational): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the need here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's for SymPy
compatibility, for the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then make it a function, otherwise isinstance(GreaterThan(x, y), GreaterThan)
will return false instead of throwing an error
symengine/lib/symengine_wrapper.pyx
Outdated
s = self.args_as_sage() | ||
return sage.le(*s) | ||
|
||
func = __class__ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd remove this as Ge(x, y).func(x, y)
would return Le(x, y)
symengine/__init__.py
Outdated
@@ -7,7 +7,7 @@ | |||
MatrixBase, Basic, Lambdify, LambdifyCSE, Lambdify as lambdify, | |||
DictBasic, symarray, series, diff, zeros, eye, diag, ones, | |||
Derivative, Subs, add, expand, has_symbol, UndefFunction, | |||
Function, FunctionSymbol as AppliedUndef) | |||
Function, FunctionSymbol as AppliedUndef, true, false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can add the relationals classes like Eq, Equality
here, ... if they are available in when you do from sympy import *
symengine/lib/symengine_wrapper.pyx
Outdated
def _sage_(self): | ||
import sage.all as sage | ||
s = self.args_as_sage() | ||
return sage.gt(*s) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this work?
symengine/tests/test_sage.py
Outdated
|
||
assert pi == sympify(sage.pi) | ||
assert E == sympify(sage.e) | ||
assert oo == sympify(sage.oo) | ||
assert zoo == sympify(sage.unsigned_infinity) | ||
assert nan == sympify(sage.NaN) | ||
assert true == sympify(True) | ||
assert false == sympify(False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test doesn't belong in this file
In SymPy |
a415b27
to
46bfba5
Compare
@isuruf I couldn't find where this was being parsed in |
In pure python you need to define |
@isuruf Are the current changes satisfactory? Or should |
Ping @isuruf. |
Looks good. I'll merge this after I've done a release over the weekend. |
594e8af
to
8ea8e6b
Compare
@isuruf Can this be merged? It would be required for |
@ShikharJ, if you need this PR for other PRs, please send the new PR with the commits here. I'll merge this after the release. |
Please review and suggest improvements.