# Ticket #4539: trac4539_fix_docs.patch

File trac4539_fix_docs.patch, 42.1 KB (added by SimonKing, 6 years ago)

Fixing doc strings and doc tests

• ## sage/libs/singular/function.pyx

```# HG changeset patch
# User Simon King <simon.king@uni-jena.de>
# Date 1317313679 -7200
# Node ID d129c0622eb94d3871297ccb39de1edbf44eb729
# Parent  9f95d173ac536e34aa7c6f711843b4aa1632f166
#4539: Fix doc string format; fix doc test errors left over by the previous patches.

diff --git a/sage/libs/singular/function.pyx b/sage/libs/singular/function.pyx```
 a def is_singular_poly_wrapper(p): """ Checks if p is some data type corresponding to some singular ``poly```. Checks if p is some data type corresponding to some singular ``poly``. EXAMPLE:: sage: from sage.rings.polynomial.plural import NCPolynomialRing_plural sage: from sage.matrix.constructor  import Matrix sage: from sage.libs.singular.function import is_singular_poly_wrapper sage: c=Matrix(2) sage: c[0,1]=-1 sage: P = NCPolynomialRing_plural(QQ, 2, 'x,y', c=c, d=Matrix(2)) sage: (x,y)=P.gens() sage: A. = FreeAlgebra(QQ, 3) sage: H. = A.g_algebra({z*x:x*z+2*x, z*y:y*z-2*y}) sage: is_singular_poly_wrapper(x+y) True """ return PY_TYPE_CHECK(p, MPolynomial_libsingular) or PY_TYPE_CHECK(p,  NCPolynomial_plural) sage: singular_list(resolution) [[(-2*y, 2, y + 1, 0), (0, -2, x - 1, 0), (x*y - y, -y + 1, 1, -y), (x^2 + 1, -x - 1, -1, -x)], [(-x - 1, y - 1, 2*x, -2*y)], [(0)]] sage: from sage.rings.polynomial.plural import NCPolynomialRing_plural sage: from sage.matrix.constructor  import Matrix sage: c=Matrix(2) sage: c[0,1]=-1 sage: P = NCPolynomialRing_plural(QQ, 2, 'x,y', c=c, d=Matrix(2)) sage: (x,y)=P.gens() sage: I= Sequence([x*y,x+y], check=False, immutable=True)#P.ideal(x*y,x+y) sage: A. = FreeAlgebra(QQ, 2) sage: P. = A.g_algebra({y*x:-x*y}) sage: I= Sequence([x*y,x+y], check=False, immutable=True) sage: twostd = singular_function("twostd") sage: twostd(I) [x + y, y^2]
• ## sage/libs/singular/groebner_strategy.pyx

