-
Notifications
You must be signed in to change notification settings - Fork 67
Wrapped Min and Max Functions #126
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
Conversation
See this error message,
|
I mean, isn't |
symengine/lib/symengine.pxd
Outdated
@@ -417,6 +419,7 @@ cdef extern from "<symengine/functions.h>" namespace "SymEngine": | |||
cdef RCP[const Basic] acoth(RCP[const Basic] &arg) nogil except+ | |||
cdef RCP[const Basic] function_symbol(string name, const vec_basic &arg) nogil except+ | |||
cdef RCP[const Basic] abs(RCP[const Basic] &arg) nogil except+ | |||
cdef RCP[const Basic] max(RCP[const Basic] &arg) nogil except+ |
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 function signature is wrong
I think this is ready for review now @isuruf. |
ping @isuruf |
symengine/tests/test_functions.py
Outdated
assert max({Integer(6)/3, 1}) == 2 | ||
assert max({-2, 2}) == 2 | ||
assert max({2, 2}) == 2 | ||
assert max({0.2, 0.3}) == 0.3 |
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 is using python's min
and max
.
symengine/lib/symengine_wrapper.pyx
Outdated
v.push_back(e_.thisptr) | ||
return c2py(symengine.max(v)) | ||
|
||
def min(*args): |
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 not good to change a function in the global namespace of python. What does sympy do?
@isuruf From what I observe, |
@isuruf What do you suggest we do of the namespace issue? |
Same as in SymPy. We define the classes Max and Min only. |
@isuruf I'am facing trouble implementing that. |
Ping @isuruf |
Use |
@isuruf I'm not sure what you mean. Wouldn't using |
Ping @isuruf |
symengine/tests/test_functions.py
Outdated
@@ -1,5 +1,5 @@ | |||
from symengine import Symbol, sin, cos, sqrt, Add, Mul, function_symbol, Integer, log, E, symbols | |||
from symengine.lib.symengine_wrapper import Subs, Derivative | |||
from symengine.lib.symengine_wrapper import Subs, Derivative, _max, _min |
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.
We don't want _max
to be the public interface.
Max
can be the public interface, but for that we need to rename the existing class to _Max
and make Max
, a pure python class and override __new__
to return the value, like in https://github.com/symengine/symengine.py/blob/master/symengine/sympy_compat.py#L53-L54
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.
Thanks for clearing me up on this.
@isuruf Can you please take a look now? |
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.
Looks good to me.
Only issue is that Max
can only be imported from sympy_compat. We should be able to use it from symengine_wrapper as well.
24f105a
to
da6e5e0
Compare
@isuruf I have added a string to address the import issues. I'd like to raise an issue for a possible workaround for the above. Can you please take a look here? |
Ping @isuruf |
Shifting the tests to sympy_compat is not a real solution. we need to give the user a way to use |
@isuruf Shifting the tests was never intended as a solution to the import issue. It was more along the lines of current necessity. As I'm out of ideas regarding the solution of the namespace issue, I would like to raise an issue, for possible ideas regarding the same, after this is merged. I pinged for a final review of this code. |
+1 |
Thanks for guiding me through @isuruf. |
@isuruf Can you tell me why are the current builds failing? Everything seems to be in compliance.