From c84246e912c9380936c9e122934ed94ab160453f Mon Sep 17 00:00:00 2001 From: Emmanuel Jeanvoine Date: Mon, 14 Feb 2011 08:51:59 +0000 Subject: [PATCH 1/2] #10779: Improve coverage test for structure/element.pyx --- src/sage/structure/element.pyx | 253 +++++++++++++++++++++------------ 1 file changed, 164 insertions(+), 89 deletions(-) diff --git a/src/sage/structure/element.pyx b/src/sage/structure/element.pyx index b233a1ee85e..3b312375562 100644 --- a/src/sage/structure/element.pyx +++ b/src/sage/structure/element.pyx @@ -224,11 +224,11 @@ def py_scalar_to_element(py): elif PyComplex_Check(py): return CDF(py) else: - raise TypeError, "Not a scalar" + raise TypeError("Not a scalar") def is_Element(x): """ - Return True if x is of type Element. + Return ``True`` if x is of type Element. EXAMPLES:: @@ -319,7 +319,7 @@ cdef class Element(sage_object.SageObject): AttributeError: 'LeftZeroSemigroup_with_category.element_class' object has no attribute 'blah_blah' We test that "private" attributes are not requested from the element class - of the category (trac ticket #10467):: + of the category (:trac:`10467`):: sage: C = EuclideanDomains() sage: P. = QQ[] @@ -447,8 +447,8 @@ cdef class Element(sage_object.SageObject): def _im_gens_(self, codomain, im_gens): """ - Return the image of self in codomain under the map that sends - the images of the generators of the parent of self to the + Return the image of ``self`` in codomain under the map that sends + the images of the generators of the parent of ``self`` to the tuple of elements of im_gens. """ raise NotImplementedError @@ -470,6 +470,13 @@ cdef class Element(sage_object.SageObject): def base_ring(self): """ Returns the base ring of this element's parent (if that makes sense). + + TESTS:: + + sage: QQ.base_ring() + Rational Field + sage: identity_matrix(3).base_ring() + Integer Ring """ return self._parent.base_ring() @@ -637,15 +644,15 @@ cdef class Element(sage_object.SageObject): sage: (2/3).n() 0.666666666666667 - sage: pi.n(digits=10) + sage: pi.n(digits=10) # indirect doctest 3.141592654 - sage: pi.n(prec=20) # 20 bits + sage: pi.n(prec=20) # indirect doctest 3.1416 """ - import sage.misc.functional - return sage.misc.functional.numerical_approx(self, prec=prec, digits=digits) - n=numerical_approx - N=n + from sage.misc.functional import numerical_approx + return numerical_approx(self, prec=prec, digits=digits) + n = numerical_approx + N = n def _mpmath_(self, prec=53, rounding=None): """ @@ -706,7 +713,7 @@ cdef class Element(sage_object.SageObject): cpdef _act_on_(self, x, bint self_on_left): """ - Use this method to implement self acting on x. + Use this method to implement ``self`` acting on x. Return None or raise a CoercionException if no such action is defined here. @@ -715,7 +722,7 @@ cdef class Element(sage_object.SageObject): cpdef _acted_upon_(self, x, bint self_on_left): """ - Use this method to implement self acted on by x. + Use this method to implement ``self`` acted on by x. Return None or raise a CoercionException if no such action is defined here. @@ -724,8 +731,8 @@ cdef class Element(sage_object.SageObject): def __xor__(self, right): - raise RuntimeError, "Use ** for exponentiation, not '^', which means xor\n"+\ - "in Python, and has the wrong precedence." + raise RuntimeError("Use ** for exponentiation, not '^', which means xor\n"+\ + "in Python, and has the wrong precedence.") def __pos__(self): return self @@ -751,7 +758,7 @@ cdef class Element(sage_object.SageObject): def _is_atomic(self): """ - Return True if and only if parenthesis are not required when + Return ``True`` if and only if parenthesis are not required when *printing* out any of `x - s`, `x + s`, `x^s` and `x/s`. EXAMPLES:: @@ -768,7 +775,7 @@ cdef class Element(sage_object.SageObject): def __nonzero__(self): r""" - Return True if self does not equal self.parent()(0). + Return ``True`` if ``self`` does not equal self.parent()(0). Note that this is automatically called when converting to boolean, as in the conditional of an if or while statement. @@ -793,7 +800,7 @@ cdef class Element(sage_object.SageObject): def is_zero(self): """ - Return True if self equals self.parent()(0). The default + Return ``True`` if ``self`` equals self.parent()(0). The default implementation is to fall back to 'not self.__nonzero__'. .. warning:: @@ -937,7 +944,7 @@ cdef class Element(sage_object.SageObject): cdef int _cmp_c_impl(left, Element right) except -2: ### For derived Cython code, you *MUST* ALSO COPY the __richcmp__ above ### into your class!!! For Python code just use __cmp__. - raise NotImplementedError, "BUG: sort algorithm for elements of '%s' not implemented"%right.parent() + raise NotImplementedError("BUG: sort algorithm for elements of '%s' not implemented"%right.parent()) cdef inline bint _rich_to_bool(int op, int r): if op == Py_LT: #< @@ -956,7 +963,7 @@ cdef inline bint _rich_to_bool(int op, int r): def is_ModuleElement(x): """ - Return True if x is of type ModuleElement. + Return ``True`` if x is of type ModuleElement. This is even faster than using isinstance inline. @@ -980,7 +987,7 @@ cdef class ElementWithCachedMethod(Element): The :class:`~sage.misc.cachefunc.cached_method` decorator provides a convenient way to automatically cache the result of a computation. - Since trac ticket #11115, the cached method decorator applied to a + Since :trac:`11115`, the cached method decorator applied to a method without optional arguments is faster than a hand-written cache in Python, and a cached method without any arguments (except ``self``) is actually faster than a Python method that does nothing more but @@ -1220,7 +1227,7 @@ cdef class ModuleElement(Element): return coercion_model.bin_op(left, right, add) cpdef ModuleElement _add_(left, ModuleElement right): - raise TypeError, arith_error_message(left, right, add) + raise TypeError(arith_error_message(left, right, add)) def __iadd__(ModuleElement self, right): if have_same_parent(self, right): @@ -1299,7 +1306,7 @@ cdef class ModuleElement(Element): if PyInt_CheckExact(left): return (right)._mul_long(PyInt_AS_LONG(left)) if have_same_parent(left, right): - raise TypeError, arith_error_message(left, right, mul) + raise TypeError(arith_error_message(left, right, mul)) # Always do this global coercion_model return coercion_model.bin_op(left, right, mul) @@ -1372,7 +1379,7 @@ cdef class ModuleElement(Element): def is_MonoidElement(x): """ - Return True if x is of type MonoidElement. + Return ``True`` if x is of type MonoidElement. """ return IS_INSTANCE(x, MonoidElement) @@ -1430,7 +1437,7 @@ cdef class MonoidElement(Element): Return the (integral) power of self. """ if dummy is not None: - raise RuntimeError, "__pow__ dummy argument not used" + raise RuntimeError("__pow__ dummy argument not used") return generic_power_c(self,n,None) def __nonzero__(self): @@ -1438,7 +1445,7 @@ cdef class MonoidElement(Element): def is_AdditiveGroupElement(x): """ - Return True if x is of type AdditiveGroupElement. + Return ``True`` if x is of type AdditiveGroupElement. """ return IS_INSTANCE(x, AdditiveGroupElement) @@ -1453,7 +1460,7 @@ cdef class AdditiveGroupElement(ModuleElement): return self.additive_order() def __invert__(self): - raise NotImplementedError, "multiplicative inverse not defined for additive group elements" + raise NotImplementedError("multiplicative inverse not defined for additive group elements") cpdef ModuleElement _rmul_(self, RingElement left): return self._lmul_(left) @@ -1470,7 +1477,7 @@ cdef class AdditiveGroupElement(ModuleElement): def is_MultiplicativeGroupElement(x): """ - Return True if x is of type MultiplicativeGroupElement. + Return ``True`` if x is of type MultiplicativeGroupElement. """ return IS_INSTANCE(x, MultiplicativeGroupElement) @@ -1485,7 +1492,7 @@ cdef class MultiplicativeGroupElement(MonoidElement): return self.multiplicative_order() def _add_(self, x): - raise ArithmeticError, "addition not defined in a multiplicative group" + raise ArithmeticError("addition not defined in a multiplicative group") def __div__(left, right): if have_same_parent(left, right): @@ -1508,7 +1515,7 @@ cdef class MultiplicativeGroupElement(MonoidElement): def is_RingElement(x): """ - Return True if x is of type RingElement. + Return ``True`` if x is of type RingElement. """ return IS_INSTANCE(x, RingElement) @@ -1705,7 +1712,7 @@ cdef class RingElement(ModuleElement): Cython classes should override this function to implement multiplication. See extensive documentation at the top of element.pyx. """ - raise TypeError, arith_error_message(self, right, mul) + raise TypeError(arith_error_message(self, right, mul)) def __imul__(left, right): if have_same_parent(left, right): @@ -1766,7 +1773,7 @@ cdef class RingElement(ModuleElement): sage: 2r^(1/2) sqrt(2) - Exponent overflow should throw an OverflowError (trac #2956):: + Exponent overflow should throw an OverflowError (:trac:`2956`):: sage: K. = AA[] sage: x^(2^64 + 12345) @@ -1774,7 +1781,7 @@ cdef class RingElement(ModuleElement): ... OverflowError: Exponent overflow (2147483648). - Another example from trac #2956; this should overflow on x32 + Another example from :trac:`2956`; this should overflow on x32 and succeed on x64:: sage: K. = ZZ[] @@ -1786,7 +1793,7 @@ cdef class RingElement(ModuleElement): """ if dummy is not None: - raise RuntimeError, "__pow__ dummy argument not used" + raise RuntimeError("__pow__ dummy argument not used") return generic_power_c(self,n,None) ################################## @@ -1821,9 +1828,9 @@ cdef class RingElement(ModuleElement): return self._parent.fraction_field()(self, right) except AttributeError: if not right: - raise ZeroDivisionError, "Cannot divide by zero" + raise ZeroDivisionError("Cannot divide by zero") else: - raise TypeError, arith_error_message(self, right, div) + raise TypeError(arith_error_message(self, right, div)) def __idiv__(self, right): """ @@ -1874,11 +1881,11 @@ cdef class RingElement(ModuleElement): def multiplicative_order(self): r""" - Return the multiplicative order of self, if self is a unit, or raise + Return the multiplicative order of self, if ``self`` is a unit, or raise ``ArithmeticError`` otherwise. """ if not self.is_unit(): - raise ArithmeticError, "self (=%s) must be a unit to have a multiplicative order." + raise ArithmeticError("self (=%s) must be a unit to have a multiplicative order.") raise NotImplementedError def is_unit(self): @@ -1888,8 +1895,22 @@ cdef class RingElement(ModuleElement): def is_nilpotent(self): """ - Return True if self is nilpotent, i.e., some power of self + Return ``True`` if ``self`` is nilpotent, i.e., some power of self is 0. + + TESTS:: + + sage: a=QQ(2) + sage: a.is_nilpotent() + False + sage: a=QQ(0) + sage: a.is_nilpotent() + True + sage: m=matrix(RR,3,[[3,2,3],[9,0,3],[-9,0,-3]]) + sage: m.is_nilpotent() + Traceback (most recent call last): + ... + NotImplementedError """ if self.is_unit(): return False @@ -1921,7 +1942,19 @@ cdef class RingElement(ModuleElement): def is_CommutativeRingElement(x): """ - Return True if x is of type CommutativeRingElement. + Return ``True`` if x is of type CommutativeRingElement. + + TESTS:: + + sage: is_CommutativeRingElement(oo) + doctest:...: DeprecationWarning: + Using is_CommutativeRingElement from the top level is deprecated since it was designed to be used by developers rather than end users. + It most likely does not do what you would expect it to do. If you really need to use it, import it from the module that it is defined in. + See http://trac.sagemath.org/10107 for details. + False + + sage: is_CommutativeRingElement(1) + True """ return IS_INSTANCE(x, CommutativeRingElement) @@ -1933,14 +1966,14 @@ cdef class CommutativeRingElement(RingElement): def inverse_mod(self, I): r""" - Return an inverse of self modulo the ideal `I`, if defined, - i.e., if `I` and self together generate the unit ideal. + Return an inverse of ``self`` modulo the ideal `I`, if defined, + i.e., if `I` and ``self`` together generate the unit ideal. """ raise NotImplementedError def divides(self, x): """ - Return True if self divides x. + Return ``True`` if ``self`` divides x. EXAMPLES:: @@ -1959,7 +1992,7 @@ cdef class CommutativeRingElement(RingElement): sage: (x^2+2).divides(x) False - Ticket \#5347 has been fixed:: + :trac:`5347` has been fixed:: sage: K = GF(7) sage: K(3).divides(1) @@ -1987,7 +2020,7 @@ cdef class CommutativeRingElement(RingElement): If x has different parent than `self`, they are first coerced to a common parent if possible. If this coercion fails, it returns a - TypeError. This fixes \#5759 + TypeError. This fixes :trac:`5759` :: sage: Zmod(2)(0).divides(Zmod(2)(0)) @@ -2042,7 +2075,7 @@ cdef class CommutativeRingElement(RingElement): def mod(self, I): r""" - Return a representative for self modulo the ideal I (or the ideal + Return a representative for ``self`` modulo the ideal I (or the ideal generated by the elements of I if I is not an ideal.) EXAMPLE: Integers @@ -2120,7 +2153,7 @@ cdef class CommutativeRingElement(RingElement): def is_square(self, root=False): """ Returns whether or not ring element is a square. If the optional - argument root is True, then also returns the square root (or None, + argument root is ``True``, then also returns the square root (or None, if the it is not a square). INPUT: @@ -2169,17 +2202,17 @@ cdef class CommutativeRingElement(RingElement): INPUT: - - ``extend`` - Whether to make a ring extension containing a square root if self is not a square (default: True) + - ``extend`` - Whether to make a ring extension containing a square root if ``self`` is not a square (default: ``True``) - ``all`` - Whether to return a list of all square roots or just a square root (default: False) - - ``name`` - Required when extend=True and self is not a square. This will be the name of the generator extension. + - ``name`` - Required when extend=``True`` and ``self`` is not a square. This will be the name of the generator extension. OUTPUT: - - if all=False it returns a square root. (throws an error if extend=False and self is not a square) + - if all=False it returns a square root. (throws an error if extend=False and ``self`` is not a square) - - if all=True it returns a list of all the square roots (could be empty if extend=False and self is not a square) + - if all=``True`` it returns a list of all the square roots (could be empty if extend=False and ``self`` is not a square) ALGORITHM: @@ -2274,10 +2307,10 @@ cdef class CommutativeRingElement(RingElement): #all square roots of a non-square should be an empty list if all: return [] - raise ValueError, 'trying to take square root of non-square %s with extend = False' % self + raise ValueError('trying to take square root of non-square %s with extend = False' % self) if name == None: - raise TypeError ("Polynomial is not a square. You must specify the name of the square root when using the default extend = True") + raise TypeError("Polynomial is not a square. You must specify the name of the square root when using the default extend = True") from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing PY = PolynomialRing(P,'y') y = PY.gen() @@ -2474,10 +2507,10 @@ cdef class Vector(ModuleElement): return coercion_model.bin_op(left, right, mul) cpdef Element _dot_product_(Vector left, Vector right): - raise TypeError, arith_error_message(left, right, mul) + raise TypeError(arith_error_message(left, right, mul)) cpdef Vector _pairwise_product_(Vector left, Vector right): - raise TypeError, "unsupported operation for '%s' and '%s'"%(parent_c(left), parent_c(right)) + raise TypeError("unsupported operation for '%s' and '%s'"%(parent_c(left), parent_c(right))) def __div__(self, right): if PY_IS_NUMERIC(right): @@ -2491,10 +2524,10 @@ cdef class Vector(ModuleElement): return W.coordinates(self)[0] / W.coordinates(right)[0] except ArithmeticError: if right.is_zero(): - raise ZeroDivisionError, "division by zero vector" + raise ZeroDivisionError("division by zero vector") else: - raise ArithmeticError, "vector is not in free module" - raise TypeError, arith_error_message(self, right, div) + raise ArithmeticError("vector is not in free module") + raise TypeError(arith_error_message(self, right, div)) def _magma_init_(self, magma): """ @@ -2766,7 +2799,7 @@ def is_Matrix(x): def is_IntegralDomainElement(x): """ - Return True if x is of type IntegralDomainElement. + Return ``True`` if x is of type IntegralDomainElement. """ return IS_INSTANCE(x, IntegralDomainElement) @@ -2777,7 +2810,7 @@ cdef class IntegralDomainElement(CommutativeRingElement): def is_DedekindDomainElement(x): """ - Return True if x is of type DedekindDomainElement. + Return ``True`` if x is of type DedekindDomainElement. """ return IS_INSTANCE(x, DedekindDomainElement) @@ -2786,14 +2819,14 @@ cdef class DedekindDomainElement(IntegralDomainElement): def is_PrincipalIdealDomainElement(x): """ - Return True if x is of type PrincipalIdealDomainElement. + Return ``True`` if x is of type PrincipalIdealDomainElement. """ return IS_INSTANCE(x, PrincipalIdealDomainElement) cdef class PrincipalIdealDomainElement(DedekindDomainElement): def lcm(self, right): """ - Returns the least common multiple of self and right. + Returns the least common multiple of ``self`` and right. """ if not PY_TYPE_CHECK(right, Element) or not ((right)._parent is self._parent): return coercion_model.bin_op(self, right, lcm) @@ -2801,7 +2834,7 @@ cdef class PrincipalIdealDomainElement(DedekindDomainElement): def gcd(self, right): """ - Returns the gcd of self and right, or 0 if both are 0. + Returns the gcd of ``self`` and right, or 0 if both are 0. """ if not PY_TYPE_CHECK(right, Element) or not ((right)._parent is self._parent): return coercion_model.bin_op(self, right, gcd) @@ -2809,10 +2842,10 @@ cdef class PrincipalIdealDomainElement(DedekindDomainElement): def xgcd(self, right): r""" - Return the extended gcd of self and other, i.e., elements `r, s, t` such that + Return the extended gcd of ``self`` and other, i.e., elements `r, s, t` such that .. math:: - r = s \cdot self + t \cdot other. + r = s \cdot ``self`` + t \cdot other. .. note:: @@ -2832,7 +2865,7 @@ PY_SET_TP_NEW(EuclideanDomainElement, Element) def is_EuclideanDomainElement(x): """ - Return True if x is of type EuclideanDomainElement. + Return ``True`` if x is of type EuclideanDomainElement. """ return IS_INSTANCE(x, EuclideanDomainElement) @@ -2843,7 +2876,7 @@ cdef class EuclideanDomainElement(PrincipalIdealDomainElement): def _gcd(self, other): """ - Return the greatest common divisor of self and other. + Return the greatest common divisor of ``self`` and other. Algorithm 3.2.1 in Cohen, GTM 138. """ @@ -2863,7 +2896,7 @@ cdef class EuclideanDomainElement(PrincipalIdealDomainElement): def __divmod__(self, other): """ - Return the quotient and remainder of self divided by other. + Return the quotient and remainder of ``self`` divided by other. EXAMPLES:: @@ -2883,14 +2916,14 @@ cdef class EuclideanDomainElement(PrincipalIdealDomainElement): def __floordiv__(self,right): """ - Quotient of division of self by other. This is denoted //. + Quotient of division of ``self`` by other. This is denoted //. """ Q, _ = self.quo_rem(right) return Q def __mod__(self, other): """ - Remainder of division of self by other. + Remainder of division of ``self`` by other. EXAMPLES:: @@ -2905,7 +2938,7 @@ cdef class EuclideanDomainElement(PrincipalIdealDomainElement): def is_FieldElement(x): """ - Return True if x is of type FieldElement. + Return ``True`` if x is of type FieldElement. """ return IS_INSTANCE(x, FieldElement) @@ -2916,7 +2949,7 @@ cdef class FieldElement(CommutativeRingElement): def is_unit(self): """ - Return True if self is a unit in its parent ring. + Return ``True`` if ``self`` is a unit in its parent ring. EXAMPLES:: @@ -2941,7 +2974,7 @@ cdef class FieldElement(CommutativeRingElement): def _gcd(self, FieldElement other): """ - Return the greatest common divisor of self and other. + Return the greatest common divisor of ``self`` and other. """ if self.is_zero() and other.is_zero(): return self @@ -2950,7 +2983,7 @@ cdef class FieldElement(CommutativeRingElement): def _lcm(self, FieldElement other): """ - Return the least common multiple of self and other. + Return the least common multiple of ``self`` and other. """ if self.is_zero() and other.is_zero(): return self @@ -2990,7 +3023,7 @@ cdef class FieldElement(CommutativeRingElement): def divides(self, FieldElement other): r""" - Check whether self divides other, for field elements. + Check whether ``self`` divides other, for field elements. Since this is a field, all values divide all other values, except that zero does not divide any non-zero values. @@ -3013,7 +3046,20 @@ cdef class FieldElement(CommutativeRingElement): def is_AlgebraElement(x): """ - Return True if x is of type AlgebraElement. + Return ``True`` if x is of type AlgebraElement. + + TESTS:: + + sage: R. = FreeAlgebra(QQ,2) + sage: is_AlgebraElement(x*y) + doctest:...: DeprecationWarning: + Using is_AlgebraElement from the top level is deprecated since it was designed to be used by developers rather than end users. + It most likely does not do what you would expect it to do. If you really need to use it, import it from the module that it is defined in. + See http://trac.sagemath.org/10107 for details. + True + + sage: is_AlgebraElement(1) + False """ return IS_INSTANCE(x, AlgebraElement) @@ -3022,7 +3068,7 @@ cdef class AlgebraElement(RingElement): def is_CommutativeAlgebraElement(x): """ - Return True if x is of type CommutativeAlgebraElement. + Return ``True`` if x is of type CommutativeAlgebraElement. """ return IS_INSTANCE(x, CommutativeAlgebraElement) @@ -3031,7 +3077,19 @@ cdef class CommutativeAlgebraElement(CommutativeRingElement): def is_InfinityElement(x): """ - Return True if x is of type InfinityElement. + Return ``True`` if x is of type InfinityElement. + + TESTS:: + + sage: is_InfinityElement(1) + doctest:...: DeprecationWarning: + Using is_InfinityElement from the top level is deprecated since it was designed to be used by developers rather than end users. + It most likely does not do what you would expect it to do. If you really need to use it, import it from the module that it is defined in. + See http://trac.sagemath.org/10107 for details. + False + + sage: is_InfinityElement(oo) + True """ return IS_INSTANCE(x, InfinityElement) @@ -3104,12 +3162,12 @@ cdef class CoercionModel: cpdef canonical_coercion(self, x, y): if parent_c(x) is parent_c(y): return x,y - raise TypeError, "no common canonical parent for objects with parents: '%s' and '%s'"%(parent_c(x), parent_c(y)) + raise TypeError("no common canonical parent for objects with parents: '%s' and '%s'"%(parent_c(x), parent_c(y))) cpdef bin_op(self, x, y, op): if parent_c(x) is parent_c(y): return op(x,y) - raise TypeError, arith_error_message(x,y,op) + raise TypeError(arith_error_message(x,y,op)) import coerce cdef CoercionModel coercion_model = coerce.CoercionModel_cache_maps() @@ -3331,19 +3389,36 @@ coerce_binop = NamedBinopMethod ############################################################################### -def lcm(x,y): +def lcm(x, y): + """ + TESTS:: + + sage: lcm(3,-4) + 12 + """ from sage.rings.arith import lcm - return lcm(x,y) + return lcm(x, y) -def gcd(x,y): - from sage.rings.arith import gcd - return gcd(x,y) +def gcd(x, y): + """ + TESTS:: -def xgcd(x,y): - from sage.rings.arith import xgcd - return xgcd(x,y) + sage: gcd(12,15) + 3 + """ + from sage.rings.arith import gcd + return gcd(x, y) +def xgcd(x, y): + """ + TESTS:: + sage: x = polygen(QQ) + sage: xgcd(x^3 - 1, x^2 - 1) + (x - 1, 1, -x) + """ + from sage.rings.arith import xgcd + return xgcd(x, y) ###################### @@ -3395,7 +3470,7 @@ cdef generic_power_c(a, nn, one): from sage.rings.integer import Integer n = int(Integer(nn)) except TypeError: - raise NotImplementedError, "non-integral exponents not supported" + raise NotImplementedError("non-integral exponents not supported") if not n: if one is None: From 2e30025298097a2c280629135f3f76d973c0b4a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Tue, 27 May 2014 20:44:14 +0200 Subject: [PATCH 2/2] trac #10779 corrected 3 doctests --- src/sage/structure/element.pyx | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/sage/structure/element.pyx b/src/sage/structure/element.pyx index ed2ae24089e..1dc1fd1bb77 100644 --- a/src/sage/structure/element.pyx +++ b/src/sage/structure/element.pyx @@ -1934,11 +1934,8 @@ def is_CommutativeRingElement(x): TESTS:: + sage: from sage.rings.commutative_ring_element import is_CommutativeRingElement sage: is_CommutativeRingElement(oo) - doctest:...: DeprecationWarning: - Using is_CommutativeRingElement from the top level is deprecated since it was designed to be used by developers rather than end users. - It most likely does not do what you would expect it to do. If you really need to use it, import it from the module that it is defined in. - See http://trac.sagemath.org/10107 for details. False sage: is_CommutativeRingElement(1) @@ -2978,12 +2975,9 @@ def is_AlgebraElement(x): TESTS:: + sage: from sage.structure.element import is_AlgebraElement sage: R. = FreeAlgebra(QQ,2) sage: is_AlgebraElement(x*y) - doctest:...: DeprecationWarning: - Using is_AlgebraElement from the top level is deprecated since it was designed to be used by developers rather than end users. - It most likely does not do what you would expect it to do. If you really need to use it, import it from the module that it is defined in. - See http://trac.sagemath.org/10107 for details. True sage: is_AlgebraElement(1) @@ -3009,11 +3003,8 @@ def is_InfinityElement(x): TESTS:: + sage: from sage.structure.element import is_InfinityElement sage: is_InfinityElement(1) - doctest:...: DeprecationWarning: - Using is_InfinityElement from the top level is deprecated since it was designed to be used by developers rather than end users. - It most likely does not do what you would expect it to do. If you really need to use it, import it from the module that it is defined in. - See http://trac.sagemath.org/10107 for details. False sage: is_InfinityElement(oo)