From 56421123d69a61ee1609ee7c81026cdbb40bea66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Sat, 28 Sep 2024 17:52:18 +0200 Subject: [PATCH 1/9] fix pep E225 and E228 --- lmfdb/abvar/fq/download.py | 10 +- lmfdb/abvar/fq/main.py | 4 +- lmfdb/api/api.py | 4 +- lmfdb/api2/api2.py | 6 +- lmfdb/api2/utils.py | 2 +- lmfdb/artin_representations/main.py | 16 +- .../bianchi_modular_form.py | 24 +-- lmfdb/bianchi_modular_forms/web_BMF.py | 12 +- lmfdb/characters/HeckeCharacters.py | 4 +- lmfdb/characters/main.py | 4 +- lmfdb/characters/test_characters.py | 8 +- lmfdb/characters/utils.py | 2 +- lmfdb/characters/web_character.py | 38 ++--- .../classical_modular_forms/cmf_test_pages.py | 8 +- lmfdb/classical_modular_forms/download.py | 34 ++--- lmfdb/classical_modular_forms/main.py | 42 +++--- lmfdb/classical_modular_forms/test_cmf.py | 2 +- lmfdb/classical_modular_forms/web_newform.py | 58 ++++---- lmfdb/classical_modular_forms/web_space.py | 54 +++---- lmfdb/ecnf/WebEllipticCurve.py | 104 ++++++------- lmfdb/ecnf/ecnf_stats.py | 10 +- lmfdb/ecnf/ecnf_test_pages.py | 4 +- lmfdb/ecnf/isog_class.py | 8 +- lmfdb/ecnf/main.py | 36 ++--- lmfdb/elliptic_curves/congruent_numbers.py | 8 +- lmfdb/elliptic_curves/elliptic_curve.py | 28 ++-- lmfdb/elliptic_curves/isog_class.py | 20 +-- lmfdb/elliptic_curves/web_ec.py | 80 +++++----- lmfdb/galois_groups/main.py | 16 +- lmfdb/galois_groups/transitive_group.py | 26 ++-- lmfdb/genus2_curves/g2c_test_pages.py | 6 +- lmfdb/genus2_curves/main.py | 14 +- lmfdb/groups/abstract/circles.py | 4 +- lmfdb/groups/abstract/groups_test_pages.py | 2 +- lmfdb/groups/abstract/main.py | 18 +-- lmfdb/groups/abstract/stats.py | 2 +- lmfdb/groups/abstract/verify.py | 2 +- lmfdb/groups/abstract/web_groups.py | 84 +++++------ lmfdb/groups/glnC/main.py | 4 +- lmfdb/groups/glnQ/main.py | 8 +- lmfdb/hecke_algebras/main.py | 96 ++++++------ lmfdb/higher_genus_w_automorphisms/main.py | 50 +++---- lmfdb/hilbert_modular_forms/hilbert_field.py | 6 +- .../hilbert_modular_form.py | 22 +-- lmfdb/hilbert_modular_forms/web_HMF.py | 14 +- lmfdb/knowledge/knowl.py | 14 +- lmfdb/lattice/isom.py | 24 +-- lmfdb/lfunctions/Lfunction.py | 30 ++-- lmfdb/lfunctions/Lfunctionutilities.py | 12 +- lmfdb/lfunctions/main.py | 22 +-- lmfdb/lfunctions/test_lfunctions.py | 2 +- lmfdb/local_fields/main.py | 34 ++--- lmfdb/logger/start.py | 2 +- lmfdb/maass_forms/main.py | 2 +- lmfdb/maass_forms/plot.py | 2 +- lmfdb/modl_galois_representations/main.py | 4 +- .../web_modlgal.py | 20 +-- lmfdb/modlmf/main.py | 82 +++++----- lmfdb/modular_curves/main.py | 10 +- lmfdb/modular_curves/test_modular_curves.py | 2 +- lmfdb/modular_curves/web_curve.py | 20 +-- lmfdb/motives/main.py | 2 +- lmfdb/nfutils/psort.py | 22 +-- lmfdb/number_fields/number_field.py | 84 +++++------ lmfdb/number_fields/web_number_field.py | 62 ++++---- lmfdb/sato_tate_groups/main.py | 140 +++++++++--------- .../siegel_modular_form.py | 14 +- lmfdb/siegel_modular_forms/smf_test_pages.py | 2 +- lmfdb/tensor_products/galois_reps.py | 50 +++---- lmfdb/tensor_products/main.py | 14 +- lmfdb/users/main.py | 4 +- lmfdb/utils/color.py | 4 +- lmfdb/utils/display_stats.py | 8 +- lmfdb/utils/downloader.py | 2 +- lmfdb/utils/search_boxes.py | 4 +- lmfdb/utils/search_parsing.py | 2 +- lmfdb/utils/trace_hash.py | 2 +- lmfdb/utils/utilities.py | 10 +- lmfdb/utils/web_display.py | 16 +- lmfdb/verify/gps/gps_gl2zhat_fine.py | 2 +- lmfdb/verify/mf/mf_hecke_nf.py | 6 +- lmfdb/verify/mf/mf_newforms.py | 2 +- lmfdb/verify/verification.py | 42 +++--- 83 files changed, 890 insertions(+), 890 deletions(-) diff --git a/lmfdb/abvar/fq/download.py b/lmfdb/abvar/fq/download.py index ede1703fea..e8aaec67ae 100644 --- a/lmfdb/abvar/fq/download.py +++ b/lmfdb/abvar/fq/download.py @@ -12,22 +12,22 @@ class AbvarFq_download(Downloader): def download_all(self, label, lang='text'): data = db.av_fq_isog.lookup(label) if data is None: - return abort(404, "Label not found: %s"%label) + return abort(404, "Label not found: %s" % label) return self._wrap(Json.dumps(data), label, lang=lang, - title='Stored data for abelian variety isogeny class %s,'%(label)) + title='Stored data for abelian variety isogeny class %s,' % (label)) def download_curves(self, label, lang='text'): data = db.av_fq_isog.lookup(label) if data is None: - return abort(404, "Label not found: %s"%label) + return abort(404, "Label not found: %s" % label) if 'curves' not in data or ('curves' in data and not data['curves']): - return abort(404, "No curves for abelian variety isogeny class %s"%label) + return abort(404, "No curves for abelian variety isogeny class %s" % label) return self._wrap('\n'.join(data['curves']), label + '.curves', lang=lang, - title='Curves in abelian variety isogeny class %s,'%(label)) + title='Curves in abelian variety isogeny class %s,' % (label)) def postprocess(self, rec, info, query): return AbvarFq_isoclass(rec) diff --git a/lmfdb/abvar/fq/main.py b/lmfdb/abvar/fq/main.py index 3f57d925cb..16d99b3ceb 100644 --- a/lmfdb/abvar/fq/main.py +++ b/lmfdb/abvar/fq/main.py @@ -133,11 +133,11 @@ def abelian_varieties_by_gqi(g, q, iso): properties=cl.properties(), friends=cl.friends(), downloads=downloads, - title='Abelian variety isogeny class %s over $%s$'%(label, cl.field()), + title ='Abelian variety isogeny class %s over $%s$' % (label, cl.field()), bread=bread, cl=cl, learnmore=learnmore_list(), - KNOWL_ID='av.fq.%s'%label + KNOWL_ID ='av.fq.%s' % label ) def url_for_label(label): diff --git a/lmfdb/api/api.py b/lmfdb/api/api.py index 198316b18e..fe8b12346f 100644 --- a/lmfdb/api/api.py +++ b/lmfdb/api/api.py @@ -70,7 +70,7 @@ def full_index(): def stats(): def mb(x): return int(round(x/2**20.)) - info={} + info = {} info['minsizes'] = ['0','1','10','100','1000','10000','100000'] info['minsize'] = request.args.get('minsize','1').strip() if info['minsize'] not in info['minsizes']: @@ -270,7 +270,7 @@ def apierror(msg, flash_extras=[], code=404, table=True): # executing the query "q" and replacing the _id in the result list # So as not to preserve backwards compatibility (see test_api_usage() test) - if table=='ec_curvedata': + if table == 'ec_curvedata': for oldkey, newkey in zip(['label', 'iso', 'number'], ['Clabel', 'Ciso', 'Cnumber']): if oldkey in q: q[newkey] = q[oldkey] diff --git a/lmfdb/api2/api2.py b/lmfdb/api2/api2.py index a7840552fc..a0aa9b4839 100644 --- a/lmfdb/api2/api2.py +++ b/lmfdb/api2/api2.py @@ -83,9 +83,9 @@ def handle_singletons(path_var): @api2_page.route("/description/searchers") def list_searchers(): - names=[] - h_names=[] - descs=[] + names = [] + h_names = [] + descs = [] for el in searchers: names.append(el) h_names.append(searchers[el].get_name()) diff --git a/lmfdb/api2/utils.py b/lmfdb/api2/utils.py index 414ceeffee..6258bd7eb5 100644 --- a/lmfdb/api2/utils.py +++ b/lmfdb/api2/utils.py @@ -44,7 +44,7 @@ def create_search_dict(table='', query=None, view_start=0, request=None): 'max_count':100, 'correct_count':False, 'count_only':False} if request: - search['view_start']=int(request.args.get('_view_start', search['view_start'])) + search['view_start'] = int(request.args.get('_view_start', search['view_start'])) search['max_count'] = min(int(request.args.get('_max_count', search['max_count'])), 100) search['correct_count'] = bool(request.args.get('_correct_count', search['correct_count'])) search['count_only'] = bool(request.args.get('_count_only', search['count_only'])) diff --git a/lmfdb/artin_representations/main.py b/lmfdb/artin_representations/main.py index 552a843d41..ca0febd01c 100644 --- a/lmfdb/artin_representations/main.py +++ b/lmfdb/artin_representations/main.py @@ -150,7 +150,7 @@ def artin_representation_jump(info): return redirect(url_for(".index")) return redirect(url_for(".render_artin_representation_webpage", label=label), 307) -dihedrals =[ [4,2], [6,1], [8, 3], [10,1], [12,4], [14,1], [16,7], +dihedrals = [ [4,2], [6,1], [8, 3], [10,1], [12,4], [14,1], [16,7], [ 18, 1 ], [ 20, 4 ], [ 22, 1 ], [ 24, 6 ], [ 26, 1 ], [ 28, 3 ], [ 30, 3 ], [ 32, 18 ], [ 34, 1 ], [ 36, 4 ], [ 38, 1 ], [ 40, 6 ], [ 42, 5 ], [ 44, 3 ], [ 46, 1 ], [ 48, 7 ], [ 50, 1 ], [ 52, 4 ], [ 54, 1 ], [ 56, 5 ], [ 58, 1 ], @@ -183,9 +183,9 @@ def parse_projective_group(inp, query, qfield): query[qfield] = [24,12] elif Dn_RE.match(inp): n = int(inp.replace('d',''))-2 - if n>=0 and n= 0 and n < len(dihedrals): query[qfield] = dihedrals[n] - elif n>=0: + elif n >= 0: query[qfield] = [-1,-2] # we don't have it else: try: @@ -339,7 +339,7 @@ def render_artin_representation_webpage(label): #artin_logger.info("Found %s" % (the_rep._data)) - if case=='rep': + if case == 'rep': title = "Artin representation %s" % label else: title = "Galois orbit of Artin representations %s" % label @@ -369,10 +369,10 @@ def render_artin_representation_webpage(label): if proj_coefs != the_nf.polynomial(): friends.append(("Field {}".format(proj_wnf.get_label()), str(url_for("number_fields.by_label", label=proj_wnf.get_label())))) - if case == 'rep' or the_rep.galois_conjugacy_size()==1: + if case == 'rep' or the_rep.galois_conjugacy_size() == 1: cc = the_rep.central_character() if cc is not None: - if the_rep.dimension()==1: + if the_rep.dimension() == 1: if cc.order == 2: cc_name = cc.symbol else: @@ -391,7 +391,7 @@ def render_artin_representation_webpage(label): friends.append(("L-function", url_for('l_functions.by_full_label', label='1-1-1.1-r0-0-0'))) else: # looking for Lhash dirichlet_L_modulus.number - mylhash = 'dirichlet_L_%d.%d'%(cc.modulus,cc.number) + mylhash = 'dirichlet_L_%d.%d' % (cc.modulus,cc.number) lres = db.lfunc_instances.lucky({'Lhash': mylhash}) if lres is not None: friends.append(("L-function", url_for('l_functions.by_full_label', label=lres["label"]))) @@ -410,7 +410,7 @@ def render_artin_representation_webpage(label): friends.append(("Artin representation " + artin_label_pretty(newlabel), url_for(".render_artin_representation_webpage", label=newlabel))) - info={} # for testing + info = {} # for testing if case == 'rep': return render_template( diff --git a/lmfdb/bianchi_modular_forms/bianchi_modular_form.py b/lmfdb/bianchi_modular_forms/bianchi_modular_form.py index 25ca069a84..3f390e7d3f 100644 --- a/lmfdb/bianchi_modular_forms/bianchi_modular_form.py +++ b/lmfdb/bianchi_modular_forms/bianchi_modular_form.py @@ -107,7 +107,7 @@ def statistics(): def bianchi_modular_form_jump(info): label = info['jump'].strip() dat = label.split("-") - if len(dat)==2: # assume field & level, display space + if len(dat) == 2: # assume field & level, display space return render_bmf_space_webpage(dat[0], dat[1]) else: # assume single newform label; will display an error if invalid return bianchi_modular_form_by_label(label) @@ -184,7 +184,7 @@ def bianchi_modular_form_search(info, query): query['CM'] = 0 # will exclude NULL values elif info['include_cm'] == 'only': query['CM'] = {'$ne': 0} # will exclude NULL values - if info.get('include_base_change') =='exclude': + if info.get('include_base_change') == 'exclude': query['bc'] = 0 elif info.get('include_base_change') == 'only': query['bc'] = {'$ne': 0} @@ -223,13 +223,13 @@ def bmf_field_dim_table(**args): argsdict.update(to_dict(request.args)) gl_or_sl = argsdict['gl_or_sl'] - field_label=argsdict['field_label'] + field_label = argsdict['field_label'] field_label = nf_string_to_label(field_label) count = parse_count(argsdict, 50) start = parse_start(argsdict) - info={} + info = {} info['gl_or_sl'] = gl_or_sl # level_flag controls whether to list all levels ('all'), only # those with positive cuspidal dimension ('cusp'), or only those @@ -245,7 +245,7 @@ def bmf_field_dim_table(**args): parse_ints(argsdict, query, 'level_norm') info["level_norm"] = argsdict["level_norm"] query['field_label'] = field_label - if gl_or_sl=='gl2_dims': + if gl_or_sl == 'gl2_dims': info['group'] = 'GL(2)' info['bgroup'] = r'\GL(2,\mathcal{O}_K)' else: @@ -296,7 +296,7 @@ def bmf_field_dim_table(**args): info['nlevels'] = len(data) dimtable = [{'level_label': dat['level_label'], 'level_norm': dat['level_norm'], - 'level_space': url_for(".render_bmf_space_webpage", field_label=field_label, level_label=dat['level_label']) if gl_or_sl=='gl2_dims' else "", + 'level_space': url_for(".render_bmf_space_webpage", field_label=field_label, level_label=dat['level_label']) if gl_or_sl == 'gl2_dims' else "", 'dims': dims[dat['level_label']]} for dat in data] info['dimtable'] = dimtable return render_template("bmf-field_dim_table.html", info=info, title=t, properties=properties, bread=bread) @@ -334,7 +334,7 @@ def render_bmf_space_webpage(field_label, level_label): info['level_norm'] = data['level_norm'] info['field_poly'] = teXify_pol(str(nf.poly())) info['field_knowl'] = nf_display_knowl(field_label, pretty_field_label) - w = 'i' if nf.disc()==-4 else 'a' + w = 'i' if nf.disc() == -4 else 'a' L = nf.K().change_names(w) alpha = L.gen() info['field_gen'] = latex(alpha) @@ -345,7 +345,7 @@ def render_bmf_space_webpage(field_label, level_label): weights = list(dim_data) weights.sort(key=int) for w in weights: - dim_data[w]['dim']=dim_data[w]['cuspidal_dim'] + dim_data[w]['dim'] = dim_data[w]['cuspidal_dim'] info['dim_data'] = dim_data info['weights'] = weights info['nweights'] = len(weights) @@ -357,14 +357,14 @@ def render_bmf_space_webpage(field_label, level_label): 'url': url_for(".render_bmf_webpage",field_label=f['field_label'], level_label=f['level_label'], label_suffix=f['label_suffix']), 'wt': f['weight'], 'dim': f['dimension'], - 'sfe': "+1" if f.get('sfe',None)==1 else "-1" if f.get('sfe',None)==-1 else "?", + 'sfe': "+1" if f.get('sfe',None) == 1 else "-1" if f.get('sfe',None) == -1 else "?", 'bc': bc_info(f['bc']), 'cm': cm_info(f.get('CM','?')), } for f in newforms] info['nnewforms'] = len(info['nfdata']) # currently we have newforms of dimension 1 and 2 only (mostly dimension 1) # but the dimension 2 data is untrustworthy so is ignored here - info['nnf1'] = sum(1 for f in info['nfdata'] if f['dim']==1) + info['nnf1'] = sum(1 for f in info['nfdata'] if f['dim'] == 1) #info['nnf2'] = sum(1 for f in info['nfdata'] if f['dim']==2) info['nnf_missing'] = dim_data['2']['new_dim'] - info['nnf1'] # - 2*info['nnf2'] properties = [('Base field', pretty_field_label), ('Level',info['level_label']), ('Norm',str(info['level_norm'])), ('New dimension',str(newdim))] @@ -447,7 +447,7 @@ def download_bmf_magma(**args): outstr += 'heckePol := x;\nK := Rationals(); e := 1;\n' hecke_eigs_processed = [str(st).replace(' ', '') if st != 'not known' else '"not known"' for st in hecke_eigs] - outstr += '\nheckeEigenvaluesList := [*\n'+ ',\n'.join(hecke_eigs_processed) + '\n*];\n' + outstr += '\nheckeEigenvaluesList := [*\n' + ',\n'.join(hecke_eigs_processed) + '\n*];\n' outstr += '\nheckeEigenvalues := AssociativeArray();\n' outstr += 'for i in [1..#heckeEigenvaluesList] do\n heckeEigenvalues[primes[i]] := heckeEigenvaluesList[i];\nend for;\n' @@ -635,7 +635,7 @@ def render_bmf_webpage(field_label, level_label, label_suffix): friends=friends, info=info, learnmore=learnmore_list(), - KNOWL_ID="mf.bianchi.%s"%label, + KNOWL_ID ="mf.bianchi.%s" % label, ) diff --git a/lmfdb/bianchi_modular_forms/web_BMF.py b/lmfdb/bianchi_modular_forms/web_BMF.py index aad0e65206..6b47795814 100644 --- a/lmfdb/bianchi_modular_forms/web_BMF.py +++ b/lmfdb/bianchi_modular_forms/web_BMF.py @@ -151,7 +151,7 @@ def make_form(self,nap0=50): # 'hecke_poly_obj' is the non-LaTeX version of hecke_poly self.hecke_poly_obj = self.hecke_poly - if self.dimension>1: + if self.dimension > 1: Qx = PolynomialRing(QQ,'x') self.hecke_poly = Qx(str(self.hecke_poly)) F = NumberField(self.hecke_poly,'z') @@ -176,7 +176,7 @@ def conv(ap): ideal_label(p), web_latex(p.gens_reduced()), web_latex(ap)] for p,ap in zip(primes_iter(K), self.hecke_eigs[:self.neigs]) if p not in badp] - self.have_AL = self.AL_eigs[0]!='?' + self.have_AL = self.AL_eigs[0] != '?' if self.have_AL: self.AL_table = [[web_latex(p.norm()), ideal_label(p), @@ -199,7 +199,7 @@ def conv(ap): self.anrank = "not determined" else: self.Lratio = QQ(self.Lratio) - self.anrank = r"\(0\)" if self.Lratio!=0 else "odd" if self.sfe==-1 else r"\(\ge2\), even" + self.anrank = r"\(0\)" if self.Lratio != 0 else "odd" if self.sfe == -1 else r"\(\ge2\), even" self.properties = [('Label', self.label), ('Base field', pretty_field), @@ -215,7 +215,7 @@ def conv(ap): elif self.CM == 0: self.CM = 'no' else: - if int(self.CM)%4 in [2,3]: + if int(self.CM) % 4 in [2,3]: self.CM = 4*int(self.CM) self.CM = "$%s$" % self.CM except AttributeError: @@ -224,7 +224,7 @@ def conv(ap): self.bc_extra = '' self.bcd = 0 - self.bct = self.bc!='?' and self.bc!=0 + self.bct = self.bc != '?' and self.bc != 0 if self.bc == '?': self.bc = 'not determined' elif self.bc == 0: @@ -232,7 +232,7 @@ def conv(ap): elif self.bc == 1: self.bcd = self.bc self.bc = 'yes' - elif self.bc >1: + elif self.bc > 1: self.bcd = self.bc self.bc = 'yes' self.bc_extra = r', of a form over \(\mathbb{Q}\) with coefficients in \(\mathbb{Q}(\sqrt{' + str(self.bcd) + r'})\)' diff --git a/lmfdb/characters/HeckeCharacters.py b/lmfdb/characters/HeckeCharacters.py index 9d3e5e1534..798fba1218 100644 --- a/lmfdb/characters/HeckeCharacters.py +++ b/lmfdb/characters/HeckeCharacters.py @@ -97,7 +97,7 @@ def __call__(self, x): return HeckeChar(self, x) def __repr__(self): - return "Group of Hecke characters on %s"%self.group() + return "Group of Hecke characters on %s" % self.group() #def list(self): # return [ HeckeChar(self, c.list()) for c in DualAbelianGroup_class.list(self) ] @@ -147,7 +147,7 @@ def logvalue(self, x): if isinstance(r, (int,Integer)): return 0 n,d = r.numerator(), r.denominator() - return n%d/d + return n % d/d def logvalues_on_gens(self): F = self.exponents() diff --git a/lmfdb/characters/main.py b/lmfdb/characters/main.py index 20cec10787..793aca48b4 100644 --- a/lmfdb/characters/main.py +++ b/lmfdb/characters/main.py @@ -404,7 +404,7 @@ def render_Dirichletwebpage(modulus=None, orbit_label=None, number=None): modulus, number = modulus.split('.') return redirect(url_for(".render_Dirichletwebpage", modulus=modulus, number=number), 301) if number is not None and number > modulus: - return redirect(url_for(".render_Dirichletwebpage", modulus=modulus, number=number%modulus), 301) + return redirect(url_for(".render_Dirichletwebpage", modulus=modulus, number=number % modulus), 301) if modulus == 1 and number == 0: return redirect(url_for(".render_Dirichletwebpage", modulus=1, number=1), 301) @@ -467,7 +467,7 @@ def render_Dirichletwebpage(modulus=None, orbit_label=None, number=None): return redirect(url_for(".render_DirichletNavigation")) else: if gcd(modulus,number) != 1: - flash_error("%s is not a valid Conrey label (number must be coprime to modulus).", "%s.%s"%(args['modulus'],args['number'])) + flash_error("%s is not a valid Conrey label (number must be coprime to modulus).", "%s.%s" % (args['modulus'],args['number'])) return redirect(url_for(".render_DirichletNavigation")) try: diff --git a/lmfdb/characters/test_characters.py b/lmfdb/characters/test_characters.py index f544667695..792c8178eb 100644 --- a/lmfdb/characters/test_characters.py +++ b/lmfdb/characters/test_characters.py @@ -27,8 +27,8 @@ def test_order(self): def test_even_odd(self): W = self.tc.get('/Character/Dirichlet/?modulus=35') - assert '>%s%s%s%s 1: - raise Warning ("n must be coprime to the modulus : %s"%mod) + raise Warning ("n must be coprime to the modulus : %s" % mod) if val > mod: - raise Warning ("n must be less than the modulus : %s"%mod) + raise Warning ("n must be less than the modulus : %s" % mod) if val < 0: raise Warning ("n must be positive") @@ -362,7 +362,7 @@ def jacobi_sum(self, val): Gtex = r'\Z/%s\Z' % mod chitexr = self.char2tex(mod, num, 'r', tag=False) psitex1r = self.char2tex(mod, val, '1-r', tag=False) - deftex = r'\sum_{r\in %s} %s %s'%(Gtex,chitexr,psitex1r) + deftex = r'\sum_{r\in %s} %s %s' % (Gtex,chitexr,psitex1r) return r"\( \displaystyle J(%s,%s) = %s = %s \)" % (chitex, psitex, deftex, latex(jacobi_sum)) @lazy_attribute @@ -544,7 +544,7 @@ def friends(self): if self.type == 'Dirichlet': f.append( ("Character group", url_character(type=self.type,modulus=self.modlabel)) ) f.append( ('Sato-Tate group', url_for('st.by_label', label=f'0.1.{self.order}'))) - if len(self.vflabel)>0: + if len(self.vflabel) > 0: f.append( ("Value field", url_for("number_fields.by_label", label=self.vflabel)) ) return f @@ -821,9 +821,9 @@ def _compute(self): def codeinit(self): return { 'sage': [ - 'H = DirichletGroup(%i)'%(self.modulus) + 'H = DirichletGroup(%i)' % (self.modulus) ], - 'pari': 'g = idealstar(,%i,2)'%(self.modulus) + 'pari': 'g = idealstar(,%i,2)' % (self.modulus) } @lazy_attribute @@ -1001,10 +1001,10 @@ def friends(self): assoclabel = '2.0.%d.1' % -self.symbol_numerator() friendlist.append(("Associated quadratic field", url_for("number_fields.by_label", label=assoclabel))) - label = "%s.%s"%(self.modulus, self.number) + label = "%s.%s" % (self.modulus, self.number) myrep = db.artin_reps.lucky({'Dets': {'$contains': label}}) if myrep is not None: - j=myrep['Dets'].index(label) + j = myrep['Dets'].index(label) artlabel = myrep['Baselabel']+'.'+num2letters(j+1) friendlist.append(('Artin representation '+artlabel, url_for('artin_representations.render_artin_representation_webpage', label=artlabel))) @@ -1066,7 +1066,7 @@ def codeparity(self): def codesymbol(self): m = self.symbol_numerator() if m: - return { 'sage': 'kronecker_character(%i)'%m, + return { 'sage': 'kronecker_character(%i)' % m, 'pari': 'znchartokronecker(g,chi)' } return None @@ -1255,7 +1255,7 @@ def symbol(self): def codesymbol(self): m = self.symbol_numerator() if m: - return { 'sage': 'kronecker_character(%i)'%m, + return { 'sage': 'kronecker_character(%i)' % m, 'pari': 'znchartokronecker(g,chi)' } return None @@ -1371,9 +1371,9 @@ def indlabel(self): def codeinit(self): return { 'sage': [ - 'H = DirichletGroup(%i)'%(self.modulus), - 'chi = H[%i]'%(self.number) ], - 'pari': '[g,chi] = znchar(Mod(%i,%i))'%(self.number,self.modulus), + 'H = DirichletGroup(%i)' % (self.modulus), + 'chi = H[%i]' % (self.number) ], + 'pari': '[g,chi] = znchar(Mod(%i,%i))' % (self.number,self.modulus), } @lazy_attribute @@ -1417,7 +1417,7 @@ def symbol(self): def codesymbol(self): m = self.symbol_numerator() if m: - return { 'sage': 'kronecker_character(%i)'%m, + return { 'sage': 'kronecker_character(%i)' % m, 'pari': 'znchartokronecker(g,chi)' } return None diff --git a/lmfdb/classical_modular_forms/cmf_test_pages.py b/lmfdb/classical_modular_forms/cmf_test_pages.py index 554120f14a..8f3cfb524d 100644 --- a/lmfdb/classical_modular_forms/cmf_test_pages.py +++ b/lmfdb/classical_modular_forms/cmf_test_pages.py @@ -54,7 +54,7 @@ def all_newforms(self, level, weight): errors.append(r[1]) if errors: - print("Tested %d pages with level = %d weight = %d with %d errors occurring on the following pages:" %(n, level, weight, len(errors))) + print("Tested %d pages with level = %d weight = %d with %d errors occurring on the following pages:" % (n, level, weight, len(errors))) for url in errors: print(url) @@ -71,7 +71,7 @@ def all_newspaces(self, level, weight): url = '/ModularForm/GL2/Q/holomorphic/%d/%d/' % (level, weight) newspaces = list(db.mf_newspaces.search({'level':level,'weight':weight, 'char_parity':-1 if bool(weight % 2) else 1}, ['label', 'dim'])) newforms = list(db.mf_newforms.search({'level':level,'weight':weight}, ['label', 'space_label', 'dim'])) - dim = gp("mfdim([%s,%s,-1],0)"%(level,weight)) + dim = gp("mfdim([%s,%s,-1],0)" % (level,weight)) if dim is None: for ns in newspaces: assert ns['dim'] == 0 @@ -150,7 +150,7 @@ def all_newspaces(self, level, weight): res.append((None, url)) if errors: - print("Tested %d pages with level = %d weight = %d with %d errors occurring on the following pages:" %(n, level, weight, len(errors))) + print("Tested %d pages with level = %d weight = %d with %d errors occurring on the following pages:" % (n, level, weight, len(errors))) for url in errors: print(url) @@ -217,7 +217,7 @@ def test_all(self): bins[i] += 1 for i, b in enumerate(bins): d = 100*float(b)/total - print('%.2f\t|' %((i + 0.5)*h + just_times[0]) + '-'*(int(d)-1) + '| - %.2f%%' % d) + print('%.2f\t|' % ((i + 0.5)*h + just_times[0]) + '-'*(int(d)-1) + '| - %.2f%%' % d) else: print("These pages didn't pass the tests:") for u in broken_urls: diff --git a/lmfdb/classical_modular_forms/download.py b/lmfdb/classical_modular_forms/download.py index 51a794b738..44dc426231 100644 --- a/lmfdb/classical_modular_forms/download.py +++ b/lmfdb/classical_modular_forms/download.py @@ -22,9 +22,9 @@ def _get_hecke_nf(self, label): print(data) if data is None: f = db.mf_newforms.lookup(label,projection=["level","char_orbit_label","dim","traces"]) - if f["dim"]==1: - vals = ConreyCharacter(f["level"], db.char_dirichlet.lookup("%s.%s"%(f["level"],f["char_orbit_label"]),projection="first")).values_gens - vals = [[v[0],[1] if v[1]==0 else [-1]] for v in vals] + if f["dim"] == 1: + vals = ConreyCharacter(f["level"], db.char_dirichlet.lookup("%s.%s" % (f["level"],f["char_orbit_label"]),projection="first")).values_gens + vals = [[v[0],[1] if v[1] == 0 else [-1]] for v in vals] aps = [[f["traces"][p-1]] for p in prime_range(len(f["traces"])+1)] data = { 'hecke_ring_cyclotomic_generator': 0, 'hecke_ring_character_values': vals, 'hecke_ring_power_basis': True, 'field_poly': [0,1], 'maxp': previous_prime(len(f["traces"])), 'ap': aps } else: @@ -43,11 +43,11 @@ def _get_traces(self, label): elif label.count('.') == 3: traces = db.mf_newforms.lookup(label, projection=['traces']) else: - return abort(404, "Invalid label: %s"%label) + return abort(404, "Invalid label: %s" % label) if traces is None: - return abort(404, "Label not found: %s"%label) + return abort(404, "Label not found: %s" % label) elif traces.get('traces') is None: - return abort(404, "We have not computed traces for: %s"%label) + return abort(404, "We have not computed traces for: %s" % label) else: return [0] + traces['traces'] @@ -204,7 +204,7 @@ def download_qexp(self, label, lang='sage'): return self._wrap(explain + code + level_data + weight_data + poly_data + basis_data + hecke_ring_character_values + aps_data, label + '.qexp', lang=lang, - title='q-expansion of newform %s,'%(label)) + title='q-expansion of newform %s,' % (label)) def download_traces(self, label, lang='text'): data = self._get_traces(label) @@ -214,7 +214,7 @@ def download_traces(self, label, lang='text'): return self._wrap(Json.dumps(data), label + '.traces', lang=lang, - title='Trace form for %s,'%(label)) + title='Trace form for %s,' % (label)) def download_multiple_traces(self, info, spaces=False): lang = info.get(self.lang_key,'text').strip() @@ -293,7 +293,7 @@ def download_embedding(self, label, lang='text'): 'an_normalized', 'angles']) if data is None: - return abort(404, "No embedded newform found for %s"%(label)) + return abort(404, "No embedded newform found for %s" % (label)) root = (data.pop('embedding_root_real', None), data.pop('embedding_root_imag', None)) if root != (None, None): @@ -301,12 +301,12 @@ def download_embedding(self, label, lang='text'): return self._wrap(Json.dumps(data), label, lang=lang, - title='Coefficient data for embedded newform %s,'%label) + title='Coefficient data for embedded newform %s,' % label) def download_newform(self, label, lang='text'): data = db.mf_newforms.lookup(label) if data is None: - return abort(404, "Label not found: %s"%label) + return abort(404, "Label not found: %s" % label) form = WebNewform(data) if form.has_exact_qexp: data['qexp'] = form.qexp @@ -314,7 +314,7 @@ def download_newform(self, label, lang='text'): return self._wrap(Json.dumps(data), label, lang=lang, - title='Stored data for newform %s,'%(label)) + title='Stored data for newform %s,' % (label)) def download_code(self, label, lang): if lang == 'gp': @@ -324,7 +324,7 @@ def download_code(self, label, lang): abort(404,"Invalid code language specified: " + lang) data = db.mf_newforms.lookup(label) if data is None: - return abort(404, "Label not found: %s"%label) + return abort(404, "Label not found: %s" % label) form = WebNewform(data) code = form.code comment = code.pop('comment').get(lang).strip() @@ -339,20 +339,20 @@ def download_code(self, label, lang): def download_newspace(self, label, lang='text'): data = db.mf_newspaces.lookup(label) if data is None: - return abort(404, "Label not found: %s"%label) + return abort(404, "Label not found: %s" % label) space = WebNewformSpace(data) data['newforms'] = [form['label'] for form in space.newforms] data['oldspaces'] = space.oldspaces return self._wrap(Json.dumps(data), label, lang=lang, - title='Stored data for newspace %s,'%(label)) + title='Stored data for newspace %s,' % (label)) def download_full_space(self, label, lang='text'): try: space = WebGamma1Space.by_label(label) except ValueError: - return abort(404, "Label not found: %s"%label) + return abort(404, "Label not found: %s" % label) data = {} for attr in ['level', 'weight', 'label', 'oldspaces']: data[attr] = getattr(space, attr) @@ -364,7 +364,7 @@ def download_full_space(self, label, lang='text'): return self._wrap(Json.dumps(data), label, lang=lang, - title='Stored data for newspace %s,'%(label)) + title='Stored data for newspace %s,' % (label)) def download_spaces(self, info): lang = info.get(self.lang_key,'text').strip() diff --git a/lmfdb/classical_modular_forms/main.py b/lmfdb/classical_modular_forms/main.py index 89e6641a38..ce3bf65628 100644 --- a/lmfdb/classical_modular_forms/main.py +++ b/lmfdb/classical_modular_forms/main.py @@ -91,9 +91,9 @@ def level_bound(nontriv=None): ############################################################################# def ALdims_knowl(al_dims, level, weight): - short = "+".join(["$%s$"%(d) for d in al_dims]) + short = "+".join(["$%s$" % (d) for d in al_dims]) AL_table = ALdim_table(al_dims, level, weight) - return r'%s'%(AL_table, short) + return r'%s' % (AL_table, short) def nf_link(m, d, is_real_cyc, nf_label, poly, disc): # args: ["field_poly_root_of_unity", "dim", "field_poly_is_real_cyclotomic", "nf_label", "field_poly", "field_disc_factorization"] @@ -128,14 +128,14 @@ def display_decomp(level, weight, char_orbit_label, hecke_orbit_dims): for dim in sorted(dim_dict.keys()): count = dim_dict[dim] query = {'weight':weight, - 'char_label':'%s.%s'%(level,char_orbit_label), + 'char_label':'%s.%s' % (level,char_orbit_label), 'dim':dim} if count > 3: short = r'\({0}\)+\(\cdots\)+\({0}\)'.format(dim) title = '%s newforms' % count else: - short = '+'.join([r'\(%s\)'%dim]*count) - title=None + short = '+'.join([r'\(%s\)' % dim]*count) + title = None if count == 1: query['jump'] = 'yes' link = newform_search_link(short, title=title, **query) @@ -269,8 +269,8 @@ def parse_n(info, newform, primes_only): def parse_m(info, newform): errs = [] maxm = min(newform.dim, 20) - info['default_mrange'] = '1-%s'%maxm - mrange = info.get('m', '1-%s'%maxm) + info['default_mrange'] = '1-%s' % maxm + mrange = info.get('m', '1-%s' % maxm) if '.' in mrange: # replace embedding codes with the corresponding integers # If error, need to replace 'm' by default @@ -278,7 +278,7 @@ def parse_m(info, newform): mrange = re.sub(r'\d+\.\d+', newform.embedding_from_embedding_label, mrange) except ValueError: errs.append("Invalid embedding label") - mrange = info['m'] = '1-%s'%maxm + mrange = info['m'] = '1-%s' % maxm try: info['CC_m'] = integer_options(mrange, 1000) except (ValueError, TypeError) as err: @@ -442,7 +442,7 @@ def render_full_gamma1_space_webpage(label): space = WebGamma1Space.by_label(label) except (TypeError,KeyError,ValueError) as err: return abort(404, err.args) - info={} + info = {} set_info_funcs(info) learnmore_cmf_picture = ('Picture description', url_for(".picture_page")) return render_template("cmf_full_gamma1_space.html", @@ -728,13 +728,13 @@ def common_parse(info, query, na_check=False): parse_character(info, query, 'prim_label', name='Primitive character', prim=True) parse_ints(info, query, 'weight', name="Weight") if 'weight_parity' in info: - parity=info['weight_parity'] + parity = info['weight_parity'] if parity == 'even': query['weight_parity'] = 1 elif parity == 'odd': query['weight_parity'] = -1 if 'char_parity' in info: - parity=info['char_parity'] + parity = info['char_parity'] if parity == 'even': query['char_parity'] = 1 elif parity == 'odd': @@ -844,7 +844,7 @@ def _AL_col(i, p): FloatCol("analytic_conductor", "cmf.analytic_conductor", r"$A$", align="center", short_title="analytic conductor"), MultiProcessedCol("field", "cmf.coefficient_field", "Field", ["field_poly_root_of_unity", "dim", "field_poly_is_real_cyclotomic", "nf_label", "field_poly", "field_disc_factorization"], nf_link, download_col="nf_label"), ProcessedCol("projective_image", "cmf.projective_image", "Image", - lambda img: ('' if img=='?' else '$%s_{%s}$' % (img[:1], img[1:])), + lambda img: ('' if img == '?' else '$%s_{%s}$' % (img[:1], img[1:])), contingent=lambda info: any(mf.get('weight') == 1 for mf in info["results"]), default=lambda info: all(mf.get('weight') == 1 for mf in info["results"]), align="center", short_title="projective image"), @@ -877,7 +877,7 @@ def _AL_col(i, p): lambda ev: "$+$" if ev == 1 else ("$-$" if ev else ""), contingent=display_Fricke, default=lambda info: not display_AL(info), align="center"), ProcessedCol("hecke_ring_index_factorization", "cmf.coefficient_ring", "Coefficient ring index", - lambda fac: "" if fac=="" else factor_base_factorization_latex(fac), mathmode=True, align="center", default=False), + lambda fac: "" if fac == "" else factor_base_factorization_latex(fac), mathmode=True, align="center", default=False), ProcessedCol("sato_tate_group", "cmf.sato_tate", "Sato-Tate", st_display_knowl, short_title="Sato-Tate group", default=False), MultiProcessedCol("qexp", "cmf.q-expansion", "$q$-expansion", ["label", "qexp_display"], lambda label, disp: fr'\({disp}\)' if disp else "", @@ -982,9 +982,9 @@ def set_rows_cols(info, query): raise ValueError("Table too large: at most 200 options for weight") if 'weight_parity' in query: if query['weight_parity'] == -1: - info['weight_list'] = [k for k in info['weight_list'] if k%2 == 1] + info['weight_list'] = [k for k in info['weight_list'] if k % 2 == 1] else: - info['weight_list'] = [k for k in info['weight_list'] if k%2 == 0] + info['weight_list'] = [k for k in info['weight_list'] if k % 2 == 0] if 'char_orbit_index' in query: # Character was set, consistent with level info['level_list'] = [query['level']] @@ -1325,7 +1325,7 @@ def summary(self): @lazy_attribute def buckets(self): return {'level':['1','2-10','11-100','101-1000','1001-5000', '5001-10000','10001-50000','50001-100000','100001-1000000'], - 'weight':['1','2','3','4','5-8','9-16','17-32','33-64','65-%d'%weight_bound()], + 'weight':['1','2','3','4','5-8','9-16','17-32','33-64','65-%d' % weight_bound()], 'dim':['1','2','3','4','5','6-10','11-20','21-100','101-1000','1001-10000','10001-100000'], 'relative_dim':['1','2','3','4','5','6-10','11-20','21-100','101-1000'], 'char_order':['1','2','3','4','5','6-10','11-20','21-100','101-1000'], @@ -1448,10 +1448,10 @@ class CMFSearchArray(SearchArray): sorts = {'': _sort_forms, 'Traces': _sort_forms, 'Spaces': _sort_spaces} - jump_example="3.6.a.a" - jump_egspan="e.g. 3.6.a.a, 55.3.d or 20.5" - jump_knowl="cmf.search_input" - jump_prompt="Label" + jump_example = "3.6.a.a" + jump_egspan = "e.g. 3.6.a.a, 55.3.d or 20.5" + jump_knowl = "cmf.search_input" + jump_prompt = "Label" null_column_explanations = { # No need to display warnings for these 'is_polredabs': False, 'projective_image': False, @@ -1626,7 +1626,7 @@ def __init__(self): example='20', example_span='7, 1-10') - analytic_rank= TextBox( + analytic_rank = TextBox( name='analytic_rank', label='Analytic rank', knowl='cmf.analytic_rank', diff --git a/lmfdb/classical_modular_forms/test_cmf.py b/lmfdb/classical_modular_forms/test_cmf.py index 4b157a540e..f00986423a 100644 --- a/lmfdb/classical_modular_forms/test_cmf.py +++ b/lmfdb/classical_modular_forms/test_cmf.py @@ -86,7 +86,7 @@ def test_many(self): print("testing (N, k) = (%s, %s)" % (N, k)) url = "/ModularForm/GL2/Q/holomorphic/{0}/{1}/".format(N, k) rv = self.tc.get(url,follow_redirects=True) - self.assertTrue(rv.status_code==200,"Request failed for {0}".format(url)) + self.assertTrue(rv.status_code == 200,"Request failed for {0}".format(url)) assert str(N) in rv.get_data(as_text=True) assert str(k) in rv.get_data(as_text=True) assert str(N)+'.'+str(k) in rv.get_data(as_text=True) diff --git a/lmfdb/classical_modular_forms/web_newform.py b/lmfdb/classical_modular_forms/web_newform.py index 34ef20c81b..67c15fafd4 100644 --- a/lmfdb/classical_modular_forms/web_newform.py +++ b/lmfdb/classical_modular_forms/web_newform.py @@ -184,7 +184,7 @@ def __init__(self, data, space=None, all_m=False, all_n=False, embedding_label=N hecke_cols = ['hecke_ring_numerators', 'hecke_ring_denominators', 'hecke_ring_inverse_numerators', 'hecke_ring_inverse_denominators', 'hecke_ring_cyclotomic_generator', 'hecke_ring_character_values', 'hecke_ring_power_basis', 'maxp'] if self.dim == 1: # avoid using mf_hecke_nf when the dimension is 1 - vals = ConreyCharacter(self.level, db.char_dirichlet.lookup("%s.%s"%(self.level,self.char_orbit_label),projection="first")).values_gens + vals = ConreyCharacter(self.level, db.char_dirichlet.lookup("%s.%s" % (self.level,self.char_orbit_label),projection="first")).values_gens eigenvals = { 'hecke_ring_cyclotomic_generator': 0, 'hecke_ring_character_values': vals, 'hecke_ring_power_basis': True, 'maxp': previous_prime(len(self.traces)+1), 'an': self.traces } else: eigenvals = db.mf_hecke_nf.lucky({'hecke_orbit_code': self.hecke_orbit_code}, ['an'] + hecke_cols) @@ -550,7 +550,7 @@ def by_label(label, embedding_label=None): from .main import Nk2_bound if Nk2 > Nk2_bound(nontriv=nontriv): nontriv_text = "non trivial" if nontriv else "trivial" - raise ValueError(r"Level and weight too large. The product \(Nk^2 = %s\) is larger than the currently computed threshold of \(%s\) for %s character."%(Nk2, Nk2_bound(nontriv=nontriv), nontriv_text) ) + raise ValueError(r"Level and weight too large. The product \(Nk^2 = %s\) is larger than the currently computed threshold of \(%s\) for %s character." % (Nk2, Nk2_bound(nontriv=nontriv), nontriv_text) ) raise ValueError("The newform %s is not in the database (but it may be added in the future)" % label) return WebNewform(data, embedding_label=embedding_label) @@ -683,7 +683,7 @@ def twist_minimal_display(self): if self.is_twist_minimal: return r'yes' else: - return r'no (minimal twist has level %s)'%(self.minimal_twist.split('.')[0]) if self.minimal_twist else r'no' + return r'no (minimal twist has level %s)' % (self.minimal_twist.split('.')[0]) if self.minimal_twist else r'no' def display_newspace(self): s = r'\(S_{%s}^{\mathrm{new}}(' @@ -691,7 +691,7 @@ def display_newspace(self): s += r'\Gamma_0(%s))\)' else: s += r'%s, [\chi])\)' - return s%(self.weight, self.level) + return s % (self.weight, self.level) def display_hecke_cutters(self): acting_on = f"acting on {self.display_newspace()}" @@ -708,7 +708,7 @@ def display_hecke_cutters(self): elif len(polynomials) == 1: desc += f"kernel of the {knowl} {polynomials[0]}" else: - desc = r"

