Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
241852 views
1
#################################################################################
2
#
3
# (c) Copyright 2011 William Stein
4
#
5
# This file is part of PSAGE
6
#
7
# PSAGE is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation, either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# PSAGE is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with this program. If not, see <http://www.gnu.org/licenses/>.
19
#
20
#################################################################################
21
22
23
def import_table(address, table_filename, max_level=None):
24
"""
25
Import a text table of weq's, using upsert to avoid
26
replication of data. Format is like this:
27
28
::
29
30
31 5*a-2 0 -3 2 -2 2 4 -4 4 -4 -2 -2 ? ? -6 -6 12 -4 6 -2 -8 0 0 16 10 -6 [1,a+1,a,a,0]
31
31 5*a-3 0 -3 2 -2 2 -4 4 -4 4 -2 -2 ? ? -6 -6 -4 12 -2 6 0 -8 16 0 -6 10 [1,-a-1,a,0,0]
32
36 6 0 ? ? -4 10 2 2 0 0 0 0 -8 -8 2 2 -10 -10 2 2 12 12 0 0 10 10 [a,a-1,a,-1,-a+1]
33
"""
34
from psage.modform.hilbert.sqrt5.sqrt5 import F
35
from sage.databases.cremona import cremona_letter_code
36
from aplists import labeled_primes_of_bounded_norm, str_to_apdict
37
labels, primes = labeled_primes_of_bounded_norm(F, 100)
38
39
from psage.lmfdb.auth import userpass
40
user, password = userpass()
41
42
from pymongo import Connection
43
C = Connection(address).research
44
if not C.authenticate(user, password):
45
raise RuntimeError, "failed to authenticate"
46
e = C.ellcurves_sqrt5
47
48
49
for X in open(table_filename).read().splitlines():
50
if X.startswith('#'):
51
continue
52
z = X.split()
53
Nlevel = z[0]; level = z[1]; iso_class = z[2]; weq = z[-1]
54
ap = ' '.join(z[3:-1])
55
ap = str_to_apdict(ap, labels)
56
Nlevel = int(Nlevel)
57
iso_class = cremona_letter_code(int(iso_class))
58
v = {'level':level, 'iso_class':iso_class,
59
'number':1, 'Nlevel':Nlevel, 'ap':ap,
60
'weq':weq}
61
if max_level and Nlevel > max_level: break
62
print v
63
spec = dict(v)
64
del spec['weq']
65
e.update(spec, v, upsert=True, safe=True)
66
67
68
69
70