Skip to content

Commit

Permalink
Merge pull request #465 from isuruf/pos
Browse files Browse the repository at this point in the history
Implement unary addition
  • Loading branch information
isuruf authored Jan 23, 2024
2 parents d1a50aa + 42ee143 commit a79eeee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions symengine/lib/symengine_wrapper.in.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,9 @@ cdef class Basic(object):
def __neg__(Basic self not None):
return c2py(symengine.neg(self.thisptr))

def __pos__(self):
return self

def __abs__(Basic self not None):
return c2py(symengine.abs(self.thisptr))

Expand Down
6 changes: 6 additions & 0 deletions symengine/tests/test_arit.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ def test_arit8():
assert (2*y**(-2*x**2)) * (3*y**(2*x**2)) == 6


def test_unary():
x = Symbol("x")
assert -x == 0 - x
assert +x == x


def test_expand1():
x = Symbol("x")
y = Symbol("y")
Expand Down

0 comments on commit a79eeee

Please sign in to comment.