This %s is the entire %s %s.

"%(display_knowl('cmf.newform_subspace','newform subspace'), + desc = r"

This %s is the entire %s %s.

" % (display_knowl('cmf.newform_subspace','newform subspace'), display_knowl('cmf.newspace','newspace'),self.display_newspace()) return desc @@ -764,7 +764,7 @@ def _zeta_print(self): def _make_table(self, basis): s = '\n' for LHS, RHS in basis: - s += r''%(LHS, RHS) + '\n' + s += r'' % (LHS, RHS) + '\n' return s + "
%s\(=\)%s
%s\(=\)%s
" def _order_basis_forward(self): @@ -920,7 +920,7 @@ def _elt(self, data): def dual_link(self): dlabel = self.label + '.' + self.dual_label d_url = '/ModularForm/GL2/Q/holomorphic/' + dlabel.replace('.','/') + '/' - return '%s'%(d_url, dlabel) + return '%s' % (d_url, dlabel) @property def char_orbit_link(self): @@ -961,11 +961,11 @@ def display_character_values(self): elif order == 2: latexterm = '-1' else: - latexterm = r'e\left(\frac{%s}{%s}\right)'%(chi_g, order) - color = "dark" if j%2 else "light" - gens.append(r' \(%s\)'%(color, g)) - vals.append(r' \(%s\)'%(color, latexterm)) - return ' \n%s \n \n%s '%('\n'.join(gens), '\n'.join(vals)) + latexterm = r'e\left(\frac{%s}{%s}\right)' % (chi_g, order) + color = "dark" if j % 2 else "light" + gens.append(r' \(%s\)' % (color, g)) + vals.append(r' \(%s\)' % (color, latexterm)) + return ' \n%s \n \n%s ' % ('\n'.join(gens), '\n'.join(vals)) def display_inner_twists(self): if self.inner_twist_count < 1: @@ -983,7 +983,7 @@ def display_inner_twists(self): for r in inner_twists: char_link = display_knowl('character.dirichlet.orbit_data', title=r['twisting_char_label'], kwargs={'label':r['twisting_char_label']}) d = r['self_twist_disc'] - stdisc = 'inner' if not d else ('trivial' if d==1 else ('CM by ' if d < 0 else 'RM by ') + quad_field_knowl(d)) + stdisc = 'inner' if not d else ('trivial' if d == 1 else ('CM by ' if d < 0 else 'RM by ') + quad_field_knowl(d)) twists.append(' ') twists.extend([td_wrapl(char_link), td_wrapl(parity_text(r['parity'])), td_wrapr(r['order']), td_wrapr(r['multiplicity']), td_wrapl(stdisc)]) twists.append(' ') @@ -1052,7 +1052,7 @@ def twist_type(r): return '' if r['target_label'] != self.label else ('inner' if not d else ('trivial' if d == 1 else ('CM' if d < 0 else 'RM'))) twists1 = ['', '', - ''% display_knowl('cmf.twist','twisting character orbit'), '', + '' % display_knowl('cmf.twist','twisting character orbit'), '', th_wrap('character.dirichlet.galois_orbit_label', 'Char'), th_wrap('character.dirichlet.parity', 'Parity'), th_wrap('character.dirichlet.order', 'Ord'), @@ -1066,7 +1066,7 @@ def twist_type(r): for r in sorted(self.twists, key=lambda x: [x['conductor'], x['twisting_char_orbit'], x['target_level'], x['target_char_orbit'], x['target_hecke_orbit']]): minimality = '✓' if r['target_label'] == self.minimal_twist else 'yes' if r['target_is_minimal'] else '' char_link = display_knowl('character.dirichlet.orbit_data', title=r['twisting_char_label'], kwargs={'label':r['twisting_char_label']}) - target_link = '%s'%('/ModularForm/GL2/Q/holomorphic/' + r['target_label'].replace('.','/'),r['target_label']) + target_link = '%s' % ('/ModularForm/GL2/Q/holomorphic/' + r['target_label'].replace('.','/'),r['target_label']) twists1.append('') twists1.extend([td_wrapl(char_link), td_wrapl(parity_text(r['parity'])), td_wrapr(r['order']), td_wrapr(r['multiplicity']), td_wrapl(twist_type(r)), td_wrapl(target_link), td_wrapc(minimality), td_wrapr(r['target_dim'])]) @@ -1074,7 +1074,7 @@ def twist_type(r): twists1.extend(['', '
       By %s
       By %s
