diff --git a/lmfdb/siegel_modular_forms/sample.py b/lmfdb/siegel_modular_forms/sample.py index 7fc07a63ef..5a7ad45738 100644 --- a/lmfdb/siegel_modular_forms/sample.py +++ b/lmfdb/siegel_modular_forms/sample.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# This file provides the class Sammple_Class which describes -# a sample of a collection of Sıegel modular forms. +# This file provides the class Sample_Class which describes +# a sample of a collection of Siegel modular forms. # # Author: Nils Skoruppa @@ -9,10 +9,12 @@ from ast import literal_eval from lmfdb import db + def random_sample_name(): data = db.smf_samples.random(projection=['collection', 'name']) return (data['collection'][0], data['name']) + class Sample_class (SageObject): """ A wrapper around a database entry providing various @@ -24,10 +26,10 @@ def __init__(self, doc): self.__name = doc.get('name') self.__weight = doc.get('weight') self.__degree_of_field = doc.get('fdeg') - self.__field_poly = PolynomialRing(QQ,'x')(str(doc.get('field_poly'))) - self.__field = None # created on demand - self.__explicit_formula = None # create on demand - self.__explicit_formula_set = False # set to true once we try to get it to avoid repeatedly trying to fetch an explicit formula that is not there + self.__field_poly = PolynomialRing(QQ, 'x')(str(doc.get('field_poly'))) + self.__field = None # created on demand + self.__explicit_formula = None # create on demand + self.__explicit_formula_set = False # set to true once we try to get it to avoid repeatedly trying to fetch an explicit formula that is not there self.__type = doc.get('type') self.__is_eigenform = doc.get('is_eigenform') self.__is_integral = doc.get('is_integral') @@ -54,13 +56,13 @@ def field_poly(self): def field(self): if not self.__field: - f = PolynomialRing(ZZ,name='x')(str(self.__field_poly)) - self.__field = QQ if f.degree() == 1 else NumberField(f,'a') + f = PolynomialRing(ZZ, name='x')(str(self.__field_poly)) + self.__field = QQ if f.degree() == 1 else NumberField(f, 'a') return self.__field def explicit_formula(self): if not self.__explicit_formula_set: - self.__explicit_formula = db.smf_samples.lucky({'id_link':self.__id}, 'explicit_formula') + self.__explicit_formula = db.smf_samples.lucky({'id_link': self.__id}, 'explicit_formula') self.__explicit_formula_set = True return self.__explicit_formula @@ -97,7 +99,9 @@ def Fourier_coefficients(self, det_list): query = {'owner_id': self.__id, 'det': {'$in': det_list}} fcs = db.smf_fc.search(query, ['det', 'data']) P = PolynomialRing(self.__field, names='x,y') - return {fcd['det']: {tuple(literal_eval(f)): P(str(poly)) for f, poly in fcd['data'].items() } for fcd in fcs} + return {fcd['det']: {tuple(literal_eval(f)): P(str(poly)) + for f, poly in fcd['data'].items()} + for fcd in fcs} def Sample(collection, name): @@ -113,8 +117,10 @@ def Samples(query): """ Return a result of a database query as list of light instances of Sample_class. """ - docs = db.smf_samples.search(query, {'Fourier_coefficients': False, 'eigenvalues': False, 'explicit_formula': False }) - return [ Sample_class(doc) for doc in docs] + docs = db.smf_samples.search(query, {'Fourier_coefficients': False, + 'eigenvalues': False, + 'explicit_formula': False}) + return [Sample_class(doc) for doc in docs] def export(collection, name): @@ -135,7 +141,7 @@ def export(collection, name): doc['eigenvalues'] = {ev['index']: ev['data'] for ev in evs} label = doc['collection'][0] + '.' + doc['name'] - doc['label']= label + doc['label'] = label import json return json.dumps(doc, sort_keys=True, indent=4)