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

Commit

Permalink
trac 21887 undoing alias of __nonzero__ in pyx files
Browse files Browse the repository at this point in the history
  • Loading branch information
Frédéric Chapoton committed Nov 17, 2016
1 parent e62142d commit 41d63ab
Show file tree
Hide file tree
Showing 43 changed files with 46 additions and 113 deletions.
2 changes: 1 addition & 1 deletion src/sage/rings/asymptotic/asymptotic_ring.py
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ def __bool__(self):
"""
return bool(self._summands_)

__nonzero__ =__bool__
__nonzero__ = __bool__

def __eq__(self, other):
r"""
Expand Down
4 changes: 1 addition & 3 deletions src/sage/rings/complex_arb.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1402,7 +1402,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 __nonzero__(self):
"""
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 All @@ -1427,8 +1427,6 @@ cdef class ComplexBall(RingElement):
"""
return not acb_is_zero(self.value)

__nonzero__ =__bool__

def is_exact(self):
"""
Return ``True`` iff the radius of this ball is zero.
Expand Down
4 changes: 1 addition & 3 deletions src/sage/rings/complex_interval.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1389,7 +1389,7 @@ cdef class ComplexIntervalFieldElement(sage.structure.element.FieldElement):
"""
raise TypeError("can't convert complex interval to complex")

def __bool__(self):
def __nonzero__(self):
"""
Return ``True`` if ``self`` is not known to be exactly zero.
Expand All @@ -1408,8 +1408,6 @@ cdef class ComplexIntervalFieldElement(sage.structure.element.FieldElement):
"""
return self.real().__bool__() or self.imag().__bool__()

__nonzero__ =__bool__

cpdef _richcmp_(left, right, int op):
r"""
As with the real interval fields this never returns false positives.
Expand Down
4 changes: 1 addition & 3 deletions src/sage/rings/complex_mpc.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1243,7 +1243,7 @@ cdef class MPComplexNumber(sage.structure.element.FieldElement):
elif cim<0: return -1
else: return 0

def __bool__(self):
def __nonzero__(self):
"""
Return ``True`` if ``self`` is not zero.
Expand All @@ -1258,8 +1258,6 @@ cdef class MPComplexNumber(sage.structure.element.FieldElement):
"""
return not (mpfr_zero_p(self.value.re) and mpfr_zero_p(self.value.im))

__nonzero__ =__bool__

def is_square(self):
r"""
This function always returns true as `\CC` is algebraically closed.
Expand Down
4 changes: 1 addition & 3 deletions src/sage/rings/complex_number.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ cdef class ComplexNumber(sage.structure.element.FieldElement):
real_string, digit_precision_bound,
imag_string, digit_precision_bound)

def __bool__(self):
def __nonzero__(self):
"""
Return ``True`` if ``self`` is not zero. This is an internal function;
use :meth:`is_zero()` instead.
Expand All @@ -872,8 +872,6 @@ cdef class ComplexNumber(sage.structure.element.FieldElement):
"""
return not (mpfr_zero_p(self.__re) and mpfr_zero_p(self.__im))

__nonzero__ =__bool__

def prec(self):
"""
Return precision of this complex number.
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/continued_fraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,7 @@ def __bool__(self):
"""
return bool(self.quotient(0)) or self.quotient(1) is not Infinity

__nonzero__ =__bool__
__nonzero__ = __bool__

def is_zero(self):
r"""
Expand Down
4 changes: 1 addition & 3 deletions src/sage/rings/finite_rings/element_givaro.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ cdef class FiniteField_givaroElement(FinitePolyExtElement):
"""
return self.element

def __bool__(FiniteField_givaroElement self):
def __nonzero__(FiniteField_givaroElement self):
r"""
Return ``True`` if ``self != k(0)``.
Expand All @@ -941,8 +941,6 @@ cdef class FiniteField_givaroElement(FinitePolyExtElement):
"""
return not self._cache.objectptr.isZero(self.element)

__nonzero__ =__bool__

def is_one(FiniteField_givaroElement self):
r"""
Return ``True`` if ``self == k(1)``.
Expand Down
4 changes: 1 addition & 3 deletions src/sage/rings/finite_rings/element_ntl_gf2e.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ cdef class FiniteField_ntl_gf2eElement(FinitePolyExtElement):

return " + ".join(reversed(_repr))

def __bool__(FiniteField_ntl_gf2eElement self):
def __nonzero__(FiniteField_ntl_gf2eElement self):
r"""
Return ``True`` if ``self != k(0)``.
Expand All @@ -591,8 +591,6 @@ cdef class FiniteField_ntl_gf2eElement(FinitePolyExtElement):
(<Cache_ntl_gf2e>self._parent._cache).F.restore()
return not bool(GF2E_IsZero(self.x))

