Path: blob/main/scripts/lattices/add_q_expansion_theta.py
1127 views
# -*- coding: utf-8 -*-1r""" Check presence if the first 150 coefficients of the q expansion of the theta series attached to an integral lattice are stored, and adds them otherwise.23Initial version: Samuele Anni45"""67import os8from sage.all import gp, matrix91011from pymongo.mongo_client import MongoClient12C= MongoClient(port=37010)13import yaml14pw_dict = yaml.load(open(os.path.join(os.getcwd(), "passwords.yaml")))15username = pw_dict['data']['username']16password = pw_dict['data']['password']17C['Lattices'].authenticate('editor', password)18lat = C.Lattices.lat192021def check_add_qexp(dim, min_det=1, max_det=None, fix=False):22query = {}23query['dim'] = int(dim)24query['det'] = {'$gte' : int(min_det)}25if max_det:26query['det']['$lte'] = int(max_det)27else:28max_det = "infinity"29lat_set = lat.find(query)30print("%s lattices to examine of dimension %s and determinant between %s and %s."31% (lat_set.count(), dim, min_det, max_det))32if lat_set.count() == 0:33return None34print("checking whether the q expansion is stored...")35for l in lat_set:36print("Testing lattice %s" % l['label'])37if l['theta_series'] == "":38print("q expansion NOT stored")39if fix:40M=l['gram']41exp=[int(i) for i in gp("Vec(1+2*'x*Ser(qfrep("+str(gp(matrix(M)))+",150,0)))")]42lat.update({'label': l['label']}, {"$set": {'theta_series': exp}}, upsert=True)43print("Fixed lattice %s" % l['label'])44else:45print("q expansion stored")46474849