']) twists2 = ['', '', - ''% display_knowl('cmf.twist','twisted newform orbit'), '', + '' % display_knowl('cmf.twist','twisted newform orbit'), '', th_wrap('cmf.twist', 'Twist'), th_wrap('cmf.twist_minimal', 'Min'), th_wrap('cmf.dimension', 'Dim'), @@ -1091,7 +1091,7 @@ def twist_type(r): x['twisting_char_orbit']]): minimality = '✓' if r['target_label'] == self.minimal_twist else 'yes' if r['target_is_minimal'] else '' char_link = display_knowl('character.dirichlet.orbit_data', title=r['twisting_char_label'], kwargs={'label':r['twisting_char_label']}) - target_link = '%s'%('/ModularForm/GL2/Q/holomorphic/' + r['target_label'].replace('.','/'),r['target_label']) + target_link = '%s' % ('/ModularForm/GL2/Q/holomorphic/' + r['target_label'].replace('.','/'),r['target_label']) twists2.append('') twists2.extend([td_wrapl(target_link), td_wrapc(minimality), td_wrapr(r['target_dim']), td_wrapl(char_link), td_wrapl(parity_text(r['parity'])), td_wrapr(r['order']), td_wrapr(r['multiplicity']), td_wrapl(twist_type(r))]) @@ -1124,7 +1124,7 @@ def revcode(x): return ((x & ((1 << 24) - 1)) << 40) | (((x >> 24) & ((1 << 12) - 1)) << 28) | (((x >> 36) & ((1 << 16) - 1)) << 12) | (x >> 52) twists1 = ['
        By %s
        By %s
