Skip to content

Commit 681a8e4

Browse files
committed
database_ellcurves: access files through features, for simpler configuration
1 parent f83fabf commit 681a8e4

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

src/sage/features/databases.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,34 @@ def __init__(self, name="cremona"):
6565
description="Cremona's database of elliptic curves")
6666

6767

68+
class DatabaseEllcurves(StaticFile):
69+
r"""
70+
A :class:`~sage.features.Feature` which describes the presence of
71+
William Stein's database of interesting curves.
72+
73+
EXAMPLES::
74+
75+
sage: from sage.features.databases import DatabaseEllcurves
76+
sage: bool(DatabaseEllcurves().is_present()) # optional - database_ellcurves
77+
True
78+
"""
79+
def __init__(self):
80+
r"""
81+
TESTS::
82+
83+
sage: from sage.features.databases import DatabaseEllcurves
84+
sage: isinstance(DatabaseEllcurves(), DatabaseEllcurves)
85+
True
86+
"""
87+
from sage.env import ELLCURVE_DATA_DIR
88+
StaticFile.__init__(self, "database_ellcurves",
89+
filename='rank0',
90+
search_path=ELLCURVE_DATA_DIR,
91+
spkg="elliptic_curves",
92+
type="standard",
93+
description="William Stein's database of interesting curve")
94+
95+
6896
class DatabaseGraphs(StaticFile):
6997
r"""
7098
A :class:`~sage.features.Feature` which describes the presence of
@@ -211,6 +239,7 @@ def all_features():
211239
return [PythonModule('conway_polynomials'),
212240
DatabaseCremona(),
213241
DatabaseCremona('cremona_mini'),
242+
DatabaseEllcurves(),
214243
DatabaseGraphs(),
215244
DatabaseJones(),
216245
DatabaseKnotInfo(),

src/sage/schemes/elliptic_curves/ec_database.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,10 @@ def rank(self, rank, tors=0, n=10, labels=False):
132132
sage: elliptic_curves.rank(6, n=3, labels=True)
133133
[]
134134
"""
135-
from sage.env import ELLCURVE_DATA_DIR
136-
data = os.path.join(ELLCURVE_DATA_DIR, 'rank%s' % rank)
135+
from sage.features.databases import DatabaseEllcurves
136+
db = DatabaseEllcurves()
137+
data = os.path.join(os.path.dirname(db.absolute_filename()),
138+
f'rank{rank}')
137139
try:
138140
f = open(data)
139141
except OSError:

0 commit comments

Comments
 (0)