Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix pep E225 and E228 #6194

Merged
merged 1 commit into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lmfdb/abvar/fq/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 2 additions & 2 deletions lmfdb/abvar/fq/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions lmfdb/api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']:
Expand Down Expand Up @@ -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]
Expand Down
6 changes: 3 additions & 3 deletions lmfdb/api2/api2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion lmfdb/api2/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']))
Expand Down
16 changes: 8 additions & 8 deletions lmfdb/artin_representations/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ],
Expand Down Expand Up @@ -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<len(dihedrals):
if 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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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"])))
Expand All @@ -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(
Expand Down
24 changes: 12 additions & 12 deletions lmfdb/bianchi_modular_forms/bianchi_modular_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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))]
Expand Down Expand Up @@ -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'

Expand Down Expand Up @@ -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,
)


Expand Down
12 changes: 6 additions & 6 deletions lmfdb/bianchi_modular_forms/web_BMF.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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),
Expand All @@ -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),
Expand All @@ -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:
Expand All @@ -224,15 +224,15 @@ 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:
self.bc = 'no'
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'})\)'
Expand Down
4 changes: 2 additions & 2 deletions lmfdb/characters/HeckeCharacters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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) ]
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions lmfdb/characters/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions lmfdb/characters/test_characters.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def test_order(self):

def test_even_odd(self):
W = self.tc.get('/Character/Dirichlet/?modulus=35')
assert '>%s</t'%(parity_string(1)) in W.get_data(as_text=True)
assert '>%s</t'%(parity_string(-1)) in W.get_data(as_text=True)
assert '>%s</t' % (parity_string(1)) in W.get_data(as_text=True)
assert '>%s</t' % (parity_string(-1)) in W.get_data(as_text=True)

def test_modbrowse(self):
W = self.tc.get('/Character/Dirichlet/?modbrowse=41-60')
Expand Down Expand Up @@ -61,8 +61,8 @@ def test_nextprev(self):
class DirichletTableTest(LmfdbTest):

def test_table(self):
get= r'modulus=35&poly=x%5E6+-+x%5E5+-+7%2Ax%5E4+%2B+2%2Ax%5E3+%2B+7%2Ax%5E2+-+2%2Ax+-+1&char_number_list=1%2C4%2C9%2C11%2C16%2C29'
W = self.tc.get('/Character/Dirichlet/grouptable?%s'%get)
get = r'modulus=35&poly=x%5E6+-+x%5E5+-+7%2Ax%5E4+%2B+2%2Ax%5E3+%2B+7%2Ax%5E2+-+2%2Ax+-+1&char_number_list=1%2C4%2C9%2C11%2C16%2C29'
W = self.tc.get('/Character/Dirichlet/grouptable?%s' % get)
assert '35 }(29' in W.get_data(as_text=True)

class DirichletCharactersTest(LmfdbTest):
Expand Down
2 changes: 1 addition & 1 deletion lmfdb/characters/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def evalpolelt(label,gen,genlabel='a'):
( '*' and '**' are removed )
"""
res = 0
regexp = r'([+-]?)([+-]?\d*o?\d*)(%s\d*)?'%genlabel
regexp = r'([+-]?)([+-]?\d*o?\d*)(%s\d*)?' % genlabel
for m in re.finditer(regexp,label):
s, c, e = m.groups()
if c == '' and e is None:
Expand Down
Loading
Loading