`diff --git a/sage/libs/singular/groebner_strategy.pyx b/sage/libs/singular/groebner_strategy.pyx`
 a EXAMPLES:: sage: from sage.libs.singular.groebner_strategy import GroebnerStrategy sage: P. = PolynomialRing(QQ) sage: I = Ideal([x+z,y+z+1]) sage: strat = GroebnerStrategy(I); strat Groebner Strategy for ideal generated by 2 elements over Multivariate Polynomial Ring in x, y, z over Rational Field sage: from sage.libs.singular.groebner_strategy import NCGroebnerStrategy sage: A. = FreeAlgebra(QQ, 3) sage: H. = A.g_algebra({y*x:x*y-z, z*x:x*z+2*x, z*y:y*z-2*y}) sage: I = H.ideal([y^2, x^2, z^2-H.one_element()]) sage: NCGroebnerStrategy(I) Groebner Strategy for ideal generated by 3 elements over Noncommutative Multivariate Polynomial Ring in x, y, z over Rational Field, nc-relations: {y*x: x*y - z, z*y: y*z - 2*y, z*x: x*z + 2*x} TESTS:: sage: from sage.libs.singular.groebner_strategy import GroebnerStrategy sage: strat = GroebnerStrategy(None) sage: strat = NCGroebnerStrategy(None) Traceback (most recent call last): ... TypeError: First parameter must be a multivariate polynomial ideal. TypeError: First parameter must be an ideal in a g-algebra. sage: P. = PolynomialRing(QQ,order='neglex') sage: P. = PolynomialRing(CC,order='neglex') sage: I = Ideal([x+z,y+z+1]) sage: strat = GroebnerStrategy(I) sage: strat = NCGroebnerStrategy(I) Traceback (most recent call last): ... NotImplementedError: The local case is not implemented yet. sage: P. = PolynomialRing(CC,order='neglex') sage: I = Ideal([x+z,y+z+1]) sage: strat = GroebnerStrategy(I) Traceback (most recent call last): ... TypeError: First parameter's ring must be multivariate polynomial ring via libsingular. TypeError:  First parameter must be an ideal in a g-algebra. sage: P. = PolynomialRing(ZZ) sage: I = Ideal([x+z,y+z+1]) sage: strat = GroebnerStrategy(I) Traceback (most recent call last): ... NotImplementedError: Only coefficient fields are implemented so far. """ if not isinstance(L, NCPolynomialIdeal): raise TypeError("First parameter must be an ideal in a g-algebra.") if not isinstance(L.ring(), NCPolynomialRing_plural): raise TypeError("First parameter's ring must be multivariate polynomial ring via libsingular.") raise TypeError("First parameter's ring must be a g-algebra.") self._ideal = L """ TEST:: sage: from sage.libs.singular.groebner_strategy import GroebnerStrategy sage: P. = PolynomialRing(GF(32003)) sage: I = Ideal([x + z, y + z]) sage: strat = GroebnerStrategy(I) sage: del strat sage: from sage.libs.singular.groebner_strategy import NCGroebnerStrategy sage: A. = FreeAlgebra(QQ, 3) sage: H. = A.g_algebra({y*x:x*y-z, z*x:x*z+2*x, z*y:y*z-2*y}) sage: I = H.ideal([y^2, x^2, z^2-H.one_element()]) sage: strat = NCGroebnerStrategy(I) sage: del strat   # indirect doctest """ cdef ring *oldRing = NULL if self._strat: """ TEST:: sage: from sage.libs.singular.groebner_strategy import GroebnerStrategy sage: P. = PolynomialRing(GF(32003)) sage: I = Ideal([x + z, y + z]) sage: strat = GroebnerStrategy(I) sage: from sage.libs.singular.groebner_strategy import NCGroebnerStrategy sage: A. = FreeAlgebra(QQ, 3) sage: H. = A.g_algebra({y*x:x*y-z, z*x:x*z+2*x, z*y:y*z-2*y}) sage: I = H.ideal([y^2, x^2, z^2-H.one_element()]) sage: strat = NCGroebnerStrategy(I) sage: strat # indirect doctest Groebner Strategy for ideal generated by 2 elements over Multivariate Polynomial Ring in x, y, z over Finite Field of size 32003 Groebner Strategy for ideal generated by 3 elements over Noncommutative Multivariate Polynomial Ring in x, y, z over Rational Field, nc-relations: {y*x: x*y - z, z*y: y*z - 2*y, z*x: x*z + 2*x} """ return "Groebner Strategy for ideal generated by %d elements over %s"%(self._ideal.ngens(),self._parent) EXAMPLE:: sage: from sage.libs.singular.groebner_strategy import GroebnerStrategy sage: P. = PolynomialRing(GF(32003)) sage: I = Ideal([x + z, y + z]) sage: strat = GroebnerStrategy(I) sage: strat.ideal() Ideal (x + z, y + z) of Multivariate Polynomial Ring in x, y, z over Finite Field of size 32003 sage: from sage.libs.singular.groebner_strategy import NCGroebnerStrategy sage: A. = FreeAlgebra(QQ, 3) sage: H. = A.g_algebra({y*x:x*y-z, z*x:x*z+2*x, z*y:y*z-2*y}) sage: I = H.ideal([y^2, x^2, z^2-H.one_element()]) sage: strat = NCGroebnerStrategy(I) sage: strat.ideal() == I True """ return self._ideal EXAMPLE:: sage: from sage.libs.singular.groebner_strategy import GroebnerStrategy sage: P. = PolynomialRing(GF(32003)) sage: I = Ideal([x + z, y + z]) sage: strat = GroebnerStrategy(I) sage: strat.ring() Multivariate Polynomial Ring in x, y, z over Finite Field of size 32003 sage: from sage.libs.singular.groebner_strategy import NCGroebnerStrategy sage: A. = FreeAlgebra(QQ, 3) sage: H. = A.g_algebra({y*x:x*y-z, z*x:x*z+2*x, z*y:y*z-2*y}) sage: I = H.ideal([y^2, x^2, z^2-H.one_element()]) sage: strat = NCGroebnerStrategy(I) sage: strat.ring() is H True """ return self._parent """ EXAMPLE:: sage: from sage.libs.singular.groebner_strategy import GroebnerStrategy sage: P. = PolynomialRing(GF(19)) sage: I = Ideal([P(0)]) sage: strat = GroebnerStrategy(I) sage: strat == GroebnerStrategy(I) sage: from sage.libs.singular.groebner_strategy import NCGroebnerStrategy sage: A. = FreeAlgebra(QQ, 3) sage: H. = A.g_algebra({y*x:x*y-z, z*x:x*z+2*x, z*y:y*z-2*y}) sage: I = H.ideal([y^2, x^2, z^2-H.one_element()]) sage: strat = NCGroebnerStrategy(I) sage: strat == NCGroebnerStrategy(I) True sage: I = Ideal([x+1,y+z]) sage: strat == GroebnerStrategy(I) sage: I = H.ideal([y^2, x^2, z^2-H.one_element()], side='twosided') sage: strat == NCGroebnerStrategy(I) False """ if not isinstance(other, NCGroebnerStrategy): return cmp(type(self),other(type)) else: return cmp(self._ideal.gens(),(other)._ideal.gens()) return cmp((self._ideal.gens(),self._ideal.side()), ((other)._ideal.gens(), (other)._ideal.side())) def __reduce__(self): """ EXAMPLE:: sage: from sage.libs.singular.groebner_strategy import GroebnerStrategy sage: P. = PolynomialRing(GF(32003)) sage: I = Ideal([x + z, y + z]) sage: strat = GroebnerStrategy(I) sage: from sage.libs.singular.groebner_strategy import NCGroebnerStrategy sage: A. = FreeAlgebra(QQ, 3) sage: H. = A.g_algebra({y*x:x*y-z, z*x:x*z+2*x, z*y:y*z-2*y}) sage: I = H.ideal([y^2, x^2, z^2-H.one_element()]) sage: strat = NCGroebnerStrategy(I) sage: loads(dumps(strat)) == strat True """ EXAMPLE:: sage: from sage.libs.singular.groebner_strategy import GroebnerStrategy sage: P. = PolynomialRing(QQ) sage: I = Ideal([x + z, y + z]) sage: strat = GroebnerStrategy(I) sage: strat.normal_form(x*y) # indirect doctest z^2 sage: strat.normal_form(x + 1) -z + 1 sage: A. = FreeAlgebra(QQ, 3) sage: H. = A.g_algebra({y*x:x*y-z, z*x:x*z+2*x, z*y:y*z-2*y}) sage: JL = H.ideal([x^3, y^3, z^3 - 4*z]) sage: JT = H.ideal([x^3, y^3, z^3 - 4*z], side='twosided') sage: from sage.libs.singular.groebner_strategy import NCGroebnerStrategy sage: SL = NCGroebnerStrategy(JL.std()) sage: ST = NCGroebnerStrategy(JT.std()) sage: SL.normal_form(x*y^2) x*y^2 sage: ST.normal_form(x*y^2) y*z TESTS:: sage: from sage.libs.singular.groebner_strategy import GroebnerStrategy sage: P. = PolynomialRing(QQ) sage: I = Ideal([P(0)]) sage: strat = GroebnerStrategy(I) sage: strat.normal_form(x) x sage: strat.normal_form(P(0)) 0 """ if unlikely(p._parent is not self._parent): raise TypeError("parent(p) must be the same as this object's parent.") """ EXAMPLE:: sage: from sage.libs.singular.groebner_strategy import GroebnerStrategy sage: P. = PolynomialRing(GF(32003)) sage: I = Ideal([x + z, y + z]) sage: strat = GroebnerStrategy(I) sage: loads(dumps(strat)) == strat # indirect doctest sage: from sage.libs.singular.groebner_strategy import NCGroebnerStrategy sage: A. = FreeAlgebra(QQ, 3) sage: H. = A.g_algebra({y*x:x*y-z, z*x:x*z+2*x, z*y:y*z-2*y}) sage: I = H.ideal([y^2, x^2, z^2-H.one_element()]) sage: strat = NCGroebnerStrategy(I) sage: loads(dumps(strat)) == strat   # indirect doctest True """ return NCGroebnerStrategy(I)
