Ticket #12341: trac_12341.patch

File trac_12341.patch, 9.4 KB (added by ohanar, 10 years ago)

re-rebased against 5.4.rc1

  • sage/databases/cremona.py

    # HG changeset patch
    # User R. Andrew Ohana <andrew.ohana@gmail.com>
    # Date 1327313504 28800
    # Node ID e75281e629cf428ece6ac50de98f6a2644fbd634
    # Parent  03f85b4cf054c4668b105eef752ab85fe08fba91
    Trac 12341: verifies the existence of a desired cremona database
    
    diff --git a/sage/databases/cremona.py b/sage/databases/cremona.py
    a b  
    5252
    5353import sage.schemes.elliptic_curves.constructor as elliptic
    5454from sql_db import SQLDatabase, verify_column
    55 from sage.misc.package import optional_packages
     55from sage.misc.package import is_package_installed
    5656from sage.misc.misc import SAGE_SHARE, walltime
    5757
    5858import re
     
    114114
    115115        sage: d = sage.databases.cremona.build('cremona','ecdata.tgz')   # not tested
    116116    """
    117     t = name.replace(' ','_')
    118     if os.path.exists("%s/cremona/%s.db"%(SAGE_SHARE, t)):
    119         raise RuntimeError("Please (re)move %s/cremona/%s.db"%(SAGE_SHARE, t)
    120         + " before rebuilding database.")
     117    db_path = os.path.join(SAGE_SHARE,'cremona',name.replace(' ','_')+'.db')
     118    if os.path.exists(db_path):
     119        raise RuntimeError('Please (re)move %s before building '%db_path \
     120                + 'database')
    121121    if not os.path.exists(data_tgz):
    122122        raise IOError, "The data file is not at %s"%data_tgz
    123123    t = walltime()
     
    584584            sage: c.name
    585585            'cremona mini'
    586586        """
     587        self.name = name
     588        name = name.replace(' ','_')
     589        db_path = os.path.join(SAGE_SHARE, 'cremona', name+'.db')
    587590        if build:
    588591            if name is None:
    589592                raise RuntimeError('The database must have a name.')
    590593            if read_only:
    591594                raise RuntimeError('The database must not be read_only.')
    592             self.name = name
    593             name = name.replace(' ','_')
    594             SQLDatabase.__init__(self, '%s/cremona/%s.db'%(SAGE_SHARE, name), \
    595                 read_only=read_only, skeleton=_miniCremonaSkeleton)
     595            SQLDatabase.__init__(self, db_path, read_only=read_only, \
     596                    skeleton=_miniCremonaSkeleton)
    596597            return
    597         self.name = name
    598         name = name.replace(' ','_')
    599         SQLDatabase.__init__(self, '%s/cremona/%s.db'%(SAGE_SHARE, name), \
    600             read_only=read_only)
     598        if not os.path.isfile(db_path):
     599            raise ValueError("Desired database (='%s') does not "%self.name \
     600                    + "exist")
     601        SQLDatabase.__init__(self, db_path, read_only=read_only)
    601602        if self.get_skeleton() != _miniCremonaSkeleton:
    602603            raise RuntimeError('Database at %s does '%(self.__dblocation__) \
    603604              + 'not appear to be a valid SQL Cremona database.')
     
    854855            if N < self.largest_conductor():
    855856                message = "There is no elliptic curve with label " + label \
    856857                    + " in the database (note: use lower case letters!)"
    857             elif 'database_cremona_ellcurve' in \
    858                     [s.split('-')[0] for s in optional_packages()[0]]:
     858            elif is_package_installed('database_cremona_ellcurve'):
    859859                message = "There is no elliptic curve with label " + label \
    860860                    + " in the currently available databases"
    861861            else:
     
    13061306            sage: c.name                                              # optional - database_cremona_ellcurve
    13071307            'cremona'
    13081308        """
     1309        self.name = name
     1310        name = name.replace(' ','_')
     1311        db_path = os.path.join(SAGE_SHARE, 'cremona', name+'.db')
    13091312        if build:
    13101313            if name is None:
    13111314                raise RuntimeError('The database must have a name.')
    13121315            if read_only:
    13131316                raise RuntimeError('The database must not be read_only.')
    1314             self.name = name
    1315             name = name.replace(' ','_')
    1316             SQLDatabase.__init__(self, '%s/cremona/%s.db'%(SAGE_SHARE, name), \
    1317                 read_only=read_only, skeleton=_cremonaSkeleton)
     1317            SQLDatabase.__init__(self, db_path, read_only=read_only, \
     1318                    skeleton=_cremonaSkeleton)
    13181319            return
    1319         self.name = name
    1320         name = name.replace(' ','_')
    1321         SQLDatabase.__init__(self, '%s/cremona/%s.db'%(SAGE_SHARE, name), \
    1322             read_only=read_only)
     1320        if not os.path.isfile(db_path):
     1321            raise ValueError("Desired database (='%s') does not "%self.name \
     1322                    + "exist")
     1323        SQLDatabase.__init__(self, db_path, read_only=read_only)
    13231324        if self.get_skeleton() != _cremonaSkeleton:
    13241325            raise RuntimeError('Database at %s does '%(self.__dblocation__) \
    13251326              + 'not appear to be a valid SQL Cremona database.')
     
    15421543        True
    15431544        sage: isinstance(c, sage.databases.cremona.LargeCremonaDatabase)  # optional - database_cremona_ellcurve
    15441545        True
     1546
     1547    Verify that ticket #12341 has been resolved::
     1548
     1549        sage: c = CremonaDatabase('should not exist',mini=True)
     1550        Traceback (most recent call last):
     1551        ...
     1552        ValueError: Desired database (='should not exist') does not exist
     1553        sage: c = CremonaDatabase('should not exist',mini=False)
     1554        Traceback (most recent call last):
     1555        ...
     1556        ValueError: Desired database (='should not exist') does not exist
     1557        sage: from sage.misc.misc import SAGE_SHARE
     1558        sage: os.path.isfile(os.path.join(SAGE_SHARE,'cremona','should_not_exist.db'))
     1559        False
    15451560    """
    15461561    global _db
    15471562    if set_global is None:
     
    15491564    if name is None and not set_global:
    15501565        return _db
    15511566    if set_global and name is None:
    1552         if os.path.isfile('%s/cremona/cremona.db'%SAGE_SHARE):
     1567        if is_package_installed('database_cremona_ellcurve'):
    15531568            name = 'cremona'
    1554         elif os.path.isfile('%s/cremona/cremona_mini.db'%SAGE_SHARE):
     1569        else:
    15551570            name = 'cremona mini'
    1556         else:
    1557             raise RuntimeError('Could not find valid cremona database. ' \
    1558                 + 'Please make sure SAGE_SHARE is set correctly.')
    15591571    if name == 'cremona':
    15601572        mini = False
    15611573    elif name == 'cremona mini':
  • sage/schemes/elliptic_curves/ell_curve_isogeny.py

    diff --git a/sage/schemes/elliptic_curves/ell_curve_isogeny.py b/sage/schemes/elliptic_curves/ell_curve_isogeny.py
    a b  
    528528        x
    529529        sage: phi.rational_maps()
    530530        ((x^2 + 1)/x, (x^2*y - y)/x^2)
    531         sage: phi == loads(dumps(phi))   # optional - pickling http://trac.sagemath.org/sage_trac/ticket/11599
     531        sage: phi == loads(dumps(phi))   # not tested - pickling http://trac.sagemath.org/sage_trac/ticket/11599
    532532        True
    533533
    534534    A more complicated example of a characteristic 2 field::
  • sage/schemes/elliptic_curves/ell_torsion.py

    diff --git a/sage/schemes/elliptic_curves/ell_torsion.py b/sage/schemes/elliptic_curves/ell_torsion.py
    a b  
    155155            sage: type(T)
    156156            <class 'sage.schemes.elliptic_curves.ell_torsion.EllipticCurveTorsionSubgroup_with_category'>
    157157
    158             sage: T == loads(dumps(T))  # optional - pickling http://trac.sagemath.org/sage_trac/ticket/11599
     158            sage: T == loads(dumps(T))  # not tested - pickling http://trac.sagemath.org/sage_trac/ticket/11599
    159159            True
    160160
    161161        """
  • sage/schemes/elliptic_curves/lseries_ell.py

    diff --git a/sage/schemes/elliptic_curves/lseries_ell.py b/sage/schemes/elliptic_curves/lseries_ell.py
    a b  
    161161
    162162        EXAMPLES:
    163163            sage: E = EllipticCurve('37a')
    164             sage: a = E.lseries().sympow(2,16)   # optional - requires precomputing "sympow('-new_data 2')"
    165             sage: a      # optional
     164            sage: a = E.lseries().sympow(2,16)   # not tested - requires precomputing "sympow('-new_data 2')"
     165            sage: a                              # not tested
    166166            '2.492262044273650E+00'
    167             sage: RR(a)                      # optional
     167            sage: RR(a)                          # not tested
    168168            2.49226204427365
    169169        """
    170170        from sage.lfunctions.sympow import sympow
     
    190190
    191191        EXAMPLES:
    192192            sage: E = EllipticCurve('37a')
    193             sage: print E.lseries().sympow_derivs(1,16,2)      # optional -- requires precomputing "sympow('-new_data 2')"
     193            sage: print E.lseries().sympow_derivs(1,16,2)      # not tested -- requires precomputing "sympow('-new_data 2')"
    194194            sympow 1.018 RELEASE  (c) Mark Watkins --- see README and COPYING for details
    195195            Minimal model of curve  is [0,0,1,-1,0]
    196196            At 37: Inertia Group is  C1 MULTIPLICATIVE REDUCTION
  • sage/schemes/elliptic_curves/padic_lseries.py

    diff --git a/sage/schemes/elliptic_curves/padic_lseries.py b/sage/schemes/elliptic_curves/padic_lseries.py
    a b  
    839839            sage: lp = E.padic_lseries(3)
    840840            sage: lp.series(2,quadratic_twist=-19)
    841841            2 + 2*3 + 2*3^2 + O(3^4) + (1 + O(3))*T + (1 + O(3))*T^2 + O(T^3)
    842             sage: E.quadratic_twist(-19).label()    #optional --- conductor is greater than 10000
     842            sage: E.quadratic_twist(-19).label()    # optional -- database_cremona_ellcurve
    843843            '15523a1'
    844844       
    845845        This proves that the rank of '15523a1' is zero, even if ``mwrank`` can not determine this.