Skip to content

Commit

Permalink
functions: add arg._eval_rewrite_as_sign helper
Browse files Browse the repository at this point in the history
  • Loading branch information
skirpichev committed Feb 23, 2023
1 parent 6273afc commit 2d0df3f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions diofant/functions/elementary/complexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,9 @@ def _eval_rewrite_as_atan2(self, arg):
x, y = re(self.args[0]), im(self.args[0])
return atan2(y, x)

def _eval_rewrite_as_sign(self, arg):
return -I*log(sign(arg))


class conjugate(Function):
"""Returns the complex conjugate of an argument.
Expand Down
2 changes: 2 additions & 0 deletions diofant/tests/functions/test_complexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,8 @@ def test_arg():
e = (p + 1) + I*(p**2 - 1)
assert arg(e).args[0] == e

assert arg(x).rewrite(sign) == -I*log(sign(x))


def test_arg_rewrite():
assert arg(1 + I) == atan2(1, 1)
Expand Down

0 comments on commit 2d0df3f

Please sign in to comment.