# 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
|
|
52 | 52 | |
53 | 53 | import sage.schemes.elliptic_curves.constructor as elliptic |
54 | 54 | from sql_db import SQLDatabase, verify_column |
55 | | from sage.misc.package import optional_packages |
| 55 | from sage.misc.package import is_package_installed |
56 | 56 | from sage.misc.misc import SAGE_SHARE, walltime |
57 | 57 | |
58 | 58 | import re |
… |
… |
|
114 | 114 | |
115 | 115 | sage: d = sage.databases.cremona.build('cremona','ecdata.tgz') # not tested |
116 | 116 | """ |
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') |
121 | 121 | if not os.path.exists(data_tgz): |
122 | 122 | raise IOError, "The data file is not at %s"%data_tgz |
123 | 123 | t = walltime() |
… |
… |
|
584 | 584 | sage: c.name |
585 | 585 | 'cremona mini' |
586 | 586 | """ |
| 587 | self.name = name |
| 588 | name = name.replace(' ','_') |
| 589 | db_path = os.path.join(SAGE_SHARE, 'cremona', name+'.db') |
587 | 590 | if build: |
588 | 591 | if name is None: |
589 | 592 | raise RuntimeError('The database must have a name.') |
590 | 593 | if read_only: |
591 | 594 | 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) |
596 | 597 | 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) |
601 | 602 | if self.get_skeleton() != _miniCremonaSkeleton: |
602 | 603 | raise RuntimeError('Database at %s does '%(self.__dblocation__) \ |
603 | 604 | + 'not appear to be a valid SQL Cremona database.') |
… |
… |
|
854 | 855 | if N < self.largest_conductor(): |
855 | 856 | message = "There is no elliptic curve with label " + label \ |
856 | 857 | + " 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'): |
859 | 859 | message = "There is no elliptic curve with label " + label \ |
860 | 860 | + " in the currently available databases" |
861 | 861 | else: |
… |
… |
|
1306 | 1306 | sage: c.name # optional - database_cremona_ellcurve |
1307 | 1307 | 'cremona' |
1308 | 1308 | """ |
| 1309 | self.name = name |
| 1310 | name = name.replace(' ','_') |
| 1311 | db_path = os.path.join(SAGE_SHARE, 'cremona', name+'.db') |
1309 | 1312 | if build: |
1310 | 1313 | if name is None: |
1311 | 1314 | raise RuntimeError('The database must have a name.') |
1312 | 1315 | if read_only: |
1313 | 1316 | 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) |
1318 | 1319 | 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) |
1323 | 1324 | if self.get_skeleton() != _cremonaSkeleton: |
1324 | 1325 | raise RuntimeError('Database at %s does '%(self.__dblocation__) \ |
1325 | 1326 | + 'not appear to be a valid SQL Cremona database.') |
… |
… |
|
1542 | 1543 | True |
1543 | 1544 | sage: isinstance(c, sage.databases.cremona.LargeCremonaDatabase) # optional - database_cremona_ellcurve |
1544 | 1545 | 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 |
1545 | 1560 | """ |
1546 | 1561 | global _db |
1547 | 1562 | if set_global is None: |
… |
… |
|
1549 | 1564 | if name is None and not set_global: |
1550 | 1565 | return _db |
1551 | 1566 | 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'): |
1553 | 1568 | name = 'cremona' |
1554 | | elif os.path.isfile('%s/cremona/cremona_mini.db'%SAGE_SHARE): |
| 1569 | else: |
1555 | 1570 | name = 'cremona mini' |
1556 | | else: |
1557 | | raise RuntimeError('Could not find valid cremona database. ' \ |
1558 | | + 'Please make sure SAGE_SHARE is set correctly.') |
1559 | 1571 | if name == 'cremona': |
1560 | 1572 | mini = False |
1561 | 1573 | elif name == 'cremona mini': |
diff --git a/sage/schemes/elliptic_curves/ell_curve_isogeny.py b/sage/schemes/elliptic_curves/ell_curve_isogeny.py
a
|
b
|
|
528 | 528 | x |
529 | 529 | sage: phi.rational_maps() |
530 | 530 | ((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 |
532 | 532 | True |
533 | 533 | |
534 | 534 | A more complicated example of a characteristic 2 field:: |
diff --git a/sage/schemes/elliptic_curves/ell_torsion.py b/sage/schemes/elliptic_curves/ell_torsion.py
a
|
b
|
|
155 | 155 | sage: type(T) |
156 | 156 | <class 'sage.schemes.elliptic_curves.ell_torsion.EllipticCurveTorsionSubgroup_with_category'> |
157 | 157 | |
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 |
159 | 159 | True |
160 | 160 | |
161 | 161 | """ |
diff --git a/sage/schemes/elliptic_curves/lseries_ell.py b/sage/schemes/elliptic_curves/lseries_ell.py
a
|
b
|
|
161 | 161 | |
162 | 162 | EXAMPLES: |
163 | 163 | 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 |
166 | 166 | '2.492262044273650E+00' |
167 | | sage: RR(a) # optional |
| 167 | sage: RR(a) # not tested |
168 | 168 | 2.49226204427365 |
169 | 169 | """ |
170 | 170 | from sage.lfunctions.sympow import sympow |
… |
… |
|
190 | 190 | |
191 | 191 | EXAMPLES: |
192 | 192 | 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')" |
194 | 194 | sympow 1.018 RELEASE (c) Mark Watkins --- see README and COPYING for details |
195 | 195 | Minimal model of curve is [0,0,1,-1,0] |
196 | 196 | At 37: Inertia Group is C1 MULTIPLICATIVE REDUCTION |
diff --git a/sage/schemes/elliptic_curves/padic_lseries.py b/sage/schemes/elliptic_curves/padic_lseries.py
a
|
b
|
|
839 | 839 | sage: lp = E.padic_lseries(3) |
840 | 840 | sage: lp.series(2,quadratic_twist=-19) |
841 | 841 | 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 |
843 | 843 | '15523a1' |
844 | 844 | |
845 | 845 | This proves that the rank of '15523a1' is zero, even if ``mwrank`` can not determine this. |