Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
{Real,Complex}Ball: rename abs() to __abs__()
Browse files Browse the repository at this point in the history
Element already defines a generic abs() that calls __abs__().
  • Loading branch information
mezzarobba committed Oct 16, 2015
1 parent 7b67b5e commit 202f64c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/sage/rings/complex_ball_acb.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -987,15 +987,18 @@ cdef class ComplexBall(RingElement):
arb_set(r.value, acb_imagref(self.value))
return r

def abs(self):
def __abs__(self):
"""
Return the absolute value of this complex ball.
EXAMPLES::
sage: from sage.rings.complex_ball_acb import CBF
sage: CBF(1 + i).abs()
sage: CBF(1 + i).abs() # indirect doctest
[1.414213562373095 +/- 2.99e-16]
sage: abs(CBF(i))
1.000000000000000
sage: CBF(1 + i).abs().parent()
Real ball field with 53 bits precision
"""
Expand Down
6 changes: 4 additions & 2 deletions src/sage/rings/real_arb.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1374,15 +1374,17 @@ cdef class RealBall(RingElement):
mag_zero(arb_radref(res.value))
return res

def abs(self):
def __abs__(self):
"""
Return the absolute value of this ball.
EXAMPLES::
sage: from sage.rings.real_arb import RBF
sage: RBF(-1/3).abs()
sage: RBF(-1/3).abs() # indirect doctest
[0.3333333333333333 +/- 7.04e-17]
sage: abs(RBF(-1))
1.000000000000000
"""
cdef RealBall r = self._new()
arb_abs(r.value, self.value)
Expand Down

0 comments on commit 202f64c

Please sign in to comment.