• ## sage/rings/ideal_monoid.py

`diff --git a/sage/rings/ideal_monoid.py b/sage/rings/ideal_monoid.py`
 a sage: R. = QuadraticField(-23) sage: M = sage.rings.ideal_monoid.IdealMonoid(R) sage: M(a) sage: M(a)   # indirect doctest Fractional ideal (a) sage: M([a-4, 13]) Fractional ideal (13, 1/2*a + 9/2) """ #print x, type(x) if isinstance(x, ideal.Ideal_generic): try: side = x.side() except (AttributeError,TypeError): side = None try: x = x.gens() y = self.__R.ideal(x) except AttributeError: pass if side is None: y = self.__R.ideal(x) else: y = self.__R.ideal(x,side=side) y._set_parent(self) return y
• ## sage/rings/polynomial/multi_polynomial_ideal.py

`diff --git a/sage/rings/polynomial/multi_polynomial_ideal.py b/sage/rings/polynomial/multi_polynomial_ideal.py`
 a Apparently, ``x*y^2-y*z`` should be in the two-sided, but not in the left ideal:: sage: x*y^2-y*z in JL sage: x*y^2-y*z in JL   #indirect doctest False sage: x*y^2-y*z in JT True
• ## sage/rings/polynomial/plural.pxd

`diff --git a/sage/rings/polynomial/plural.pxd b/sage/rings/polynomial/plural.pxd`
 a #    cdef NCPolynomial_plural _one_element #    cdef NCPolynomial_plural _zero_element cdef public object _relations cdef public object _relations,_relations_commutative pass cdef class ExteriorAlgebra_plural(NCPolynomialRing_plural):
• ## sage/rings/polynomial/plural.pyx

`diff --git a/sage/rings/polynomial/plural.pyx b/sage/rings/polynomial/plural.pyx`