Ticket #14958: trac_14958-rename-doctests.patch

File trac_14958-rename-doctests.patch, 14.2 KB (added by jpflori, 8 years ago)
  • doc/en/reference/finite_rings/index.rst

    # HG changeset patch
    # User Jean-Pierre Flori <jean-pierre.flori@ssi.gouv.fr>
    # Date 1375192848 -7200
    # Node ID eb86b775d2d622b5a135547c7d1a8db6c72552f8
    # Parent  01bf45cb42b39d1c6661ce752a4550bb8e748743
    Class renaming and doctests fixes
    
    diff --git a/doc/en/reference/finite_rings/index.rst b/doc/en/reference/finite_rings/index.rst
    a b  
    44.. toctree::
    55   :maxdepth: 2
    66
     7   sage/rings/finite_rings/conway_polynomials
    78   sage/rings/finite_rings/element_givaro
    89   sage/rings/finite_rings/element_ntl_gf2e
    910   sage/rings/finite_rings/element_pari_ffelt
  • sage/rings/finite_rings/conway_polynomials.py

    diff --git a/sage/rings/finite_rings/conway_polynomials.py b/sage/rings/finite_rings/conway_polynomials.py
    a b  
    4040    See also the ``ConwayPolynomials()`` object, which is a table of
    4141    Conway polynomials.
    4242
    43     For example, if ``c = ConwayPolynomials()``, then ``c.primes()``
     43    For example, if ``c == ConwayPolynomials()``, then ``c.primes()``
    4444    is a list of all primes for which the polynomials are known, and
    4545    for a given prime `p`, ``c.degree(p)`` is a list of all degrees
    4646    for which the Conway polynomials are known.
     
    8484    """
    8585    return sage.databases.conway.ConwayPolynomials().has_polynomial(p,n)
    8686
    87 pseudo_conway_poly = {}
     87pseudo_conway_lattice_cache = {}
    8888
    89 class PseudoConwayPolyTree(SageObject):
     89class PseudoConwayLattice(SageObject):
    9090    """
    9191    An object holding references to pseudo-Conway polynomials for
    9292    divisors of the given degree, so that they aren't garbage
    9393    collected.
     94
     95    INPUT:
     96
     97    - ``p`` -- The prime for which this defines an extension of
     98      ``GF(p)``.
     99
     100    - ``n`` -- The degree of the extension.
     101
     102    - ``nodes_dict`` -- dict or bool:
     103
     104      - either a dictionary of ``PseudoConwayLattice`` objects,
     105        indexed by prime divisors of `n`.  The entry for `q`
     106        corresponds to the pseudo-Conway extension of degree
     107        `n/q`.
     108
     109      - or a boolean:
     110
     111          - If ``True``, then this polynomial is actually in the Conway
     112            polynomials database, and no references to other PCLs are
     113            stored.
     114          - If ``False``, then `n == 1` and no references are stored
     115            (since there is no compatibility condition).
     116
     117    - ``f`` -- The polynomial defining this extension.
     118
     119    EXAMPLES::
     120
     121        sage: from sage.rings.finite_rings.conway_polynomials import find_pseudo_conway_lattice
     122        sage: PCL = find_pseudo_conway_lattice(2, 6, False)
     123        sage: PCL.get_pseudo_conway_polynomial(3)
     124        x^3 + x + 1
    94125    """
     126
    95127    def __init__(self, p, n, nodes_dict, f):
    96128        """
    97         INPUT::
    98 
    99         - ``p`` -- The prime for which this defines an extension of
    100           ``GF(p)``.
    101 
    102         - ``n`` -- The degree of the extension.
    103 
    104         - ``nodes_dict`` -- dict or bool:
    105 
    106           - either a dictionary of ``PseudoConwayPolyTree`` objects,
    107             indexed by prime divisors of `n`.  The entry for `q`
    108             corresponds to the pseudo-Conway extension of degree
    109             `n/q`.
    110 
    111           - or a boolean.  If True, then this polynomial is actually
    112             in the Conway polynomials database, and no references to
    113             other PCPTs are stored.  If False, then `n` is prime and
    114             no references are stored (since there is no compatibility
    115             condition).
    116 
    117         - ``f`` -- The polynomial defining this extension.
     129        See ``PseudoConwayLattice`` for full documentation.
    118130
    119131        EXAMPLES::
    120132
    121             sage: from sage.rings.finite_rings.conway_polynomials import find_pseudo_conway_polynomial_tree
    122             sage: PCPT = find_pseudo_conway_polynomial_tree(2, 6, False)
    123             sage: PCPT.get_pseudo_conway_poly(3)
    124             x^3 + x + 1
    125 
     133            sage: from sage.rings.finite_rings.conway_polynomials import find_pseudo_conway_lattice
     134            sage: PCL = find_pseudo_conway_lattice(3, 9, False)
     135            sage: PCL.get_pseudo_conway_polynomial(3)
     136            x^3 + 2*x^2 + x + 1
    126137        """
    127138        self.p = p
    128139        self.n = n
    129140        self.nodes_dict = nodes_dict
    130141        self.f = f
    131142
    132     def get_pseudo_conway_poly(self, m):
     143    def get_pseudo_conway_polynomial(self, m):
    133144        """
    134145        Return the pseudo-Conway polynomial associated to a divisor
    135         of the degree of this tree.
     146        of the degree of this lattice.
    136147
    137148        EXAMPLES::
    138149
    139             sage: from sage.rings.finite_rings.conway_polynomials import find_pseudo_conway_polynomial_tree
    140             sage: PCPT = find_pseudo_conway_polynomial_tree(2, 6, False)
    141             sage: PCPT.get_pseudo_conway_poly(3)
     150            sage: from sage.rings.finite_rings.conway_polynomials import find_pseudo_conway_lattice
     151            sage: PCL = find_pseudo_conway_lattice(2, 6, False)
     152            sage: PCL.get_pseudo_conway_polynomial(3)
    142153            x^3 + x + 1
    143             sage: PCPT.get_pseudo_conway_poly(4)
     154            sage: PCL.get_pseudo_conway_polynomial(4)
    144155            Traceback (most recent call last):
    145156            ...
    146157            RuntimeError: 4 does not divide 6
     
    151162        if not m.divides(self.n):
    152163            raise RuntimeError, "%s does not divide %s"%(m, self.n)
    153164        try:
    154             return pseudo_conway_poly[self.p][m]().f
     165            return pseudo_conway_lattice_cache[self.p][m]().f
    155166        except (KeyError, AttributeError):
    156167            return conway_polynomial(self.p, m)
    157168
    158169    def check_consistency(self):
    159170        """
    160171        Checks that the pseudo-Conway polynomials dividing the degree
    161         of this tree satisfy the required compatibility conditions.
     172        of this lattice satisfy the required compatibility conditions.
    162173
    163174        EXAMPLES::
    164175
    165             sage: from sage.rings.finite_rings.conway_polynomials import find_pseudo_conway_polynomial_tree
    166             sage: PCPT = find_pseudo_conway_polynomial_tree(2, 6, False)
    167             sage: PCPT.check_consistency()
    168             sage: PCPT = find_pseudo_conway_polynomial_tree(2, 60, False) # long
    169             sage: PCPT.check_consistency() # long
     176            sage: from sage.rings.finite_rings.conway_polynomials import find_pseudo_conway_lattice
     177            sage: PCL = find_pseudo_conway_lattice(2, 6, False)
     178            sage: PCL.check_consistency()
     179            sage: PCL = find_pseudo_conway_lattice(2, 60, False) # long
     180            sage: PCL.check_consistency() # long
    170181
    171182        """
    172183        p, n = self.p, self.n
    173184        K = FiniteField(p**n, modulus = self.f, names='a')
    174185        a = K.gen()
    175186        for m in n.divisors():
    176             assert (a**((p**n-1)//(p**m-1))).minimal_polynomial() == self.get_pseudo_conway_poly(m)
     187            assert (a**((p**n-1)//(p**m-1))).minimal_polynomial() == self.get_pseudo_conway_polynomial(m)
    177188
    178 def find_pseudo_conway_polynomial_tree(p, n, use_database=True):
     189def find_pseudo_conway_lattice(p, n, use_database=True):
    179190    r"""
    180191    Return an object holding references to a set of consistent
    181192    pseudo-Conway polynomials for degrees dividing `n`.
     
    201212
    202213    INPUT:
    203214
    204     - `p` -- prime number
     215    - ``p`` -- prime number
    205216
    206     - `n` -- integer greater than 1
     217    - ``n`` -- integer greater than 1
    207218
    208     - `use_database` -- whether to use the Conway polynomials database
     219    - ``use_database`` -- whether to use the Conway polynomials database
    209220      if the Conway polynomial for `p, n` exists within it (versus
    210221      computing a pseudo-Conway polynomial)
    211222
    212223    EXAMPLES::
    213224
    214         sage: from sage.rings.finite_rings.conway_polynomials import find_pseudo_conway_polynomial_tree
    215         sage: PCPT = find_pseudo_conway_polynomial_tree(2, 12, False)
    216         sage: PCPT.f
     225        sage: from sage.rings.finite_rings.conway_polynomials import find_pseudo_conway_lattice
     226        sage: PCL = find_pseudo_conway_lattice(2, 12, False)
     227        sage: PCL.f
    217228        x^12 + x^11 + x^9 + x^5 + x^3 + x + 1
    218         sage: PCPT = find_pseudo_conway_polynomial_tree(5, 6, False)
    219         sage: PCPT.f
     229        sage: PCL = find_pseudo_conway_lattice(5, 6, False)
     230        sage: PCL.f
    220231        x^6 + x^5 + 4*x^4 + 3*x^3 + 3*x^2 + 2*x + 2
    221         sage: PCPT = find_pseudo_conway_polynomial_tree(5, 11, False)
    222         sage: PCPT.f
     232        sage: PCL = find_pseudo_conway_lattice(5, 11, False)
     233        sage: PCL.f
    223234        x^11 + x^6 + 3*x^3 + 4*x + 3
    224235    """
    225     if not pseudo_conway_poly.has_key(p):
    226         pseudo_conway_poly[p] = {}
    227     pdict = pseudo_conway_poly[p]
     236    if not pseudo_conway_lattice_cache.has_key(p):
     237        pseudo_conway_lattice_cache[p] = {}
     238    pdict = pseudo_conway_lattice_cache[p]
    228239    n = sage.rings.integer.Integer(n)
    229240    if pdict.has_key(n):
    230241        pcp = pdict[n]()
    231242        if pcp is not None:
    232243            return pcp
    233244    if use_database and exists_conway_polynomial(p, n):
    234         ans = PseudoConwayPolyTree(p, n, True, FiniteField(p)['x'](conway_polynomial(p, n)))
     245        ans = PseudoConwayLattice(p, n, True, FiniteField(p)['x'](conway_polynomial(p, n)))
    235246    elif n == 1:
    236         ans = PseudoConwayPolyTree(p, n, False, compute_pseudo_conway_polynomial(p, n, None))
     247        ans = PseudoConwayLattice(p, n, False, compute_pseudo_conway_polynomial(p, n, None))
    237248    else:
    238249        nodes = {}
    239250        for q in n.prime_factors():
    240             nodes[q] = find_pseudo_conway_polynomial_tree(p, n//q, use_database)
    241         ans = PseudoConwayPolyTree(p, n, nodes, compute_pseudo_conway_polynomial(p, n, nodes))
     251            nodes[q] = find_pseudo_conway_lattice(p, n//q, use_database)
     252        ans = PseudoConwayLattice(p, n, nodes, compute_pseudo_conway_polynomial(p, n, nodes))
    242253    pdict[n] = weakref.ref(ans)
    243254    return ans
    244255
     
    512523
    513524    INPUT:
    514525
    515     - `p` -- prime number
     526    - ``p`` -- prime number
    516527
    517     - `n` -- positive integer
     528    - ``n`` -- positive integer
    518529
    519     - ``nodes`` -- None (in the case that `n` is prime) or a
    520       dictionary of ``PseudoConwayPolyTree`` objects, indexed by prime
     530    - ``nodes`` -- None (in the case that `n == 1`) or a
     531      dictionary of ``PseudoConwayLattice`` objects, indexed by prime
    521532      divisors `q` of `n`, with entries corresponding to pseudo-Conway
    522533      polynomials of degree `n/q`.
    523534
     
    541552
    542553    EXAMPLES::
    543554
    544         sage: from sage.rings.finite_rings.conway_polynomials import compute_pseudo_conway_polynomial, find_pseudo_conway_polynomial_tree
    545         sage: PCPT30 = find_pseudo_conway_polynomial_tree(2, 30, False)
    546         sage: PCPT20 = find_pseudo_conway_polynomial_tree(2, 20, False)
    547         sage: PCPT12 = find_pseudo_conway_polynomial_tree(2, 12, False)
    548         sage: compute_pseudo_conway_polynomial(2, 60, {2:PCPT30, 3:PCPT20, 5:PCPT12})
     555        sage: from sage.rings.finite_rings.conway_polynomials import compute_pseudo_conway_polynomial, find_pseudo_conway_lattice
     556        sage: PCL30 = find_pseudo_conway_lattice(2, 30, False)
     557        sage: PCL20 = find_pseudo_conway_lattice(2, 20, False)
     558        sage: PCL12 = find_pseudo_conway_lattice(2, 12, False)
     559        sage: compute_pseudo_conway_polynomial(2, 60, {2:PCL30, 3:PCL20, 5:PCL12})
    549560        x^60 + x^59 + x^58 + x^55 + x^54 + x^53 + x^52 + x^51 + x^48 + x^46 + x^45 + x^42 + x^41 + x^39 + x^38 + x^37 + x^35 + x^32 + x^31 + x^30 + x^28 + x^24 + x^22 + x^21 + x^18 + x^17 + x^16 + x^15 + x^14 + x^10 + x^8 + x^7 + x^5 + x^3 + x^2 + x + 1
    550561    """
    551562    k = FiniteField(p)
  • sage/rings/polynomial/polynomial_ring.py

    diff --git a/sage/rings/polynomial/polynomial_ring.py b/sage/rings/polynomial/polynomial_ring.py
    a b  
    13581358    def __init__(self, base_ring, name="x", sparse=False, implementation=None,
    13591359            element_class=None):
    13601360        """
    1361         TESTS:
     1361        TESTS::
     1362
    13621363            sage: from sage.rings.polynomial.polynomial_ring import PolynomialRing_integral_domain as PRing
    13631364            sage: R = PRing(ZZ, 'x'); R
    13641365            Univariate Polynomial Ring in x over Integer Ring
     
    13911392   
    13921393    def _repr_(self):
    13931394        """
    1394         TESTS:
     1395        TESTS::
     1396
    13951397            sage: from sage.rings.polynomial.polynomial_ring import PolynomialRing_integral_domain as PRing
    13961398            sage: R = PRing(ZZ, 'x', implementation='NTL'); R
    13971399            Univariate Polynomial Ring in x over Integer Ring (using NTL)
     
    14061408                           ):
    14071409    def __init__(self, base_ring, name="x", sparse=False, element_class=None):
    14081410        """
    1409         TESTS:
     1411        TESTS::
     1412
    14101413            sage: from sage.rings.polynomial.polynomial_ring import PolynomialRing_field as PRing
    14111414            sage: R = PRing(QQ, 'x'); R
    14121415            Univariate Polynomial Ring in x over Rational Field
     
    21582161
    21592162        A monic irreducible polynomial of degree `n` in ``self``.
    21602163
     2164        .. WARNING::
     2165
     2166            Beware that if this method is called with ``algorithm == "pseudo-conway"``,
     2167            the lattice of pseudo-Conway polynomials used to build the
     2168            pseudo-Conway polynomial, which is only weakrefed, will be garbage
     2169            collected.
     2170            Therefore, it is more sensible to build this lattice first using
     2171            the
     2172            :func:`sage.rings.finite_rings.conway_polynomials.find_pseudo_conway_lattice`
     2173            function and extract the pseudo-Conway polynomial from the lattice.
     2174
    21612175        EXAMPLES::
    21622176
    21632177            sage: GF(5)['x'].irreducible_element(2)
     
    21782192        """
    21792193        from sage.libs.pari.all import pari
    21802194        from sage.rings.finite_rings.conway_polynomials import \
    2181             conway_polynomial, exists_conway_polynomial, find_pseudo_conway_polynomial_tree
     2195            conway_polynomial, exists_conway_polynomial, find_pseudo_conway_lattice
    21822196        from polynomial_gf2x import (GF2X_BuildIrred_list, GF2X_BuildSparseIrred_list,
    21832197                                     GF2X_BuildRandomIrred_list)
    21842198
     
    21992213        elif algorithm == "conway":
    22002214            return self(conway_polynomial(p, n))
    22012215        elif algorithm == "pseudo-conway":
    2202             pcpt = find_pseudo_conway_polynomial_tree(p, n)
    2203             return self(pcpt.f)
     2216            PCL = find_pseudo_conway_lattice(p, n)
     2217            return self(PCL.f)
    22042218        elif algorithm == "first_lexicographic":
    22052219            if p == 2:
    22062220                return self(GF2X_BuildIrred_list(n))