-
-
Save jwbober/d4818253a908cde68cb2d46ec0fd76a4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from sage.all import loads, PolynomialRing, ZZ | |
outfile = open(sys.argv[1], 'w') | |
error_outfile = open(sys.argv[2], 'w') | |
from lmfdb import base | |
from lmfdb.modular_forms.elliptic_modular_forms import WebNewForm | |
F = WebNewForm('1.12.1.a') | |
c = F._collection | |
fc = F._file_collection | |
files = F._files | |
total = c.count() - 1776 | |
#res = {} | |
R = PolynomialRing(ZZ, 'q') | |
q = R.gen() | |
for x in c.find({'is_rational':1}): | |
label = x['hecke_orbit_label'] | |
f = x['q_expansion'] # this is a string that ends with '+ O(something)' | |
try: | |
g = f[:f.rfind('+')] # so we strip this from it | |
g = R(str(g)) | |
outfile.write('{} ; {}\n'.format(label, g.coefficients(sparse=False)[1:])) | |
print label | |
except: | |
error_outfile.write('{} ; {}\n'.format(label, f)) | |
print 'error:', label | |
print 'trying nonrational ones' | |
count = 0 | |
for x in c.find({'is_rational':0}): | |
count = count + 1 | |
mflabel = x['hecke_orbit_label'] | |
print '{}: {}/{}'.format(mflabel, count, total) | |
try: | |
fid = fc.find_one({'hecke_orbit_label':x['hecke_orbit_label']})['_id'] | |
d = loads(files.get(fid).read()) | |
embeddings = d['_embeddings']['values'] | |
#print embeddings | |
dimension = len(embeddings[1]) | |
prec = d['_embeddings']['prec'] | |
L = [ [] for _ in range(dimension)] | |
for x in range(1, prec): | |
for d in range(dimension): | |
L[d].append(embeddings[x][d]) | |
for d in range(dimension): | |
outfile.write('{}.{} ; {}\n'.format(mflabel, d, L[d])) | |
outfile.flush | |
except Exception as e: | |
error_outfile.write('{} ; {}\n'.format(mflabel, str(e))) | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment