Ticket #12335: 12335.patch

File 12335.patch, 15.7 KB (added by ddrake, 7 years ago)

for databases

  • sage/databases/jones.py

    # HG changeset patch
    # User Dan Drake <drake@kaist.edu>
    # Date 1337969507 -32400
    # Node ID 470fd6bd010509a8ccb383a0d022194b85fc4b93
    # Parent  5299aa8232d7acb68d37162f5bef2068c8a68d54
    fix optional doctest labels and whitespace in databases/ (ticket 12335)
    
    diff --git a/sage/databases/jones.py b/sage/databases/jones.py
    a b  
    1818List the degree and discriminant of all fields in the database that
    1919have ramification at most at 2::
    2020
    21     sage: [(k.degree(), k.disc()) for k in J.unramified_outside([2])]    # optional - jones_database
     21    sage: [(k.degree(), k.disc()) for k in J.unramified_outside([2])]    # optional - database_jones_numfield
    2222    [(1, 1), (2, -4), (2, -8), (2, 8), (4, 256), (4, 512), (4, -1024), (4, -2048), (4, 2048), (4, 2048), (4, 2048)]
    2323
    2424List the discriminants of the fields of degree exactly 2 unramified
    2525outside 2::
    2626
    27     sage: [k.disc() for k in J.unramified_outside([2],2)]                # optional - jones_database
     27    sage: [k.disc() for k in J.unramified_outside([2],2)]                # optional - database_jones_numfield
    2828    [-4, -8, 8]
    2929
    3030List the discriminants of cubic field in the database ramified
    3131exactly at 3 and 5::
    3232
    33     sage: [k.disc() for k in J.ramified_at([3,5],3)]                     # optional - jones_database
     33    sage: [k.disc() for k in J.ramified_at([3,5],3)]                     # optional - database_jones_numfield
    3434    [-135, -675, -6075, -6075]
    3535    sage: factor(6075)
    3636    3^5 * 5^2
     
    4141
    4242List all fields in the database ramified at 101::
    4343
    44     sage: J.ramified_at(101)                                             # optional - jones_database
     44    sage: J.ramified_at(101)                                             # optional - database_jones_numfield
    4545    [Number Field in a with defining polynomial x^2 - 101,
    4646     Number Field in a with defining polynomial x^4 - x^3 + 13*x^2 - 19*x + 361,
    4747     Number Field in a with defining polynomial x^5 + 2*x^4 + 7*x^3 + 4*x^2 + 11*x - 6,
     
    8080class JonesDatabase:
    8181    def __init__(self):
    8282        self.root = None
    83        
     83
    8484    def __repr__(self):
    8585        return "John Jones's table of number fields with bounded ramification and degree <= 6"
    86    
     86
    8787    def _load(self, path, filename):
    8888        print filename
    8989        i = 0
     
    104104            self.root[s].sort()
    105105        else:
    106106            self.root[s] = v
    107            
     107
    108108
    109109    def _init(self, path):
    110110        """
    111111        Create the database from scratch from the PARI files on John Jones's
    112112        web page, downloaded (e.g., via wget) to a local directory, which
    113113        is specified as path above.
    114        
     114
    115115        INPUT:
    116        
    117        
     116
     117
    118118        -  ``path`` - (default works on William Stein install.)
    119119           path must be the path to Jones's Number_Fields directory
    120120           http://hobbes.la.asu.edu/Number_Fields These files should have
    121121           been downloaded using wget.
    122        
    123        
     122
     123
    124124        EXAMPLE: This is how to create the database from scratch, assuming
    125125        that the number fields are in the default directory above: From a
    126126        cold start of Sage::
    127        
     127
    128128                sage: J = JonesDatabase()
    129129                sage: J._init()   # not tested
    130130                ...
    131                
     131
    132132        This takes about 5 seconds.
    133133        """
    134134        from sage.misc.misc import sage_makedirs
     
    155155        The fields are ordered by degree and discriminant.
    156156
    157157        INPUT:
    158        
    159        
     158
     159
    160160        -  ``S`` - list or set of primes, or a single prime
    161        
    162         -  ``d`` - None (default, in which case all fields of degree <= 6 are returned) 
     161
     162        -  ``d`` - None (default, in which case all fields of degree <= 6 are returned)
    163163           or a positive integer giving the degree of the number fields returned.
    164        
    165         -  ``var`` - the name used for the generator of the number fields (default 'a').   
    166        
     164
     165        -  ``var`` - the name used for the generator of the number fields (default 'a').
     166
    167167        EXAMPLES::
    168        
    169             sage: J = JonesDatabase()             # optional - jones_database
    170             sage: J.unramified_outside([101,109]) # optional - jones_database
     168
     169            sage: J = JonesDatabase()             # optional - database_jones_numfield
     170            sage: J.unramified_outside([101,109]) # optional - database_jones_numfield
    171171            [Number Field in a with defining polynomial x - 1,
    172172             Number Field in a with defining polynomial x^2 - 101,
    173173             Number Field in a with defining polynomial x^2 - 109,
     
    185185        Z = []
    186186        for X in powerset(S):
    187187            Z += self.ramified_at(X, d=d, var=var)
    188         Z = [(k.degree(), k.discriminant().abs(), k.discriminant() > 0, k) for k in Z] 
     188        Z = [(k.degree(), k.discriminant().abs(), k.discriminant() > 0, k) for k in Z]
    189189        Z.sort()
    190190        return [z[-1] for z in Z]
    191191
     
    195195    def get(self, S, var='a'):
    196196        """
    197197        Return all fields in the database ramified exactly at
    198         the primes in S. 
     198        the primes in S.
    199199
    200200        INPUT:
    201201
    202202        -  ``S`` - list or set of primes, or a single prime
    203        
    204         -  ``var`` - the name used for the generator of the number fields (default 'a').   
    205        
     203
     204        -  ``var`` - the name used for the generator of the number fields (default 'a').
     205
    206206        EXAMPLES::
    207        
    208             sage: J = JonesDatabase()              # optional - jones_database
    209             sage: J.get(163, var='z')              # optional - jones_database
     207
     208            sage: J = JonesDatabase()              # optional - database_jones_numfield
     209            sage: J.get(163, var='z')              # optional - database_jones_numfield
    210210            [Number Field in z with defining polynomial x^2 + 163,
    211211             Number Field in z with defining polynomial x^3 - x^2 - 54*x + 169,
    212212             Number Field in z with defining polynomial x^4 - x^3 - 7*x^2 + 2*x + 9]
    213             sage: J.get([3, 4])                    # optional - jones_database
     213            sage: J.get([3, 4])                    # optional - database_jones_numfield
    214214            Traceback (most recent call last):
    215215            ...
    216216            ValueError: S must be a list of primes
     
    240240        INPUT:
    241241
    242242        -  ``S`` - list or set of primes
    243        
    244         -  ``d`` - None (default, in which case all fields of degree <= 6 are returned) 
     243
     244        -  ``d`` - None (default, in which case all fields of degree <= 6 are returned)
    245245           or a positive integer giving the degree of the number fields returned.
    246        
    247         -  ``var`` - the name used for the generator of the number fields (default 'a').   
    248        
     246
     247        -  ``var`` - the name used for the generator of the number fields (default 'a').
     248
    249249        EXAMPLES::
    250        
    251             sage: J = JonesDatabase()              # optional - jones_database
    252             sage: J.ramified_at([101,109])         # optional - jones_database
     250
     251            sage: J = JonesDatabase()              # optional - database_jones_numfield
     252            sage: J.ramified_at([101,109])         # optional - database_jones_numfield
    253253            []
    254             sage: J.ramified_at([109])             # optional - jones_database
     254            sage: J.ramified_at([109])             # optional - database_jones_numfield
    255255            [Number Field in a with defining polynomial x^2 - 109,
    256256             Number Field in a with defining polynomial x^3 - x^2 - 36*x + 4,
    257257             Number Field in a with defining polynomial x^4 - x^3 + 14*x^2 + 34*x + 393]
    258             sage: J.ramified_at(101)               # optional - jones_database
     258            sage: J.ramified_at(101)               # optional - database_jones_numfield
    259259            [Number Field in a with defining polynomial x^2 - 101,
    260260             Number Field in a with defining polynomial x^4 - x^3 + 13*x^2 - 19*x + 361,
    261261             Number Field in a with defining polynomial x^5 + 2*x^4 + 7*x^3 + 4*x^2 + 11*x - 6,
    262262             Number Field in a with defining polynomial x^5 + x^4 - 6*x^3 - x^2 + 18*x + 4,
    263263             Number Field in a with defining polynomial x^5 - x^4 - 40*x^3 - 93*x^2 - 21*x + 17]
    264             sage: J.ramified_at((2, 5, 29), 3, 'c') # optional - jones_database
     264            sage: J.ramified_at((2, 5, 29), 3, 'c') # optional - database_jones_numfield
    265265            [Number Field in c with defining polynomial x^3 - x^2 - 8*x - 28,
    266266             Number Field in c with defining polynomial x^3 - x^2 + 10*x + 102,
    267267             Number Field in c with defining polynomial x^3 - x^2 + 97*x - 333,
     
    271271        if d == None:
    272272            Z = [(k.degree(), k.discriminant().abs(), k.discriminant() > 0, k) for k in Z]
    273273        else:
    274             Z = [(k.discriminant().abs(), k.discriminant() > 0, k) for k in Z if k.degree() == d] 
     274            Z = [(k.discriminant().abs(), k.discriminant() > 0, k) for k in Z if k.degree() == d]
    275275        Z.sort()
    276276        return [z[-1] for z in Z]
  • sage/databases/stein_watkins.py

    diff --git a/sage/databases/stein_watkins.py b/sage/databases/stein_watkins.py
    a b  
    4848We type ``d.next()`` to get each isogeny class of
    4949curves from ``d``::
    5050
    51     sage: C = d.next()                                   # optional - stein_watkins_database
    52     sage: C                                              # optional - stein_watkins_database
     51    sage: C = d.next()                                   # optional - database_stein_watkins
     52    sage: C                                              # optional - database_stein_watkins
    5353    Stein-Watkins isogeny class of conductor 11
    54     sage: d.next()                                       # optional - stein_watkins_database
     54    sage: d.next()                                       # optional - database_stein_watkins
    5555    Stein-Watkins isogeny class of conductor 14
    56     sage: d.next()                                       # optional - stein_watkins_database
     56    sage: d.next()                                       # optional - database_stein_watkins
    5757    Stein-Watkins isogeny class of conductor 15
    5858
    5959An isogeny class has a number of attributes that give data about
     
    6262
    6363::
    6464
    65     sage: C.data                                         # optional - stein_watkins_database
     65    sage: C.data                                         # optional - database_stein_watkins
    6666    ['11', '[11]', '0', '0.253842', '25', '+*1']
    67     sage: C.curves                                       # optional - stein_watkins_database
     67    sage: C.curves                                       # optional - database_stein_watkins
    6868    [[[0, -1, 1, 0, 0], '(1)', '1', '5'],
    6969     [[0, -1, 1, -10, -20], '(5)', '1', '5'],
    7070     [[0, -1, 1, -7820, -263580], '(1)', '1', '1']]
    71     sage: C.conductor                                    # optional - stein_watkins_database
     71    sage: C.conductor                                    # optional - database_stein_watkins
    7272    11
    73     sage: C.leading_coefficient                          # optional - stein_watkins_database
     73    sage: C.leading_coefficient                          # optional - database_stein_watkins
    7474    '0.253842'
    75     sage: C.modular_degree                               # optional - stein_watkins_database
     75    sage: C.modular_degree                               # optional - database_stein_watkins
    7676    '+*1'
    77     sage: C.rank                                         # optional - stein_watkins_database
     77    sage: C.rank                                         # optional - database_stein_watkins
    7878    0
    79     sage: C.isogeny_number                               # optional - stein_watkins_database
     79    sage: C.isogeny_number                               # optional - database_stein_watkins
    8080    '25'
    8181
    8282If we were to continue typing ``d.next()`` we would
     
    8787To access the data file starting at `10^5` do the
    8888following::
    8989
    90     sage: d = SteinWatkinsAllData(1)                    # optional - stein_watkins_database
    91     sage: C = d.next()                                  # optional - stein_watkins_database
    92     sage: C                                             # optional - stein_watkins_database
     90    sage: d = SteinWatkinsAllData(1)                    # optional - database_stein_watkins
     91    sage: C = d.next()                                  # optional - database_stein_watkins
     92    sage: C                                             # optional - database_stein_watkins
    9393    Stein-Watkins isogeny class of conductor 100002
    94     sage: C.curves                                      # optional - stein_watkins_database
     94    sage: C.curves                                      # optional - database_stein_watkins
    9595    [[[1, 1, 0, 112, 0], '(8,1,2,1)', 'X', '2'],
    9696     [[1, 1, 0, -448, -560], '[4,2,1,2]', 'X', '2']]
    9797
    9898Next we access the prime-conductor data::
    9999
    100     sage: d = SteinWatkinsPrimeData(0)                 # optional - stein_watkins_database
    101     sage: C = d.next()                                 # optional - stein_watkins_database
    102     sage: C                                            # optional - stein_watkins_database
     100    sage: d = SteinWatkinsPrimeData(0)                 # optional - database_stein_watkins
     101    sage: C = d.next()                                 # optional - database_stein_watkins
     102    sage: C                                            # optional - database_stein_watkins
    103103    Stein-Watkins isogeny class of conductor 11
    104104
    105105Each call ``d.next()`` gives another elliptic curve of
    106106prime conductor::
    107107
    108     sage: C = d.next()                                 # optional - stein_watkins_database
    109     sage: C                                            # optional - stein_watkins_database
     108    sage: C = d.next()                                 # optional - database_stein_watkins
     109    sage: C                                            # optional - database_stein_watkins
    110110    Stein-Watkins isogeny class of conductor 17
    111     sage: C.curves                                     # optional - stein_watkins_database
     111    sage: C.curves                                     # optional - database_stein_watkins
    112112    [[[1, -1, 1, -1, 0], '[1]', '1', '4'],
    113113     [[1, -1, 1, -6, -4], '[2]', '1', '2x'],
    114114     [[1, -1, 1, -1, -14], '(4)', '1', '4'],
    115115     [[1, -1, 1, -91, -310], '[1]', '1', '2']]
    116     sage: C = d.next()                                 # optional - stein_watkins_database
    117     sage: C                                            # optional - stein_watkins_database
     116    sage: C = d.next()                                 # optional - database_stein_watkins
     117    sage: C                                            # optional - database_stein_watkins
    118118    Stein-Watkins isogeny class of conductor 19
    119119"""
    120120
    121121#*****************************************************************************
    122 #       
     122#
    123123#       Sage: Copyright (C) 2005 William Stein <wstein@gmail.com>
    124124#
    125125#  Distributed under the terms of the GNU General Public License (GPL)
     
    141141class SteinWatkinsIsogenyClass:
    142142    def __init__(self, conductor):
    143143        self.conductor = conductor
    144        
     144
    145145    def __repr__(self):
    146146        return "Stein-Watkins isogeny class of conductor %s"%self.conductor
    147147
     
    164164        i = s.find("\n")
    165165        if i == -1:
    166166            yield ""
    167             return 
     167            return
    168168        line = s[:i]
    169169        s = s[i+1:]
    170170        yield line
    171171
    172        
     172
    173173class SteinWatkinsAllData:
    174174    """
    175175    Class for iterating through one of the Stein-Watkins database files
     
    218218        return self._iter.next()
    219219
    220220    def __getitem__(self, N):
    221         """ 
     221        """
    222222        Return the curves of conductor N in this table. (Very slow!)
    223223        Return all data about curves between the given levels in this
    224224        database file.