Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/sage/rings/complex_arb.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ class ComplexBallField(UniqueRepresentation, sage.rings.abc.ComplexBallField):
"""
return super().__classcall__(cls, precision)

def __init__(self, long precision=53):
def __init__(self, long precision=53) -> None:
r"""
Initialize the complex ball field.

Expand Down Expand Up @@ -1399,7 +1399,7 @@ cdef class ComplexBall(RingElement):
"""
acb_clear(self.value)

def __init__(self, parent, x=None, y=None):
def __init__(self, parent, x=None, y=None) -> None:
"""
Initialize the :class:`ComplexBall`.

Expand Down Expand Up @@ -1529,7 +1529,7 @@ cdef class ComplexBall(RingElement):
else:
raise TypeError("unsupported initializer")

def __hash__(self):
def __hash__(self) -> int:
"""
TESTS::

Expand Down Expand Up @@ -2333,7 +2333,7 @@ cdef class ComplexBall(RingElement):
return (arb_is_nonzero(acb_realref(self.value))
or arb_is_nonzero(acb_imagref(self.value)))

def __bool__(self):
def __bool__(self) -> bool:
"""
Return ``True`` iff this complex ball is not the zero ball, i.e. if the
midpoint and radius of its real and imaginary parts are not all zero.
Expand Down Expand Up @@ -2590,7 +2590,7 @@ cdef class ComplexBall(RingElement):
if _do_sig(prec(self)): sig_off()
return res

def __contains__(self, other):
def __contains__(self, other) -> bool:
"""
Return ``True`` if ``other`` can be verified to be contained in ``self``.

Expand Down
8 changes: 4 additions & 4 deletions src/sage/rings/complex_interval.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ cdef class ComplexIntervalFieldElement(FieldElement):
mpfi_init2(self.__re, self._prec)
mpfi_init2(self.__im, self._prec)

def __init__(self, parent, real, imag=None, int base=10):
def __init__(self, parent, real, imag=None, int base=10) -> None:
"""
Initialize a complex number (interval).

Expand Down Expand Up @@ -168,7 +168,7 @@ cdef class ComplexIntervalFieldElement(FieldElement):
"""
return self.str(10)

def __hash__(self):
def __hash__(self) -> int:
"""
Return the hash value of ``self``.

Expand Down Expand Up @@ -664,7 +664,7 @@ cdef class ComplexIntervalFieldElement(FieldElement):

return center

def __contains__(self, other):
def __contains__(self, other) -> bool:
"""
Test whether ``other`` is totally contained in ``self``.

Expand Down Expand Up @@ -1406,7 +1406,7 @@ cdef class ComplexIntervalFieldElement(FieldElement):
return complex(self.real().n(self._prec),
self.imag().n(self._prec))

def __bool__(self):
def __bool__(self) -> bool:
"""
Return ``True`` if ``self`` is not known to be exactly zero.

Expand Down
34 changes: 18 additions & 16 deletions src/sage/rings/ideal.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from sage.categories.rings import Rings
from sage.categories.fields import Fields
from sage.structure.element import MonoidElement
from sage.structure.richcmp import rich_to_bool, richcmp, op_NE
from sage.structure.richcmp import rich_to_bool, op_NE
from sage.structure.sequence import Sequence


Expand Down Expand Up @@ -253,7 +253,7 @@ class Ideal_generic(MonoidElement):

See :func:`Ideal()`.
"""
def __init__(self, ring, gens, coerce=True, **kwds):
def __init__(self, ring, gens, coerce=True, **kwds) -> None:
"""
Initialize this ideal.

Expand Down Expand Up @@ -318,7 +318,7 @@ def _repr_short(self):
s = repr(x)
if '\n' in s:
has_return = True
s = s.replace('\n','\n ')
s = s.replace('\n', '\n ')
L.append(s)
if has_return:
return '\n(\n %s\n)\n' % (',\n\n '.join(L))
Expand Down Expand Up @@ -395,7 +395,7 @@ def _richcmp_(self, other, op):
return rich_to_bool(op, +1)
raise NotImplementedError(f'ideal comparison in {self.ring()} is not implemented')

def __contains__(self, x):
def __contains__(self, x) -> bool:
"""
Check if ``x`` is in ``self``.

Expand Down Expand Up @@ -439,7 +439,7 @@ def _contains_(self, x):
"""
raise NotImplementedError