__nonzero__ =__bool__

def is_one(FiniteField_ntl_gf2eElement self):
r"""
Return ``True`` if ``self == k(1)``.
Expand Down
3 changes: 1 addition & 2 deletions src/sage/rings/finite_rings/element_pari_ffelt.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -560,8 +560,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement):
"""
return not bool(FF_equal0(self.val))

__bool__ = is_unit
__nonzero__ =__bool__
__nonzero__ = is_unit

def __pos__(FiniteFieldElement_pari_ffelt self):
"""
Expand Down
12 changes: 3 additions & 9 deletions src/sage/rings/finite_rings/integer_mod.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1901,7 +1901,7 @@ cdef class IntegerMod_gmp(IntegerMod_abstract):
"""
return mpz_cmp_si(self.value, 1) == 0
def __bool__(IntegerMod_gmp self):
def __nonzero__(IntegerMod_gmp self):
"""
Returns ``True`` if this is not `0`, otherwise
``False``.
Expand All @@ -1915,8 +1915,6 @@ cdef class IntegerMod_gmp(IntegerMod_abstract):
"""
return mpz_cmp_si(self.value, 0) != 0
__nonzero__ =__bool__
cpdef bint is_unit(self):
"""
Return True iff this element is a unit.
Expand Down Expand Up @@ -2299,7 +2297,7 @@ cdef class IntegerMod_int(IntegerMod_abstract):
"""
return self.ivalue == 1

def __bool__(IntegerMod_int self):
def __nonzero__(IntegerMod_int self):
"""
Returns ``True`` if this is not `0`, otherwise
``False``.
Expand All @@ -2313,8 +2311,6 @@ cdef class IntegerMod_int(IntegerMod_abstract):
"""
return self.ivalue != 0

__nonzero__ =__bool__

cpdef bint is_unit(IntegerMod_int self):
"""
Return True iff this element is a unit
Expand Down Expand Up @@ -3118,7 +3114,7 @@ cdef class IntegerMod_int64(IntegerMod_abstract):
"""
return self.ivalue == 1

def __bool__(IntegerMod_int64 self):
def __nonzero__(IntegerMod_int64 self):
"""
Returns ``True`` if this is not `0`, otherwise
``False``.
Expand All @@ -3132,8 +3128,6 @@ cdef class IntegerMod_int64(IntegerMod_abstract):
"""
return self.ivalue != 0

__nonzero__ =__bool__

cpdef bint is_unit(IntegerMod_int64 self):
"""
Return True iff this element is a unit.
Expand Down
4 changes: 1 addition & 3 deletions src/sage/rings/fraction_field_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ cdef class FractionFieldElement(FieldElement):
"""
return self.__numerator.valuation(v) - self.__denominator.valuation(v)

def __bool__(self):
def __nonzero__(self):
"""
Return ``True`` if this element is nonzero.
Expand All @@ -888,8 +888,6 @@ cdef class FractionFieldElement(FieldElement):
"""
return not self.__numerator.is_zero()

__nonzero__ =__bool__

def is_zero(self):
"""
Return ``True`` if this element is equal to zero.
Expand Down
4 changes: 1 addition & 3 deletions src/sage/rings/function_field/function_field_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ cdef class FunctionFieldElement_polymod(FunctionFieldElement):
"""
return self._x._repr(name=self.parent().variable_name())

def __bool__(self):
def __nonzero__(self):
"""
EXAMPLES::
Expand All @@ -361,8 +361,6 @@ cdef class FunctionFieldElement_polymod(FunctionFieldElement):
"""
return not not self._x

__nonzero__ =__bool__

def __hash__(self):
"""
TESTS::
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/ideal.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ def __bool__(self):
return True
return False

__nonzero__ =__bool__
__nonzero__ = __bool__

def base_ring(self):
r"""
Expand Down
4 changes: 1 addition & 3 deletions src/sage/rings/integer.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -4293,7 +4293,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
"""
return mpz_cmp_si(self.value, 1) == 0

def __bool__(self):
def __nonzero__(self):
r"""
Returns ``True`` if the integer is not `0`, otherwise ``False``.

Expand All @@ -4306,8 +4306,6 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
"""
return mpz_sgn(self.value) != 0

__nonzero__ =__bool__

def is_integral(self):
"""
Return ``True`` since integers are integral, i.e.,
Expand Down
4 changes: 1 addition & 3 deletions src/sage/rings/laurent_series_ring_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,9 @@ cdef class LaurentSeries(AlgebraElement):

