Skip to content

Commit

Permalink
compat for Abs
Browse files Browse the repository at this point in the history
  • Loading branch information
isuruf committed Jun 3, 2017
1 parent 16c9422 commit 9da5eb3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions symengine/lib/symengine_wrapper.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1476,6 +1476,10 @@ mul = Mul

class Abs(OneArgFunction):

def __new__(cls, x):
cdef Basic X = _sympify(x)
return c2py(symengine.abs(X.thisptr))

def _sympy_(Basic self):
cdef RCP[const symengine.Abs] X = symengine.rcp_static_cast_Abs(self.thisptr)
arg = c2py(deref(X).get_arg())._sympy_()
Expand Down
4 changes: 4 additions & 0 deletions symengine/tests/test_sympy_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,7 @@ def __init__(self, name, extra_attribute):
two_x = 2 * x
# Check that after arithmetic, same subclass is returned
assert two_x.args[1] is x

def test_Abs():
x = symbols("x")
assert Abs(x) == Abs(-x)

0 comments on commit 9da5eb3

Please sign in to comment.