Skip to content

Commit

Permalink
Trac #34645: fix more W605 in rings
Browse files Browse the repository at this point in the history
after #34639

URL: https://trac.sagemath.org/34645
Reported by: chapoton
Ticket author(s): Frédéric Chapoton
Reviewer(s): Travis Scrimshaw
  • Loading branch information
Release Manager committed Oct 16, 2022
2 parents 791382b + 47a089d commit eab83ca
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 42 deletions.
4 changes: 2 additions & 2 deletions src/sage/rings/complex_arb.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2984,7 +2984,7 @@ cdef class ComplexBall(RingElement):
return res

def rising_factorial(self, n):
"""
r"""
Return the ``n``-th rising factorial of this ball.
The `n`-th rising factorial of `x` is equal to `x (x+1) \cdots (x+n-1)`.
Expand Down Expand Up @@ -3704,7 +3704,7 @@ cdef class ComplexBall(RingElement):
return res

def polylog(self, s):
"""
r"""
Return the polylogarithm `\operatorname{Li}_s(\mathrm{self})`.
EXAMPLES::
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/complex_double.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1637,7 +1637,7 @@ cdef class ComplexDoubleElement(FieldElement):
return self.real().is_NaN() or self.imag().is_NaN()

cpdef _pow_(self, other):
"""
r"""
The complex number ``self`` raised to the power ``other``.
This is computed using complex logarithms and exponentials
Expand Down
48 changes: 24 additions & 24 deletions src/sage/rings/complex_mpc.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,15 @@ cdef inline mpfr_rnd_t rnd_im(mpc_rnd_t rnd):
sign = '[+-]'
digit_ten = '[0123456789]'
exponent_ten = '[e@]' + sign + '?[0123456789]+'
number_ten = 'inf(?:inity)?|@inf@|nan(?:\([0-9A-Z_]*\))?|@nan@(?:\([0-9A-Z_]*\))?'\
'|(?:' + digit_ten + '*\.' + digit_ten + '+|' + digit_ten + '+\.?)(?:' + exponent_ten + ')?'
imaginary_ten = 'i(?:\s*\*\s*(?:' + number_ten + '))?|(?:' + number_ten + ')\s*\*\s*i'
complex_ten = '(?P<im_first>(?P<im_first_im_sign>' + sign + ')?\s*(?P<im_first_im_abs>' + imaginary_ten + ')' \
'(\s*(?P<im_first_re_sign>' + sign + ')\s*(?P<im_first_re_abs>' + number_ten + '))?)' \
number_ten = r'inf(?:inity)?|@inf@|nan(?:\([0-9A-Z_]*\))?|@nan@(?:\([0-9A-Z_]*\))?'\
'|(?:' + digit_ten + r'*\.' + digit_ten + '+|' + digit_ten + r'+\.?)(?:' + exponent_ten + ')?'
imaginary_ten = r'i(?:\s*\*\s*(?:' + number_ten + '))?|(?:' + number_ten + r')\s*\*\s*i'
complex_ten = '(?P<im_first>(?P<im_first_im_sign>' + sign + r')?\s*(?P<im_first_im_abs>' + imaginary_ten + r')' \
r'(\s*(?P<im_first_re_sign>' + sign + r')\s*(?P<im_first_re_abs>' + number_ten + '))?)' \
'|' \
'(?P<re_first>(?P<re_first_re_sign>' + sign + ')?\s*(?P<re_first_re_abs>' + number_ten + ')' \
'(\s*(?P<re_first_im_sign>' + sign + ')\s*(?P<re_first_im_abs>' + imaginary_ten + '))?)'
re_complex_ten = re.compile('^\s*(?:' + complex_ten + ')\s*$', re.I)
'(?P<re_first>(?P<re_first_re_sign>' + sign + r')?\s*(?P<re_first_re_abs>' + number_ten + r')' \
r'(\s*(?P<re_first_im_sign>' + sign + r')\s*(?P<re_first_im_abs>' + imaginary_ten + '))?)'
re_complex_ten = re.compile(r'^\s*(?:' + complex_ten + r')\s*$', re.I)