', '', - ''% display_knowl('cmf.twist','twisting character'), '', + '' % display_knowl('cmf.twist','twisting character'), '', th_wrap('character.dirichlet.conrey', 'Char'), th_wrap('character.dirichlet.parity', 'Parity'), th_wrap('character.dirichlet.order', 'Ord'), @@ -1137,7 +1137,7 @@ def revcode(x): for r in sorted(self.embedded_twists, key=lambda x: [x['conductor'],x['twisting_conrey_index'],revcode(x['target_hecke_orbit_code']),x['target_conrey_index'],x['target_embedding_index']]): minimality = '✓' if r['target_label'] == self.embedded_minimal_twist else 'yes' if r['target_is_minimal'] else '' char_link = display_knowl('character.dirichlet.data', title=r['twisting_char_label'], kwargs={'label':r['twisting_char_label']}) - target_link = '%s'%('/ModularForm/GL2/Q/holomorphic/' + r['target_label'].replace('.','/'),r['target_label']) + target_link = '%s' % ('/ModularForm/GL2/Q/holomorphic/' + r['target_label'].replace('.','/'),r['target_label']) twists1.append('') twists1.extend([td_wrapl(char_link), td_wrapl(parity_text(r['parity'])), td_wrapr(r['order']), td_wrapl(twist_type(r)), td_wrapl(target_link), td_wrapc(minimality), td_wrapr(r['target_dim'])]) @@ -1145,7 +1145,7 @@ def revcode(x): twists1.extend(['', '
       By %s
       By %s