def __bool__(self):
def __bool__(self) -> bool:
r"""
Return ``True`` if this ideal is not `(0)`.

Expand Down Expand Up @@ -1081,7 +1081,7 @@ def __mul__(self, other):
try:
if self.ring().has_coerce_map_from(other):
return self
except (TypeError,ArithmeticError,ValueError):
except (TypeError, ArithmeticError, ValueError):
pass
other = self.ring().ideal(other)
return self._mul_(other)
Expand All @@ -1107,7 +1107,8 @@ def _mul_(self, other):
sage: I._mul_(J)
Ideal (x^3*y, x^2*y^2, x^3*z, x^2*y*z, x^4, x^3*y) of Multivariate Polynomial Ring in x, y, z over Rational Field
"""
return self.ring().ideal([z for z in [x*y for x in self.gens() for y in other.gens()] if z])
return self.ring().ideal([z for x in self.gens() for y in other.gens()
if (z := x * y)])

def __rmul__(self, other):
"""
Expand All @@ -1124,10 +1125,11 @@ def __rmul__(self, other):
try:
if self.ring().has_coerce_map_from(other):
return self
except (TypeError,ArithmeticError,ValueError):
except (TypeError, ArithmeticError, ValueError):
pass
other = self.ring().ideal(other)
return self.ring().ideal([z for z in [y*x for x in self.gens() for y in other.gens()] if z])
return self.ring().ideal([z for x in self.gens() for y in other.gens()
if (z := y * x)])

def norm(self):
"""
Expand Down Expand Up @@ -1284,7 +1286,7 @@ class Ideal_principal(Ideal_generic):
See :func:`Ideal()`.
"""
# now Ideal_principal takes a list.
#def __init__(self, ring, gen):
# def __init__(self, ring, gen):
# Ideal_generic.__init__(self, ring, [gen])

def _repr_(self):
Expand Down Expand Up @@ -1366,7 +1368,7 @@ def gen(self, i=0):
raise ValueError(f"i (={i}) must be 0")
return self.gens()[0]

def __contains__(self, x):
def __contains__(self, x) -> bool:
"""
Return ``True`` if ``x`` is in ``self``.

Expand All @@ -1388,7 +1390,7 @@ def __contains__(self, x):
except NotImplementedError:
return self._contains_(self.ring()(x))

def __hash__(self):
def __hash__(self) -> int:
r"""
Very stupid constant hash function!

Expand Down Expand Up @@ -1622,10 +1624,10 @@ def is_prime(self):
sage: RR.ideal(7).is_prime()
False
"""
if self.is_zero(): # PIDs are integral domains by definition
if self.is_zero(): # PIDs are integral domains by definition
return True
g = self.gen()
if g.is_one(): # The ideal (1) is never prime
if g.is_one(): # The ideal (1) is never prime
return False
if hasattr(g, 'is_irreducible'):
return g.is_irreducible()
Expand Down Expand Up @@ -1819,7 +1821,7 @@ def Cyclic(R, n=None, homog=False, singular=None):
if not homog:
I = singular.cyclic(n)
else:
I = singular.cyclic(n).homog(R2.gen(n-1))
I = singular.cyclic(n).homog(R2.gen(n - 1))
return R2.ideal(I).change_ring(R)


Expand Down Expand Up @@ -1870,7 +1872,7 @@ def Katsura(R, n=None, homog=False, singular=None):
if not homog:
I = singular.katsura(n)
else:
I = singular.katsura(n).homog(R2.gen(n-1))
I = singular.katsura(n).homog(R2.gen(n - 1))
return R2.ideal(I).change_ring(R)


Expand Down
4 changes: 2 additions & 2 deletions src/sage/rings/polynomial/laurent_polynomial_ideal.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@


class LaurentPolynomialIdeal( Ideal_generic ):
def __init__(self, ring, gens, coerce=True, hint=None):
def __init__(self, ring, gens, coerce=True, hint=None) -> None:
r"""
Create an ideal in a Laurent polynomial ring.

Expand Down Expand Up @@ -184,7 +184,7 @@ def _richcmp_(self, right_r, op):
else:
raise ValueError("invalid comparison")

def __contains__(self, f):
def __contains__(self, f) -> bool:
"""
Implement containment testing (in) for Laurent polynomial ideals.

Expand Down
Loading
Loading