return self.__u.is_monomial()

def __bool__(self):
def __nonzero__(self):
return not not self.__u

__nonzero__ =__bool__

def _im_gens_(self, codomain, im_gens):
return codomain(self(im_gens[0]))

Expand Down
4 changes: 1 addition & 3 deletions src/sage/rings/morphism.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ cdef class RingHomomorphism(RingMap):
raise TypeError("parent must be a ring homset")
RingMap.__init__(self, parent)

def __bool__(self):
def __nonzero__(self):
"""
Every ring map is nonzero unless the domain or codomain is the
0 ring, since there is no zero map between rings, since 1 goes
Expand All @@ -626,8 +626,6 @@ cdef class RingHomomorphism(RingMap):
"""
return bool(self.codomain().one())

__nonzero__ =__bool__

def _repr_type(self):
"""
Used internally in printing this morphism.
Expand Down
4 changes: 1 addition & 3 deletions src/sage/rings/number_field/number_field_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2265,7 +2265,7 @@ cdef class NumberFieldElement(FieldElement):
"""
return self._mul_(~right)

def __bool__(self):
def __nonzero__(self):
"""
Return True if this number field element is nonzero.

Expand All @@ -2284,8 +2284,6 @@ cdef class NumberFieldElement(FieldElement):
"""
return not IsZero_ZZX(self.__numerator)

__nonzero__ =__bool__

cpdef _neg_(self):
r"""
EXAMPLE::
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1317,7 +1317,7 @@ cdef class NumberFieldElement_quadratic(NumberFieldElement_absolute):
h += 42082631 * mpz_pythonhash(self.b)
return h

def __bool__(self):
def __nonzero__(self):
"""
Check whether this element is not zero.

Expand All @@ -1331,8 +1331,6 @@ cdef class NumberFieldElement_quadratic(NumberFieldElement_absolute):
"""
return mpz_cmp_ui(self.a, 0) != 0 or mpz_cmp_ui(self.b, 0) != 0

__nonzero__ =__bool__

def _integer_(self, Z=None):
"""
EXAMPLES:
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/padics/CA_template.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ cdef class CAElement(pAdicTemplateElement):
"""
return not ciszero(self.value, self.prime_pow)

__nonzero__ =__bool__
__nonzero__ = __bool__

def is_equal_to(self, _right, absprec=None):
r"""
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/padics/CR_template.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ cdef class CRElement(pAdicTemplateElement):
"""
return self.relprec != 0

__nonzero__ =__bool__
__nonzero__ = __bool__

def is_equal_to(self, _right, absprec=None):
r"""
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/padics/FM_template.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ cdef class FMElement(pAdicTemplateElement):
"""
return not ciszero(self.value, self.prime_pow)

__nonzero__ =__bool__
__nonzero__ = __bool__

def is_equal_to(self, _right, absprec=None):
r"""
Expand Down
4 changes: 1 addition & 3 deletions src/sage/rings/polynomial/laurent_polynomial.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ cdef class LaurentPolynomial_univariate(LaurentPolynomial_generic):
"""
return self.__u.is_zero()

def __bool__(self):
def __nonzero__(self):
"""
Check if ``self`` is non-zero.

Expand All @@ -177,8 +177,6 @@ cdef class LaurentPolynomial_univariate(LaurentPolynomial_generic):
"""
return not self.__u.is_zero()

__nonzero__ =__bool__

def _im_gens_(self, codomain, im_gens):
"""
Return the image of ``self`` under the morphism defined by
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/polynomial/multi_polynomial_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -1474,7 +1474,7 @@ def __bool__(self):
"""
return self._MPolynomial_element__element.dict()!={}

__nonzero__ =__bool__
__nonzero__ = __bool__

def _floordiv_(self, right):
r"""
Expand Down
4 changes: 1 addition & 3 deletions src/sage/rings/polynomial/multi_polynomial_libsingular.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -3888,7 +3888,7 @@ cdef class MPolynomial_libsingular(sage.rings.polynomial.multi_polynomial.MPolyn
else:
return False

def __bool__(self):
def __nonzero__(self):
"""
EXAMPLES::

Expand All @@ -3903,8 +3903,6 @@ cdef class MPolynomial_libsingular(sage.rings.polynomial.multi_polynomial.MPolyn
else:
return False

__nonzero__ =__bool__

cpdef _floordiv_(self, right):
"""
Perform division with remainder and return the quotient.
Expand Down
Loading

0 comments on commit 41d63ab

Please sign in to comment.