']) twists2 = ['', '', - ''% display_knowl('cmf.twist','twisted newform'), '', + '' % display_knowl('cmf.twist','twisted newform'), '', th_wrap('cmf.twist', 'Twist'), th_wrap('cmf.twist_minimal', 'Min'), th_wrap('cmf.dimension', 'Dim'), @@ -1158,7 +1158,7 @@ def revcode(x): for r in sorted(self.embedded_twists, key=lambda x: [revcode(x['target_hecke_orbit_code']),x['target_conrey_index'],x['target_embedding_index'],x['conductor'],x['twisting_conrey_index']]): minimality = '✓' if r['target_label'] == self.embedded_minimal_twist else 'yes' if r['target_is_minimal'] else '' char_link = display_knowl('character.dirichlet.orbit_data', title=r['twisting_char_label'], kwargs={'label':r['twisting_char_label']}) - target_link = '%s'%('/ModularForm/GL2/Q/holomorphic/' + r['target_label'].replace('.','/'),r['target_label']) + target_link = '%s' % ('/ModularForm/GL2/Q/holomorphic/' + r['target_label'].replace('.','/'),r['target_label']) twists2.append('') twists2.extend([td_wrapl(target_link), td_wrapc(minimality), td_wrapr(r['target_dim']), td_wrapl(char_link), td_wrapl(parity_text(r['parity'])), td_wrapr(r['order']), td_wrapl(twist_type(r))]) @@ -1228,14 +1228,14 @@ def trace_expansion(self, prec_max=10): def embed_header(self, n, format='embed'): if format == 'embed': - return 'a_{%s}'%n + return 'a_{%s}' % n elif format == 'analytic_embed': if self.weight == 1: return 'a_{%s}' % n elif self.weight == 3: return 'a_{%s}/%s' % (n, n) else: - return r'\frac{a_{%s}}{%s^{%s}}'%(n, n, (ZZ(self.weight)-1)/2) + return r'\frac{a_{%s}}{%s^{%s}}' % (n, n, (ZZ(self.weight)-1)/2) elif format == 'satake': return r'\alpha_{%s}' % n else: @@ -1243,11 +1243,11 @@ def embed_header(self, n, format='embed'): def conrey_from_embedding(self, m): # Given an embedding number, return the Conrey label for the restriction of that embedding to the cyclotomic field - return "{c}.{e}".format(c=self.cc_data[m]['conrey_index'], e=((m-1)%self.rel_dim)+1) + return "{c}.{e}".format(c=self.cc_data[m]['conrey_index'], e=((m-1) % self.rel_dim)+1) def embedded_mf_link(self, m): # Given an embedding number, return the Conrey label for the restriction of that embedding to the cyclotomic field - return '/ModularForm/GL2/Q/holomorphic/' + self.label.replace('.','/') + "/{c}/{e}/".format(c=self.cc_data[m]['conrey_index'], e=((m-1)%self.rel_dim)+1) + return '/ModularForm/GL2/Q/holomorphic/' + self.label.replace('.','/') + "/{c}/{e}/".format(c=self.cc_data[m]['conrey_index'], e=((m-1) % self.rel_dim)+1) def embedding_from_embedding_label(self, elabel): if not isinstance(elabel, str): # match object @@ -1258,7 +1258,7 @@ def embedding_from_embedding_label(self, elabel): return str(self.rel_dim * self.conrey_orbit.index(c) + e) def embedded_title(self, m): - return "Embedded newform %s.%s"%(self.label, self.conrey_from_embedding(m)) + return "Embedded newform %s.%s" % (self.label, self.conrey_from_embedding(m)) def _display_re(self, x, prec, method='round', extra_truncation_digits=3): res = display_float(x, prec, @@ -1279,7 +1279,7 @@ def _display_im(self, y, prec, method='round', extra_truncation_digits=3): return "" elif res == "1": res = "" - return r"%si"%(res) + return r"%si" % (res) def _display_op(self, x, y, prec, extra_truncation_digits=3): xiszero = abs(x) < 10**(-prec + extra_truncation_digits) @@ -1373,11 +1373,11 @@ def satake_angle(self, m, p, i, prec=6): s = display_float(2*theta, prec, method='round') if s == "1": s = r'\pi' - elif s== "-1": + elif s == "-1": s = r'-\pi' elif s != "0": s += r'\pi' - return r'\(%s\)'%s + return r'\(%s\)' % s @cached_method def _get_alpha(self, m, p, i): diff --git a/lmfdb/classical_modular_forms/web_space.py b/lmfdb/classical_modular_forms/web_space.py index 80434e0140..9afb5e9c94 100644 --- a/lmfdb/classical_modular_forms/web_space.py +++ b/lmfdb/classical_modular_forms/web_space.py @@ -47,9 +47,9 @@ def get_dim_bread(): return get_bread(other='Dimension table') def newform_search_link(text, title=None, **kwd): - query = '&'.join('%s=%s'%(key, val) for key, val in kwd.items()) - link = "%s?%s"%(url_for('.index'), query) - return "%s"%(link, "" if title is None else " title='%s'"%title, text) + query = '&'.join('%s=%s' % (key, val) for key, val in kwd.items()) + link = "%s?%s" % (url_for('.index'), query) + return "%s" % (link, "" if title is None else " title='%s'" % title, text) def cyc_display(m, d, real_sub): r""" @@ -87,9 +87,9 @@ def sign_char(x): return "-" if x else "+" def url_sign_char(x): return "-" if x else "%2B" primes = ZZ(level).prime_divisors() num_primes = len(primes) - header = [r""%p for p in primes] + header = [r"" % p for p in primes] if num_primes > 1: - header.append(r""%(display_knowl('cmf.fricke', title='Fricke').replace('"',"'"))) + header.append(r"" % (display_knowl('cmf.fricke', title='Fricke').replace('"',"'"))) header.append('') rows = [] fricke = [0,0] @@ -98,13 +98,13 @@ def url_sign_char(x): return "-" if x else "%2B" continue b = list(reversed(ZZ(i).bits())) b = [0 for j in range(num_primes-len(b))] + b - row = [r""%sign_char(x) for x in b] + row = [r"" % sign_char(x) for x in b] sign = sum(b) % 2 if num_primes > 1: - row.append(r""%sign_char(sign)) + row.append(r"" % sign_char(sign)) query = {'level':level, 'weight':weight, 'char_order':1, 'atkin_lehner_string':"".join(map(url_sign_char,b))} - link = newform_search_link(r'\(%s\)'%dim, **query) - row.append(r''%(link)) + link = newform_search_link(r'\(%s\)' % dim, **query) + row.append(r'' % (link)) fricke[sign] += dim if i == len(al_dims) - 1 and num_primes > 1: tr = "" @@ -113,11 +113,11 @@ def url_sign_char(x): return "-" if x else "%2B" rows.append(tr + ''.join(row) + '') if num_primes > 1: plus_knowl = display_knowl('cmf.plus_space',title='Plus space').replace('"',"'") - plus_link = newform_search_link(r'\(%s\)'%fricke[0], level=level, weight=weight, char_order=1, fricke_eigenval=1) + plus_link = newform_search_link(r'\(%s\)' % fricke[0], level=level, weight=weight, char_order=1, fricke_eigenval=1) minus_knowl = display_knowl('cmf.minus_space',title='Minus space').replace('"',"'") - minus_link = newform_search_link(r'\(%s\)'%fricke[1], level=level, weight=weight, char_order=1, fricke_eigenval=-1) - rows.append(r""%(num_primes, plus_knowl, plus_link)) - rows.append(r""%(num_primes, minus_knowl, minus_link)) + minus_link = newform_search_link(r'\(%s\)' % fricke[1], level=level, weight=weight, char_order=1, fricke_eigenval=-1) + rows.append(r"" % (num_primes, plus_knowl, plus_link)) + rows.append(r"" % (num_primes, minus_knowl, minus_link)) return ("
        By %s
        By %s
