Skip to content

Commit 2b34a39

Browse files
authored
Merge pull request #6283 from fchapoton/some_ruff_fixes
some autofixes by ruff about using max + one missing raise
2 parents 3d51d84 + 4097d26 commit 2b34a39

File tree

13 files changed

+25
-49
lines changed

13 files changed

+25
-49
lines changed

lmfdb/abvar/fq/isog_class.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def newton_plot(self):
178178
L += line([(i, 0), (i, ymax)], color="grey", thickness=0.5)
179179
for j in range(ymax+1):
180180
L += line([(0, j), (xmax, j)], color="grey", thickness=0.5)
181-
L+=line(pts,thickness=2)
181+
L += line(pts, thickness=2)
182182
for v in pts:
183183
L += circle(v, 0.06, fill=True)
184184
L.axes(False)

lmfdb/belyi/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ def primitivization_search(info, query, search_type):
713713
re_str = PASSPORT_RE
714714
err_name = "passport"
715715
else:
716-
ValueError("Invalid search type")
716+
raise ValueError("invalid search type")
717717
if info.get("primitivization"):
718718
primitivization = info["primitivization"]
719719
if re.match(re_str, primitivization):

lmfdb/elliptic_curves/elliptic_curve.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -745,10 +745,8 @@ def modular_form_display(label, number):
745745
number = int(number)
746746
except ValueError:
747747
number = 10
748-
if number < 10:
749-
number = 10
750-
if number > 1000:
751-
number = 1000
748+
number = max(number, 10)
749+
number = min(number, 1000)
752750
ainvs = db.ec_curvedata.lookup(label, 'ainvs', 'lmfdb_label')
753751
if ainvs is None:
754752
return elliptic_curve_jump_error(label, {})

lmfdb/galois_groups/transitive_group.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def characters(self):
192192

193193
@lazy_attribute
194194
def conjclasses(self):
195-
if self.num_conjclasses()>CC_LIMIT:
195+
if self.num_conjclasses() > CC_LIMIT:
196196
return None
197197
g = self.gapgroupnt()
198198
n = self.n()
@@ -488,7 +488,7 @@ def group_cclasses_knowl_guts(n, t):
488488
rest += "<p><a title='Malle's constant $a(G)$' knowl='gg.malle_a'>'Malle's constant $a(G)$</a>: &nbsp; &nbsp;"
489489
wgg = WebGaloisGroup(label)
490490
if wgg.malle_a:
491-
rest += '$%s$'%str(wgg.malle_a)
491+
rest += '$%s$' % str(wgg.malle_a)
492492
else:
493493
rest += 'not computed'
494494
return rest

lmfdb/lattice/main.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,7 @@ def theta_display(label, number):
362362
number = 20
363363
if number < 20:
364364
number = 30
365-
if number > 150:
366-
number = 150
365+
number = min(number, 150)
367366
data = db.lat_lattices.lookup(label, projection=['theta_series'])
368367
coeff = [data['theta_series'][i] for i in range(number+1)]
369368
return print_q_expansion(coeff)

lmfdb/lfunctions/LfunctionPlot.py

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,8 @@ def getWidthAndHeight(gls):
234234
for origin in db.lfunc_lfunctions.search({'group': gls[0], 'conductor': gls[1]}, 'origin'):
235235
splitId = origin.split('/')[6].split('_')
236236

237-
if float(splitId[0]) > xMax:
238-
xMax = float(splitId[0])
239-
if float(splitId[1]) > yMax:
240-
yMax = float(splitId[1])
237+
xMax = max(float(splitId[0]), xMax)
238+
yMax = max(float(splitId[1]), yMax)
241239

242240
xMax = math.ceil(xMax)
243241
yMax = math.ceil(yMax)
@@ -277,10 +275,8 @@ def paintSvgFileAll(glslist): # list of group and level
277275
splitId = R.split('_')
278276
paralist.append((splitId[0], splitId[1], l['origin'], group, level,
279277
char, R, ap_id, l['root_number']))
280-
if float(splitId[0]) > xMax:
281-
xMax = float(splitId[0])
282-
if float(splitId[1]) > yMax:
283-
yMax = float(splitId[1])
278+
xMax = max(float(splitId[0]), xMax)
279+
yMax = max(float(splitId[1]), yMax)
284280