cpdef inline split_complex_string(string, int base=10):
"""
Expand Down Expand Up @@ -185,17 +185,17 @@ cpdef inline split_complex_string(string, int base=10):

# Warning: number, imaginary, and complex should be enclosed in parentheses
# when used as regexp because of alternatives '|'
number = '@nan@(?:\([0-9A-Z_]*\))?|@inf@|(?:' + digit + '*\.' + digit + '+|' + digit + '+\.?)(?:' + exponent + ')?'
number = r'@nan@(?:\([0-9A-Z_]*\))?|@inf@|(?:' + digit + r'*\.' + digit + '+|' + digit + r'+\.?)(?:' + exponent + ')?'
if base <= 10:
number = 'nan(?:\([0-9A-Z_]*\))?|inf(?:inity)?|' + number
imaginary = 'i(?:\s*\*\s*(?:' + number + '))?|(?:' + number + ')\s*\*\s*i'
complex = '(?P<im_first>(?P<im_first_im_sign>' + sign + ')?\s*(?P<im_first_im_abs>' + imaginary + ')' \
'(\s*(?P<im_first_re_sign>' + sign + ')\s*(?P<im_first_re_abs>' + number + '))?)' \
number = r'nan(?:\([0-9A-Z_]*\))?|inf(?:inity)?|' + number
imaginary = r'i(?:\s*\*\s*(?:' + number + '))?|(?:' + number + r')\s*\*\s*i'
complex = '(?P<im_first>(?P<im_first_im_sign>' + sign + r')?\s*(?P<im_first_im_abs>' + imaginary + r')' \
r'(\s*(?P<im_first_re_sign>' + sign + r')\s*(?P<im_first_re_abs>' + number + '))?)' \
'|' \
'(?P<re_first>(?P<re_first_re_sign>' + sign + ')?\s*(?P<re_first_re_abs>' + number + ')' \
'(\s*(?P<re_first_im_sign>' + sign + ')\s*(?P<re_first_im_abs>' + imaginary + '))?)'
'(?P<re_first>(?P<re_first_re_sign>' + sign + r')?\s*(?P<re_first_re_abs>' + number + r')' \
r'(\s*(?P<re_first_im_sign>' + sign + r')\s*(?P<re_first_im_abs>' + imaginary + '))?)'

z = re.match('^\s*(?:' + complex + ')\s*$', string, re.I)
z = re.match(r'^\s*(?:' + complex + r')\s*$', string, re.I)

x, y = None, None
if z is not None:
Expand All @@ -207,18 +207,18 @@ cpdef inline split_complex_string(string, int base=10):
return None

if z.group(prefix + '_re_abs') is not None:
x = z.expand('\g<' + prefix + '_re_abs>')
x = z.expand(r'\g<' + prefix + '_re_abs>')
if z.group(prefix + '_re_sign') is not None:
x = z.expand('\g<' + prefix + '_re_sign>') + x
x = z.expand(r'\g<' + prefix + '_re_sign>') + x

if z.group(prefix + '_im_abs') is not None:
y = re.search('(?P<im_part>' + number + ')', z.expand('\g<' + prefix + '_im_abs>'), re.I)
y = re.search('(?P<im_part>' + number + ')', z.expand(r'\g<' + prefix + '_im_abs>'), re.I)
if y is None:
y = '1'
else:
y = y.expand('\g<im_part>')
y = y.expand(r'\g<im_part>')
if z.group(prefix + '_im_sign') is not None:
y = z.expand('\g<' + prefix + '_im_sign>') + y
y = z.expand(r'\g<' + prefix + '_im_sign>') + y

return x, y

Expand Down Expand Up @@ -1701,7 +1701,7 @@ cdef class MPComplexNumber(sage.structure.element.FieldElement):
return z

def cosh(self):
"""
r"""
Return the hyperbolic cosine of this complex number:
.. MATH::
Expand All @@ -1721,7 +1721,7 @@ cdef class MPComplexNumber(sage.structure.element.FieldElement):
return z

def sinh(self):
"""
r"""
Return the hyperbolic sine of this complex number:
.. MATH::
Expand Down Expand Up @@ -2063,7 +2063,7 @@ cdef class MPComplexNumber(sage.structure.element.FieldElement):
return z

def exp(self):
"""
r"""
Return the exponential of this complex number:
.. MATH::
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/complex_mpfr.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2549,7 +2549,7 @@ cdef class ComplexNumber(sage.structure.element.FieldElement):

# Other special functions
def agm(self, right, algorithm="optimal"):
"""
r"""
Return the Arithmetic-Geometric Mean (AGM) of ``self`` and ``right``.
INPUT:
Expand Down
11 changes: 6 additions & 5 deletions src/sage/rings/integer.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1257,7 +1257,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
return self.str(2)

def bits(self):
"""
r"""
Return the bits in self as a list, least significant first. The
result satisfies the identity
Expand Down Expand Up @@ -2434,7 +2434,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
integer_ring.ZZ(n).ordinal_str()))

cpdef size_t _exact_log_log2_iter(self,Integer m):
"""
r"""
This is only for internal use only. You should expect it to crash
and burn for negative or other malformed input. In particular, if
the base `2 \leq m < 4` the log2 approximation of m is 1 and certain
Expand Down Expand Up @@ -3463,7 +3463,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
return q, r

def powermod(self, exp, mod):
"""
r"""
Compute self\*\*exp modulo mod.
EXAMPLES::
Expand Down Expand Up @@ -6714,8 +6714,9 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
raise ArithmeticError("inverse does not exist")

def inverse_mod(self, n):
"""
Returns the inverse of self modulo `n`, if this inverse exists.
r"""
Return the inverse of self modulo `n`, if this inverse exists.
Otherwise, raises a ``ZeroDivisionError`` exception.
INPUT:
Expand Down
18 changes: 9 additions & 9 deletions src/sage/rings/real_arb.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ from sage.structure.unique_representation import UniqueRepresentation
from sage.cpython.string cimport char_to_str, str_to_bytes

cdef void mpfi_to_arb(arb_t target, const mpfi_t source, const long precision):
"""
r"""
Convert an MPFI interval to an Arb ball.
INPUT:
Expand Down Expand Up @@ -282,7 +282,7 @@ cdef void mpfi_to_arb(arb_t target, const mpfi_t source, const long precision):
mpfr_clear(right)

cdef int arb_to_mpfi(mpfi_t target, arb_t source, const long precision) except -1:
"""
r"""
Convert an Arb ball to an MPFI interval.
INPUT:
Expand Down Expand Up @@ -798,7 +798,7 @@ class RealBallField(UniqueRepresentation, sage.rings.abc.RealBallField):
# Ball functions of non-ball arguments

def sinpi(self, x):
"""
r"""
Return a ball enclosing `\sin(\pi x)`.
This works even if ``x`` itself is not a ball, and may be faster or
Expand Down Expand Up @@ -844,7 +844,7 @@ class RealBallField(UniqueRepresentation, sage.rings.abc.RealBallField):
return res

def cospi(self, x):
"""
r"""
Return a ball enclosing `\cos(\pi x)`.
This works even if ``x`` itself is not a ball, and may be faster or
Expand Down Expand Up @@ -2986,7 +2986,7 @@ cdef class RealBall(RingElement):
return res

def sqrt1pm1(self):
"""
r"""
Return `\sqrt{1+\mathrm{self}}-1`, computed accurately when ``self`` is
close to zero.
Expand Down Expand Up @@ -3728,7 +3728,7 @@ cdef class RealBall(RingElement):
return res

def gamma(self, a=None):
"""
r"""
Image of this ball by the (upper incomplete) Euler Gamma function
For `a` real, return the upper incomplete Gamma function
Expand Down Expand Up @@ -3770,7 +3770,7 @@ cdef class RealBall(RingElement):
gamma_inc = gamma

def gamma_inc_lower(self, a):
"""
r"""
Image of this ball by the lower incomplete Euler Gamma function
For `a` real, return the lower incomplete Gamma function
Expand Down Expand Up @@ -3828,7 +3828,7 @@ cdef class RealBall(RingElement):
return res

def rising_factorial(self, n):
"""
r"""
Return the ``n``-th rising factorial of this ball.
The `n`-th rising factorial of `x` is equal to `x (x+1) \cdots (x+n-1)`.
Expand Down Expand Up @@ -3934,7 +3934,7 @@ cdef class RealBall(RingElement):
return res

def polylog(self, s):
"""
r"""
Return the polylogarithm `\operatorname{Li}_s(\mathrm{self})`.
EXAMPLES::
Expand Down

0 comments on commit eab83ca

Please sign in to comment.