# Ticket #4539: trac4539_fix_docs_rel10903.2.patch

File trac4539_fix_docs_rel10903.2.patch, 44.8 KB (added by SimonKing, 2 years ago)

Fixing doc strings and doc tests , rel #10903

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

```# HG changeset patch
# User Simon King <simon.king@uni-jena.de>
# Date 1317313679 -7200
# Node ID 74468a92ee93debfea68ed88d680f7efbc83154a
#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: A. = FreeAlgebra(QQ) 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/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/modules/free_module.py

`diff --git a/sage/modules/free_module.py b/sage/modules/free_module.py`
 a [1 2] [3 4] .. todo:: Refactor modules such that it only counts what category the base ring belongs to, but not what is its Python class. .. todo:: Refactor modules such that it only counts what category the base ring belongs to, but not what is its Python class. """ def create_key(self, base_ring, rank, sparse=False, inner_product_matrix=None): return self.basis_matrix().block_sum(other.basis_matrix()).row_module(self.base_ring()) def coordinates(self, v, check=True): """ r""" Write `v` in terms of the basis for self. INPUT: return self.basis()[i] def gram_matrix(self): """ r""" Return the gram matrix associated to this free module, defined to be G = B\*A\*B.transpose(), where A is the inner product matrix be `G = B*A*B.transpose()`, where A is the inner product matrix (induced from the ambient space), and B the basis matrix. EXAMPLES::
• ## 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 [                                                              x^3*z^2 + 7*x^3*z + 12*x^3                 -x*y^2*z^2 + 9*x*y^2*z - 4*y*z^3 - 20*x*y^2 + 52*y*z^2 - 224*y*z + 320*y                                                                                 -6*x*z^2] [  x^2*y^2*z + 4*x^2*y^2 - 8*x*y*z^2 - 48*x*y*z + 12*z^3 - 64*x*y + 108*z^2 + 312*z + 288                                                                           -y^4*z + 4*y^4                                                                                        0] [                                                  2*x^3*y*z + 8*x^3*y + 9*x^2*z + 27*x^2                                   -2*x*y^3*z + 8*x*y^3 - 12*y^2*z^2 + 99*y^2*z - 195*y^2                                                                -36*x*y*z + 24*z^2 + 18*z] [                                                  2*x^3*y*z + 8*x^3*y + 9*x^2*z + 27*x^2                                   -2*x*y^3*z + 8*x*y^3 - 12*y^2*z^2 + 99*y^2*z - 195*y^2                                                                -36*x*y*z + 24*z^2 + 18*z] [                                                                           x^4*z + 4*x^4    -x^2*y^2*z + 4*x^2*y^2 - 4*x*y*z^2 + 32*x*y*z - 6*z^3 - 64*x*y + 66*z^2 - 240*z + 288                                                                                        0] [x^3*y^2*z + 4*x^3*y^2 + 18*x^2*y*z - 36*x*z^3 + 66*x^2*y - 432*x*z^2 - 1656*x*z - 2052*x                                      -x*y^4*z + 4*x*y^4 - 8*y^3*z^2 + 62*y^3*z - 114*y^3                                                                        48*y*z^2 - 36*y*z] sage: M*G (0, 0, 0, 0, 0, 0, 0, 0, 0, 0) (0, 0, 0, 0, 0, 0, 0, 0, 0) ALGORITHM: Uses Singular's syz command """
• ## 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`