285281
xMax = int(math.ceil(xMax))
286282
yMax = int(math.ceil(yMax))
@@ -492,8 +488,7 @@ def colorsForWeights(num_weights):
492488
projection=['analytic_conductor', 'label', 'level', 'weight', 'conrey_index', 'dim', 'char_degree'],
493489
sort=[('analytic_conductor', 1)]):
494490
_, k, _, hecke_letter = nf['label'].split('.')
495-
if int(k) > max_k:
496-
max_k = int(k)
491+
max_k = max(int(k), max_k)
497492
if nf['weight'] not in values:
498493
values[nf['weight']] = []
499494
if nf['dim'] == 1:
@@ -522,10 +517,8 @@ def colorsForWeights(num_weights):
522517
k = label[1]
523518
x = x_scale*float(Nk2)
524519
y = y_scale*z1
525-
if y > y_max:
526-
y_max = y
527-
if x > x_max:
528-
x_max = x
520+
y_max = max(y, y_max)
521+
x_max = max(x, x_max)
529522
points.append((x, y, lfun_url, ".".join(map(str, label)), k))
530523

531524
# Begin drawing
@@ -796,20 +789,17 @@ def paintSvgHoloGeneral(Nmin, Nmax, kmin, kmax, imagewidth, imageheight):
796789
dimensioninfo['dotradius'] = radius
797790
dimensioninfo['connectinglinewidth'] = dimensioninfo['dotradius'] / 1.5
798791
dimensioninfo['firstdotoffset'] = [0.0, 0.0]
799-
#
800792
appearanceinfo = {}
801793
# appearanceinfo['edgewidth'] = dimensioninfo['dotspacing'][0]/1.0 #just a guess
802794
appearanceinfo['edgewidth'] = [0, 0] # remove the sector edges
803795
appearanceinfo['edgestyle'] = 'stroke-dasharray:3,3'
804796
appearanceinfo['edgecolor'] = 'rgb(202,202,102)'
805797
appearanceinfo['fontsize'] = 'font-size:11px'
806798
appearanceinfo['fontweight'] = ""
807-
#
808799
urlinfo = {'base': '/L/ModularForm/GL2/Q/holomorphic?'}
809800
urlinfo['space'] = {'weight': y}
810801
urlinfo['space']['level'] = x
811802
urlinfo['space']['character'] = 0
812-
#
813803
# scale = 1 # not used
814804
# Symmetry types: +1 or -1
815805
symmetrytype = [1, -1]
@@ -879,7 +869,6 @@ def paintCSHoloTMP(width, height, xMax, yMax, xfactor, yfactor, ticlength):
879869
xmlText = xmlText + ("<line x1='0' y1='" + str(
880870
height) + "' x2='0' y2='0' style='stroke:rgb(0,0,0);'/>\n") # draw vertical axis
881871
xmlText += "<text x='50.0' y='491.0' font-style='italic'>level</text>"
882-
#
883872
# xmlText += mytext("level", [0,height], [xfactor, yfactor], [0.2, 0.7],
884873
# "", 'font-size:11px', "", 'rgb(0,0,0)')
885874
xmlText += "<text x='33.0' y='411.0' transform='rotate(270 33, 411)' font-style='italic'>weight</text>"

lmfdb/local_fields/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ def render_field_webpage(args):
470470
'subfields': format_subfields(data['subfield'],data['subfield_mult'],p),
471471
'aut': data['aut'],
472472
})
473-
friends=[]
473+
friends = []
474474
if 'slopes' in data:
475475
info.update({'slopes': show_slopes(data['slopes'])})
476476
if 'inertia' in data:

lmfdb/modlmf/main.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,8 @@ def q_exp_display(label, number):
225225
number = int(number)
226226
except Exception:
227227
number = 20
228-
if number < 20:
229-
number = 20
230-
if number > 150:
231-
number = 150
228+
number = max(number, 20)
229+
number = min(number, 150)
232230
coeffs = db.modlmf_forms.lookup(label, projection='coeffs')[:number+1]
233231
return print_q_expansion(coeffs)
234232

lmfdb/riemann/stieltjes/stieltjes.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@ def list_constants(start=None,
3434

3535
if limit < 0:
3636
limit = 100
37-
if limit > 1000:
38-
limit = 1000
39-
if start < 0:
40-
start = 0
37+
limit = min(limit, 1000)
38+
start = max(start, 0)
4139
s_constants = stieltjes_list(start, limit)
4240

4341
if fmt == 'plain':

lmfdb/tensor_products/galois_reps.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,8 +510,7 @@ def set_number_of_coefficients(self):
510510
self.ld._gp_eval("MaxImaginaryPart = %s" % self.max_imaginary_part)
511511
self.numcoeff = self.ld.num_coeffs()
512512
# to be on the safe side, we make sure to have a min of terms
513-
if self.numcoeff < 50:
514-
self.numcoeff = 50
513+
self.numcoeff = max(self.numcoeff, 50)
515514

516515
## produce coefficients
517516

0 commit comments

Comments
 (0)