\(%s\)\(%s\)%s%sDim\(%s\)\(%s\)\(%s\)\(%s\)%s%s
%s\(+\)%s
%s\(-\)%s
%s\(+\)%s
%s\(-\)%s
%s%s
" % (''.join(header), ''.join(rows))) @@ -135,7 +135,7 @@ def common_latex(level, weight, conrey=None, S="S", t=0, typ="", symbolic_chi=Fa #char = r", [\chi_{{{level}}}({conrey}, \cdot)]".format(level=level, conrey=conrey) char = r", [\chi]" if typ: - typ = r"^{\mathrm{%s}}"%(typ) + typ = r"^{\mathrm{%s}}" % (typ) if char: ans = r"{S}_{{{k}}}{typ}({N}{char})" else: @@ -230,7 +230,7 @@ def new_lambda(r,s,p): if s == 1: return p-3 return (p-2)*(p-1)*p**(s-2) - if (r%2) != 0: + if (r % 2) != 0: return 0 return p-2 if r == 2 else (p-1)**2 * p**(r/2 - 2) @@ -239,7 +239,7 @@ def QDimensionNewEisensteinForms(chi, k): # The Q-dimension of the new subspace of E_k(N,chi), the space of Eisenstein series of weight k, level N, and character chi, where N is the modulus of chi. from sage.all import prod assert k > 0, "The weight k must be a positive integer" - if ((k%2) == 1) == chi['is_even']: + if ((k % 2) == 1) == chi['is_even']: return 0 N = ZZ(chi['modulus']) M = ZZ(chi['conductor']) @@ -250,7 +250,7 @@ def QDimensionNewEisensteinForms(chi, k): D += 1 # As noted by Buzzard, to handle the weight 1 case, one simply divides by 2 if k == 1: - assert (D%2) == 0 + assert (D % 2) == 0 D /= 2 return D*chi['degree'] @@ -329,12 +329,12 @@ def __init__(self, data): self.properties = [('Label',self.label)] if self.plot is not None and self.dim > 0: self.properties += [(None, ''.format(self.plot))] - self.properties +=[ + self.properties += [ ('Level', prop_int_pretty(self.level)), ('Weight', prop_int_pretty(self.weight)), ('Character orbit', '%s.%s' % (self.level, self.char_orbit_label)), ('Rep. character', '$%s$' % self.char_conrey_str), - ('Character field',r'$\Q%s$' % ('' if self.char_degree==1 else r'(\zeta_{%s})' % self.char_order)), + ('Character field',r'$\Q%s$' % ('' if self.char_degree == 1 else r'(\zeta_{%s})' % self.char_order)), ('Dimension', prop_int_pretty(self.dim)), ] if self.num_forms is not None: @@ -360,15 +360,15 @@ def __init__(self, data): self.trivial_character = True character_str = "trivial character" if self.dim == 0: - self.dim_str = r"\(%s\)"%(self.dim) + self.dim_str = r"\(%s\)" % (self.dim) else: self.minus_dim = self.dim - self.plus_dim - self.dim_str = r"\(%s + %s\)"%(self.plus_dim, self.minus_dim) + self.dim_str = r"\(%s + %s\)" % (self.plus_dim, self.minus_dim) else: self.trivial_character = False character_str = r"Character {level}.{orbit_label}".format(level=self.level, orbit_label=self.char_orbit_label) - self.dim_str = r"\(%s\)"%(self.dim) - self.title = r"Space of modular forms of level %s, weight %s, and %s"%(self.level, self.weight, character_str) + self.dim_str = r"\(%s\)" % (self.dim) + self.title = r"Space of modular forms of level %s, weight %s, and %s" % (self.level, self.weight, character_str) gamma1_link = '/ModularForm/GL2/Q/holomorphic/%d/%d' % (self.level, self.weight) self.friends = [('Newspace %d.%d' % (self.level, self.weight), gamma1_link)] @@ -506,7 +506,7 @@ def __init__(self, level, weight): space['level'] = level space['conrey_index'] = char['first'] space['char_orbit_label'] = char['label'].split('.')[-1] - space['label'] = "%s.%s.%s"%(level,weight,space['char_orbit_label']) + space['label'] = "%s.%s.%s" % (level,weight,space['char_orbit_label']) space['char_degree'] = char['degree'] space['dim'] = newspace_dims_by_label[char['label']] space['generate_link'] = (self.weight == 2) and (space['char_orbit_label'] != 'a') @@ -518,7 +518,7 @@ def __init__(self, level, weight): self.properties = [('Label',self.label),] if self.plot is not None and self.dim > 0: self.properties += [(None, ''.format(self.plot))] - self.properties +=[ + self.properties += [ ('Level',str(self.level)), ('Weight',str(self.weight)), ('Dimension',str(self.dim)) @@ -537,7 +537,7 @@ def __init__(self, level, weight): ('All stored data to text', url_for('cmf.download_full_space', label=self.label)), ('Underlying data', url_for('.mf_data', label=self.label)), ] - self.title = r"Space of modular forms of level %s and weight %s"%(self.level, self.weight) + self.title = r"Space of modular forms of level %s and weight %s" % (self.level, self.weight) self.friends = [] @staticmethod @@ -615,7 +615,7 @@ def decomposition(self): # returns a list of 6-tuples chi_rep, num_chi, space, firstform, firstdim, forms ans = [] for i, (space, forms) in enumerate(self.decomp): - rowtype = "oddrow" if i%2 else "evenrow" + rowtype = "oddrow" if i % 2 else "evenrow" chi_str = r"\chi_{%s}(%s, \cdot)" % (space['level'], space['conrey_index']) chi_rep = '1 else "{}".format(q) if n>0 else "" for q,n in zip(plist, exponents)] + factors = ["{}^{{{}}}".format(q,n) if n > 1 else "{}".format(q) if n > 0 else "" for q,n in zip(plist, exponents)] factors = [f for f in factors if f] # exclude any factors with exponent 0 - return r"\({}{}\)".format("-" if sign==-1 else "", r"\cdot".join(factors)) + return r"\({}{}\)".format("-" if sign == -1 else "", r"\cdot".join(factors)) def parse_point(K, s): r""" Returns a point in P^2(K) defined by the string s. s has the form @@ -171,9 +171,9 @@ def parse_point(K, s): return [K([QQ(ci.encode()) for ci in c.split(",")]) for c in cc] def inflate_interval(a,b,r): - c=(a+b)/2 - d=(b-a)/2 - d*=r + c = (a+b)/2 + d = (b-a)/2 + d *= r return (c-d,c+d) @@ -183,35 +183,35 @@ def plot_zone_union(R, S): # Finds a suitable plotting zone for the component a <= x <= b of the EC y**2+h(x)*y=f(x) def EC_R_plot_zone_piece(f,h,a,b): - npts=50 - Y=[] - g=f+h**2/4 - t=a - s=(b-a)/npts + npts = 50 + Y = [] + g = f+h**2/4 + t = a + s = (b-a)/npts for _ in range(npts+1): - y=g(t) - if y>0: - y=sqrt(y) - w=h(t)/2 + y = g(t) + if y > 0: + y = sqrt(y) + w = h(t)/2 Y.append(y-w) Y.append(-y-w) - t+=s - (ymin,ymax)=inflate_interval(min(Y),max(Y),1.2) - (a,b)=inflate_interval(a,b,1.3) + t += s + (ymin,ymax) = inflate_interval(min(Y),max(Y),1.2) + (a,b) = inflate_interval(a,b,1.3) return (a,b,ymin,ymax) # Finds a suitable plotting zone for the EC y**2+h(x)*y=f(x) def EC_R_plot_zone(f,h): - F=f+h**2/4 - F1=F.derivative() - F2=F1.derivative() - G=F*F2-F1**2/2 - ZF=[z[0] for z in F.roots()] - ZG=[z[0] for z in G.roots()] - xi=max(ZG) - if len(ZF)==1: + F = f+h**2/4 + F1 = F.derivative() + F2 = F1.derivative() + G = F*F2-F1**2/2 + ZF = [z[0] for z in F.roots()] + ZG = [z[0] for z in G.roots()] + xi = max(ZG) + if len(ZF) == 1: return EC_R_plot_zone_piece(f,h,ZF[0],2*xi-ZF[0]) - if len(ZF)==3: + if len(ZF) == 3: return plot_zone_union(EC_R_plot_zone_piece(f,h,ZF[0],ZF[1]),EC_R_plot_zone_piece(f,h,ZF[2],2*xi-ZF[2])) return EC_R_plot_zone_piece(f,h,ZF[0],2*ZF[1]-ZF[0]) @@ -222,17 +222,17 @@ def EC_R_plot(ainvs, xmin, xmax, ymin, ymax, colour, legend): d = (xmax - xmin) return implicit_plot(y ** 2 + ainvs[0] * x * y + ainvs[2] * y - x ** 3 - ainvs[1] * x ** 2 - ainvs[3] * x - ainvs[4], (x, xmin, xmax), (y, ymin, ymax), plot_points=500, aspect_ratio="automatic", color=colour) + plot(0, xmin=c - 1e-5 * d, xmax=c + 1e-5 * d, ymin=ymin, ymax=ymax, aspect_ratio="automatic", color=colour, legend_label=legend) # Add an extra plot outside the visible frame because implicit plots are buggy: their legend does not show (https://trac.sagemath.org/ticket/15903) -Rx=PolynomialRing(RDF,'x') +Rx = PolynomialRing(RDF,'x') def EC_nf_plot(K, ainvs, base_field_gen_name): try: n1 = K.signature()[0] if n1 == 0: return plot([]) - R=[] - S=K.embeddings(RDF) + R = [] + S = K.embeddings(RDF) for s in S: - A=[s(c) for c in ainvs] + A = [s(c) for c in ainvs] R.append(EC_R_plot_zone(Rx([A[4],A[3],A[1],1]),Rx([A[2],A[0]]))) xmin = min([r[0] for r in R]) xmax = max([r[1] for r in R]) @@ -240,19 +240,19 @@ def EC_nf_plot(K, ainvs, base_field_gen_name): ymax = max([r[3] for r in R]) cols = rainbow(n1) # Default choice of n colours # However, these tend to be too pale, so we preset them for small values of n - if n1==1: - cols=["blue"] - elif n1==2: - cols=["red","blue"] - elif n1==3: - cols=["red","limegreen","blue"] - elif n1==4: + if n1 == 1: + cols = ["blue"] + elif n1 == 2: + cols = ["red","blue"] + elif n1 == 3: + cols = ["red","limegreen","blue"] + elif n1 == 4: cols = ["red", "orange", "forestgreen", "blue"] - elif n1==5: + elif n1 == 5: cols = ["red", "orange", "forestgreen", "blue", "darkviolet"] - elif n1==6: + elif n1 == 6: cols = ["red", "darkorange", "gold", "forestgreen", "blue", "darkviolet"] - elif n1==7: + elif n1 == 7: cols = ["red", "darkorange", "gold", "forestgreen", "blue", "darkviolet", "fuchsia"] return sum([EC_R_plot([S[i](c) for c in ainvs], xmin, xmax, ymin, ymax, cols[i], "$" + base_field_gen_name + r" \mapsto$ " + str(S[i].im_gens()[0].n(20)) + r"$\dots$") for i in range(n1)]) except Exception: @@ -394,7 +394,7 @@ def make_E(self): Dnorm_factor = local_data[ip]['normp']**12 self.disc_norm = web_latex(Dnorm) - signDnorm = 1 if Dnorm>0 else -1 + signDnorm = 1 if Dnorm > 0 else -1 if Dnorm in [1, -1]: # since the factorization of (1) displays as "1" self.fact_disc = self.disc self.fact_disc_norm = str(Dnorm) @@ -449,7 +449,7 @@ def make_E(self): # CM and End(E) self.cm_bool = "no" self.End = r"\(\Z\)" - self.rational_cm = self.cm_type>0 + self.rational_cm = self.cm_type > 0 if self.cm: self.cm_sqf = integer_squarefree_part(ZZ(self.cm)) self.cm_bool = r"yes (\(%s\))" % self.cm @@ -463,7 +463,7 @@ def make_E(self): if self.cm and self.galois_images != '?': self.cm_ramp = [p for p in ZZ(self.cm).support() if p not in self.nonmax_primes] self.cm_nramp = len(self.cm_ramp) - if self.cm_nramp==1: + if self.cm_nramp == 1: self.cm_ramp = self.cm_ramp[0] else: self.cm_ramp = ", ".join(str(p) for p in self.cm_ramp) @@ -540,13 +540,13 @@ def make_E(self): # for debugging: assert self.rk == "not available" or (self.rk_lb == self.rank and self.rank == self.rk_ub) - assert self.ar=="not available" or (self.rk_lb<=self.analytic_rank and self.analytic_rank<=self.rk_ub) + assert self.ar == "not available" or (self.rk_lb <= self.analytic_rank and self.analytic_rank <= self.rk_ub) self.bsd_status = "incomplete" if self.analytic_rank is not None: - if self.rk_lb==self.rk_ub: + if self.rk_lb == self.rk_ub: self.bsd_status = "unconditional" - elif self.rk_lb==self.analytic_rank: + elif self.rk_lb == self.analytic_rank: self.bsd_status = "conditional" else: self.bsd_status = "missing_gens" @@ -588,8 +588,8 @@ def make_E(self): # Tamagawa product tamagawa_numbers = [ZZ(_ld['cp']) for _ld in self.local_data] cp_fac = [cp.factor() for cp in tamagawa_numbers] - cp_fac = [latex(cp) if len(cp)<2 else '('+latex(cp)+')' for cp in cp_fac] - if len(cp_fac)>1: + cp_fac = [latex(cp) if len(cp) < 2 else '('+latex(cp)+')' for cp in cp_fac] + if len(cp_fac) > 1: self.tamagawa_factors = r'\cdot'.join(cp_fac) else: self.tamagawa_factors = None @@ -629,8 +629,8 @@ def latex_kod(kod): # Isogeny information self.one_deg = ZZ(self.class_deg).is_prime() - isodegs = [str(d) for d in self.isodeg if d>1] - if len(isodegs)<3: + isodegs = [str(d) for d in self.isodeg if d > 1] + if len(isodegs) < 3: self.isodeg = " and ".join(isodegs) else: self.isodeg = " and ".join([", ".join(isodegs[:-1]), isodegs[-1]]) @@ -764,7 +764,7 @@ def latex_kod(kod): Lfun['Lhash'], Lfun['degree'], Lfun.get('trace_hash')) - exclude={elt[1].rstrip('/').lstrip('/') for elt in self.friends + exclude = {elt[1].rstrip('/').lstrip('/') for elt in self.friends if elt[1]} self.friends += names_and_urls(instances, exclude=exclude) self.friends += [('L-function', self.urls['Lfunction'])] @@ -810,7 +810,7 @@ def make_code(label, lang=None): language (if lang is 'pari' or 'gp', 'sage', or 'magma') or all three (if lang is None). """ - if lang=='gp': + if lang == 'gp': lang = 'pari' all_langs = ['magma', 'pari', 'sage'] diff --git a/lmfdb/ecnf/ecnf_stats.py b/lmfdb/ecnf/ecnf_stats.py index 7353d257e3..6f8350e013 100644 --- a/lmfdb/ecnf/ecnf_stats.py +++ b/lmfdb/ecnf/ecnf_stats.py @@ -212,11 +212,11 @@ def field_summary(self, field): ncurves = stats['ncurves'] nclasses = stats['nclasses'] max_norm = stats['max_norm'] - ec_knowl = self.ec_knowl if ncurves==1 else self.ec_knowls - iso_knowl = self.iso_knowl if ncurves==1 else self.iso_knowls - nf_knowl = self.nf_knowl if ncurves==1 else self.nf_knowls - cond_knowl = self.cond_knowl if ncurves==1 else self.cond_knowls - s = '' if max_norm==1 else 'up to ' + ec_knowl = self.ec_knowl if ncurves == 1 else self.ec_knowls + iso_knowl = self.iso_knowl if ncurves == 1 else self.iso_knowls + nf_knowl = self.nf_knowl if ncurves == 1 else self.nf_knowls + cond_knowl = self.cond_knowl if ncurves == 1 else self.cond_knowls + s = '' if max_norm == 1 else 'up to ' norm_phrase = ' of norm {}{}.'.format(s, max_norm) return ''.join([r'The database currently contains {} '.format(ncurves), ec_knowl, diff --git a/lmfdb/ecnf/ecnf_test_pages.py b/lmfdb/ecnf/ecnf_test_pages.py index 462ae39f55..b70e052f5d 100644 --- a/lmfdb/ecnf/ecnf_test_pages.py +++ b/lmfdb/ecnf/ecnf_test_pages.py @@ -12,9 +12,9 @@ def test_d6_pages(self): # check the page of every elliptic curve over a degree 6 field errors = [] n = db.ec_nfcurves.count({'degree':6}) - print("Checking %d elliptic curves over number fields of degree 6"%(n)) + print("Checking %d elliptic curves over number fields of degree 6" % (n)) for e in db.ec_nfcurves.search({'degree':6}): - url = "EllipticCurve/%s/%d"%("/".join(e['class_label'].split("-")),e['number']) + url = "EllipticCurve/%s/%d" % ("/".join(e['class_label'].split("-")),e['number']) print("Checking " + url) page = self.tc.get(url, follow_redirects=True) if e['label'] not in page.get_data(as_text=True) or 'Weierstrass equation' not in page.get_data(as_text=True): diff --git a/lmfdb/ecnf/isog_class.py b/lmfdb/ecnf/isog_class.py index 21ccdbd082..bdec254d3c 100644 --- a/lmfdb/ecnf/isog_class.py +++ b/lmfdb/ecnf/isog_class.py @@ -143,7 +143,7 @@ def make_class(self): Lfun['Lhash'], Lfun['degree'], Lfun.get('trace_hash')) - exclude={elt[1].rstrip('/').lstrip('/') for elt in self.friends + exclude = {elt[1].rstrip('/').lstrip('/') for elt in self.friends if elt[1]} exclude.add(lfun_url.lstrip('/L/').rstrip('/')) self.friends += names_and_urls(instances, exclude=exclude) @@ -203,7 +203,7 @@ def make_graph(M): centervert = [i for i in range(4) if max(MM.row(i)) < maxdegree][0] other = [i for i in range(4) if i != centervert] G.set_pos(pos={centervert: [0, 0], other[0]: [0, 1], other[1]: [-0.8660254, -0.5], other[2]: [0.8660254, -0.5]}) - elif maxdegree == 27 and n==4: + elif maxdegree == 27 and n == 4: # o--o--o--o centers = [i for i in range(4) if list(MM.row(i)).count(3) == 2] left = [j for j in range(4) if MM[centers[0], j] == 3 and j not in centers][0] @@ -220,14 +220,14 @@ def make_graph(M): left = [j for j in range(6) if MM[centers[0], j] == 2 and j not in centers] right = [j for j in range(6) if MM[centers[1], j] == 2 and j not in centers] G.set_pos(pos={centers[0]: [-0.5, 0], left[0]: [-1, 0.8660254], left[1]: [-1, -0.8660254], centers[1]: [0.5, 0], right[0]: [1, 0.8660254], right[1]: [1, -0.8660254]}) - elif maxdegree == 18 and n==6: + elif maxdegree == 18 and n == 6: # two squares joined on an edge centers = [i for i in range(6) if list(MM.row(i)).count(3) == 2] top = [j for j in range(6) if MM[centers[0], j] == 3] bl = [j for j in range(6) if MM[top[0], j] == 2][0] br = [j for j in range(6) if MM[top[1], j] == 2][0] G.set_pos(pos={centers[0]: [0, 0.5], centers[1]: [0, -0.5], top[0]: [-1, 0.5], top[1]: [1, 0.5], bl: [-1, -0.5], br: [1, -0.5]}) - elif maxdegree == 16 and n==8: + elif maxdegree == 16 and n == 8: # tree from bottom, 3 regular except for the leaves. centers = [i for i in range(8) if list(MM.row(i)).count(2) == 3] center = [i for i in centers if len([j for j in centers if MM[i, j] == 2]) == 2][0] diff --git a/lmfdb/ecnf/main.py b/lmfdb/ecnf/main.py index 44e55c3a2b..c6a3ee979a 100644 --- a/lmfdb/ecnf/main.py +++ b/lmfdb/ecnf/main.py @@ -301,7 +301,7 @@ def show_ecnf(nf, conductor_label, class_label, number): friends=ec.friends, downloads=ec.downloads, info=info, - KNOWL_ID="ec.%s"%label, + KNOWL_ID ="ec.%s" % label, learnmore=learnmore_list()) @ecnf_page.route("/data/
%s home page
' % (str(url_for("modcurve.by_label", label=data['label'])),data['label']) @@ -208,8 +208,8 @@ def latex_equation(ainvs): '+xy' if a1 else '', '+y' if a3 else '', '=x^3', - '+x^2' if a2==1 else '-x^2' if a2==-1 else '', - '{:+}x'.format(a4) if abs(a4)>1 else '+x' if a4==1 else '-x' if a4==-1 else '', + '+x^2' if a2 == 1 else '-x^2' if a2 == -1 else '', + '{:+}x'.format(a4) if abs(a4) > 1 else '+x' if a4 == 1 else '-x' if a4 == -1 else '', '{:+}'.format(a6) if a6 else '', r'\)']) @@ -219,9 +219,9 @@ def homogeneous_latex_equation(ainvs): '+xyz' if a1 else '', '+yz^2' if a3 else '', '=x^3', - '+x^2z' if a2==1 else '-x^2z' if a2==-1 else '', - '{:+}xz^2'.format(a4) if abs(a4)>1 else '+xz^2' if a4==1 else '-xz^2' if a4==-1 else '', - '{:+}z^3'.format(a6) if abs(a6)>1 else '+z^3' if a6==1 else '-z^3' if a6==-1 else '', + '+x^2z' if a2 == 1 else '-x^2z' if a2 == -1 else '', + '{:+}xz^2'.format(a4) if abs(a4) > 1 else '+xz^2' if a4 == 1 else '-xz^2' if a4 == -1 else '', + '{:+}z^3'.format(a6) if abs(a6) > 1 else '+z^3' if a6 == 1 else '-z^3' if a6 == -1 else '', r'\)']) def short_latex_equation(ainvs): @@ -233,7 +233,7 @@ def short_latex_equation(ainvs): A = A.divide_knowing_divisible_by(p**4) B = B.divide_knowing_divisible_by(p**6) return ''.join([r'\(y^2=x^3', - '{:+}x'.format(A) if abs(A)>1 else '+x' if A==1 else '-x' if A==-1 else '', + '{:+}x'.format(A) if abs(A) > 1 else '+x' if A == 1 else '-x' if A == -1 else '', '{:+}'.format(B) if B else '', r'\)']) @@ -251,7 +251,7 @@ def sextic_twist_discriminant(ainvs): # because the text says that 27.a4 is this curve's sextic twist by # D, not the other way round. - return D.sign() * prod(p ** ((-e)%6) for p,e in D.factor()) + return D.sign() * prod(p ** ((-e) % 6) for p,e in D.factor()) def quartic_twist_discriminant(ainvs): r""" @@ -264,7 +264,7 @@ def quartic_twist_discriminant(ainvs): # because the text says that 32.a3 is this curve's quartic twist # by D, not the other way round. - return D.sign() * prod(p ** ((-e)%4) for p,e in D.factor()) + return D.sign() * prod(p ** ((-e) % 4) for p,e in D.factor()) class WebEC(): """ @@ -336,7 +336,7 @@ def make_curve(self): Dfac = Factorization([(ZZ(ld['prime']),ld['discriminant_valuation']) for ld in local_data], unit=ZZ(self.signD)) data['disc_factor'] = latex(Dfac) data['disc'] = D = Dfac.value() - data['cond_factor'] =latex(Nfac) + data['cond_factor'] = latex(Nfac) data['disc_latex'] = web_latex(D) data['cond_latex'] = web_latex(N) @@ -363,7 +363,7 @@ def red(p): data['minq_D'] = minqD = self.min_quad_twist_disc data['minq_label'] = db.ec_curvedata.lucky({'ainvs': self.min_quad_twist_ainvs}, projection='lmfdb_label' if self.label_type == 'LMFDB' else 'Clabel') - data['minq_info'] = '(itself)' if minqD==1 else '(by {})'.format(minqD) + data['minq_info'] = '(itself)' if minqD == 1 else '(by {})'.format(minqD) data['minq_url'] = url_for(".by_ec_label", label=data["minq_label"]) # higher minimal twists: @@ -420,7 +420,7 @@ def red(p): if self.cm: data['cm_ramp'] = [p for p in ZZ(self.cm).support() if p not in self.nonmax_primes] data['cm_nramp'] = len(data['cm_ramp']) - if data['cm_nramp']==1: + if data['cm_nramp'] == 1: data['cm_ramp'] = data['cm_ramp'][0] else: data['cm_ramp'] = ", ".join(str(p) for p in data['cm_ramp']) @@ -440,8 +440,8 @@ def red(p): cond, iso, num = split_lmfdb_label(lmfdb_label) self.class_deg = classdata['class_deg'] self.one_deg = ZZ(self.class_deg).is_prime() - isodegs = [str(d) for d in self.isogeny_degrees if d>1] - if len(isodegs)<3: + isodegs = [str(d) for d in self.isogeny_degrees if d > 1] + if len(isodegs) < 3: data['isogeny_degrees'] = " and ".join(isodegs) else: data['isogeny_degrees'] = " and ".join([", ".join(isodegs[:-1]),isodegs[-1]]) @@ -469,38 +469,38 @@ def red(p): data['optimality_bound'] = OPTIMALITY_BOUND self.cremona_bound = CREMONA_BOUND - if N 1: cp_fac = [ZZ(cp).factor() for cp in tamagawa_numbers] - cp_fac = [latex(cp) if len(cp)<2 else '('+latex(cp)+')' for cp in cp_fac] + cp_fac = [latex(cp) if len(cp) < 2 else '('+latex(cp)+')' for cp in cp_fac] mwbsd['tamagawa_factors'] = r'\cdot'.join(cp_fac) else: mwbsd['tamagawa_factors'] = None @@ -628,7 +628,7 @@ def make_mwbsd(self): mwbsd['reg'] = self.regulator mwbsd['sha'] = self.sha mwbsd['sha2'] = latex_sha(self.sha) - mwbsd['sha_is_exact'] = self.rank==0 # see Issue #5872 + mwbsd['sha_is_exact'] = self.rank == 0 # see Issue #5872 for num in ['reg', 'special_value', 'real_period', 'area']: mwbsd[num] = RR(mwbsd[num]) except AttributeError: @@ -637,7 +637,7 @@ def make_mwbsd(self): mwbsd['sha'] = '?' mwbsd['sha2'] = '?' mwbsd['regsha'] = ( mwbsd['special_value'] * self.torsion**2 ) / ( mwbsd['tamagawa_product'] * mwbsd['real_period'] ) - if r<=1: + if r <= 1: mwbsd['rank'] = r # Integral points @@ -720,7 +720,7 @@ def make_iwasawa(self): pdata = iwdata[p] if isinstance(pdata, str): if not rtype: - if pdata=="o?": + if pdata == "o?": rtype = "ord" rtknowl = "ec.good_ordinary_reduction" else: @@ -733,7 +733,7 @@ def make_iwasawa(self): iw['data'] += [[p, rtype, "?", "?", rtknowl]] iw['missing_flag'] = True else: - if len(pdata)==2: + if len(pdata) == 2: if not rtype: rtype = "ord" rtknowl = "ec.good_ordinary_reduction" @@ -775,7 +775,7 @@ def make_torsion_growth(self): tg['fields_missing'] = True T = tgd['torsion'] tg1['t'] = r'\(' + r' \oplus '.join(r'\Z/{}\Z'.format(n) for n in T) + r'\)' - bcc = next((lab for lab, pol in zip(bcs, bc_pols) if pol==F), None) + bcc = next((lab for lab, pol in zip(bcs, bc_pols) if pol == F), None) if bcc: from lmfdb.ecnf.main import split_full_label F, NN, I, C = split_full_label(bcc) @@ -789,8 +789,8 @@ def make_torsion_growth(self): lastd = 1 for tg1 in tgextra: d = tg1['d'] - if d!=lastd: - tg1['m'] = len([x for x in tgextra if x['d']==d]) + if d != lastd: + tg1['m'] = len([x for x in tgextra if x['d'] == d]) lastd = d ## Hard-coded this for now. Note that the *only* place where diff --git a/lmfdb/galois_groups/main.py b/lmfdb/galois_groups/main.py index ea5376bb52..2d4aa5c7a0 100644 --- a/lmfdb/galois_groups/main.py +++ b/lmfdb/galois_groups/main.py @@ -131,7 +131,7 @@ def modify_query(self, info, query): # For the search order-parsing def make_order_key(order): order1 = int(ZZ(order).log(10)) - return '%03d%s'%(order1,str(order)) + return '%03d%s' % (order1,str(order)) gg_columns = SearchColumns([ LinkCol("label", "gg.label", "Label", url_for_label), @@ -269,7 +269,7 @@ def render_group_webpage(args): data['chartable'] = chartable(n, t) else: data['chartable_knowl'] = character_table_display_knowl(n,t, - name="%d x %d character table"%(wgg.num_conjclasses(),wgg.num_conjclasses())) + name="%d x %d character table" % (wgg.num_conjclasses(),wgg.num_conjclasses())) data['gens'] = wgg.generator_string() if n == 1 and t == 1: data['gens'] = 'None needed' @@ -281,9 +281,9 @@ def render_group_webpage(args): data['groupid'] = abstract_group_display_knowl(gp_label, gp_label) data['otherreps'] = wgg.otherrep_list() ae = data['arith_equiv'] - if ae>0: - if ae>1: - data['arith_equiv'] = r'A number field with this Galois group has %d arithmetically equivalent fields.'% ae + if ae > 0: + if ae > 1: + data['arith_equiv'] = r'A number field with this Galois group has %d arithmetically equivalent fields.' % ae else: data['arith_equiv'] = r'A number field with this Galois group has exactly one arithmetically equivalent field.' elif ae > -1: @@ -294,7 +294,7 @@ def render_group_webpage(args): if intreps: data['int_rep_classes'] = [str(z[0]) for z in intreps[0]['gens']] for onerep in intreps: - onerep['gens']=[list_to_latex_matrix(z[1]) for z in onerep['gens']] + onerep['gens'] = [list_to_latex_matrix(z[1]) for z in onerep['gens']] data['int_reps'] = intreps data['int_reps_complete'] = int_reps_are_complete(intreps) dcq = data['moddecompuniq'] @@ -322,7 +322,7 @@ def render_group_webpage(args): ('$p$-group', yesno(pgroup)), ] pretty = group_display_short(n,t, emptyifnotpretty=True) - if len(pretty)>0: + if len(pretty) > 0: prop2.extend([('Group:', pretty)]) data['pretty_name'] = pretty data['name'] = re.sub(r'_(\d+)',r'_{\1}',data['name']) @@ -348,7 +348,7 @@ def render_group_webpage(args): properties=prop2, friends=friends, downloads=downloads, - KNOWL_ID="gg.%s"%label, + KNOWL_ID ="gg.%s" % label, learnmore=learnmore_list()) @galois_groups_page.route('/