Skip to content

Commit d97dbef

Browse files
authored
autopep8 action fixes
1 parent 1d076ae commit d97dbef

File tree

2 files changed

+60
-65
lines changed

2 files changed

+60
-65
lines changed

lmfdb/number_fields/draw_spectrum.py

Lines changed: 58 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ def __add__(self,other):
2626

2727
def draw(self, radius):
2828
return svg.Circle(
29-
cx = self.x,
30-
cy = self.y,
31-
r = radius,
32-
fill = self.color,
33-
stroke = 'black',
34-
stroke_width = .75)
29+
cx=self.x,
30+
cy=self.y,
31+
r=radius,
32+
fill=self.color,
33+
stroke='black',
34+
stroke_width=.75)
3535

3636
def draw_spec(frobs, local_alg_dict, colors=True, rings=False, num_primes=100, gaga=False) -> svg.SVG:
3737
""" Draw the spectrum of the ring of integers of a number field,
@@ -46,7 +46,7 @@ def draw_spec(frobs, local_alg_dict, colors=True, rings=False, num_primes=100, g
4646
col_max = max(i[0] for [p,l] in frobs for i in l if l != [0])
4747
else:
4848
col_max = 0
49-
49+
5050
### Options:
5151
# I've hardcoded these values instead of providing them
5252
# as optional arguments; feel free to change this
@@ -56,23 +56,22 @@ def draw_spec(frobs, local_alg_dict, colors=True, rings=False, num_primes=100, g
5656

5757
# (absolute) width of svg
5858
width = 200 if gaga else (num_primes+3)*50
59-
59+
6060
# distance between two primes along x-axis
61-
x_spread = floor(width/(num_primes+1)) if gaga else 50
62-
61+
x_spread = floor(width/(num_primes+1)) if gaga else 50
62+
6363
# distance between prime ideals in same fibre
6464
# = total distance from top to bottom
6565
y_spread = 30
6666

67-
6867
# y-coordinate of Spec Z
6968
bottom_line = round((3/4)*height)
7069

7170
# fraction of height of centre line around which the primes in spec are centred
7271
centre_ratio = 1/2 if gaga else 1/4
7372
# y-coordinate of Spec O_K
7473
y_centre = round(centre_ratio*height)
75-
74+
7675
line_thickness = .75
7776

7877
# increase or decrease girth of inert primes based on size of residue field
@@ -84,10 +83,9 @@ def draw_spec(frobs, local_alg_dict, colors=True, rings=False, num_primes=100, g
8483
# Should probably be between 0 and 2, with 1 being "reasonable"
8584
curviness = 0.9
8685

87-
8886
elements = []
8987
# NB: svg y-coords start from top! eg (0,1) is 1 unit down from top left corner
90-
88+
9189
# list of coordinates, where the n-th member is a
9290
# list of Points in the n-th fibre
9391
coords = []
@@ -104,72 +102,72 @@ def draw_spec(frobs, local_alg_dict, colors=True, rings=False, num_primes=100, g
104102
if not gaga:
105103
elements.append(
106104
svg.Line(
107-
stroke = "black",
108-
stroke_width = line_thickness,
109-
x1 = coords[0][0].x, # get starting point of line
110-
y1 = bottom_line,
111-
x2 = coords[-1][0].x + x_spread,
112-
y2 = bottom_line))
105+
stroke="black",
106+
stroke_width=line_thickness,
107+
x1=coords[0][0].x, # get starting point of line
108+
y1=bottom_line,
109+
x2=coords[-1][0].x + x_spread,
110+
y2=bottom_line))
113111

114112
# a dashed line afterwards to signify generic fibre
115113
for y in (bottom_line, y_centre):
116114
elements.append(
117115
svg.Line(
118-
stroke = "black",
119-
stroke_width = line_thickness,
120-
stroke_dasharray = "5",
121-
x1 = coords[-1][0].x + x_spread,
122-
y1 = y,
123-
x2 = coords[-1][0].x + 2*x_spread,
124-
y2 = y
116+
stroke="black",
117+
stroke_width=line_thickness,
118+
stroke_dasharray="5",
119+
x1=coords[-1][0].x + x_spread,
120+
y1=y,
121+
x2=coords[-1][0].x + 2*x_spread,
122+
y2=y
125123
)
126124
)
127125
elements.append(svg.Text(
128-
x = width - x_spread,
129-
y = y,
130-
dx = 16,
131-
dy = 4,
132-
text = '(0)',
133-
text_anchor = "middle"))
126+
x=width - x_spread,
127+
y=y,
128+
dx=16,
129+
dy=4,
130+
text='(0)',
131+
text_anchor="middle"))
134132

135133
# draw curves between primes - do this first so points drawn over curve
136134
nextpts = coords if gaga else coords + [[Point(width-2*x_spread, y_centre)]]
137135
for n in range(len(nextpts)-1):
138136
for pt_this in coords[n]:
139137
for pt_next in nextpts[n + 1]:
140138
# we control the angle of the curve by adding a control point
141-
dx = curviness*round((pt_next.x - pt_this.x)/2)
139+
dx = curviness*round((pt_next.x - pt_this.x)/2)
142140
elements.append(
143141
svg.Path(
144-
stroke = "black",
145-
stroke_width = line_thickness,
146-
fill = "none",
147-
d = [
148-
svg.M( x = pt_this.x, y = pt_this.y),
142+
stroke="black",
143+
stroke_width=line_thickness,
144+
fill="none",
145+
d=[
146+
svg.M( x=pt_this.x, y=pt_this.y),
149147
svg.CubicBezier(
150-
x1 = pt_next.x-dx,
151-
y1 = pt_this.y,
152-
x2 = pt_this.x+dx,
153-
y2 = pt_next.y,
154-
x = pt_next.x,
155-
y = pt_next.y )]))
148+
x1=pt_next.x-dx,
149+
y1=pt_this.y,
150+
x2=pt_this.x+dx,
151+
y2=pt_next.y,
152+
x=pt_next.x,
153+
y=pt_next.y )]))
156154

157155
for n, pts in enumerate(coords):
158-
if not gaga:
156+
if not gaga:
159157
# dots on Spec Z
160158
elements.append(Point(pts[0].x, bottom_line).draw(dot_radius))
161159
elements.append(
162160
svg.Text(
163-
x = pts[0].x,
164-
y = bottom_line,
165-
dy = 20,
166-
text = f'({frobs[n][0]})',
167-
text_anchor = "middle"))
161+
x=pts[0].x,
162+
y=bottom_line,
163+
dy=20,
164+
text=f'({frobs[n][0]})',
165+
text_anchor="middle"))
168166

169167
# fibre above prime
170168
for pt in pts:
171-
radius = min(dot_radius +
172-
residue_factor*(pt.girth-1), y_spread/5, x_spread/5)
169+
radius = min(dot_radius
170+
+ residue_factor*(pt.girth-1), y_spread/5, x_spread/5)
173171
elements.append(pt.draw(radius))
174172

175173
return svg.SVG(
@@ -190,7 +188,7 @@ def unram_coords(frob_cycle_list, x_coord, y_centre, spread, col_max):
190188
"""
191189
Given list of frobenius cycle describing a fixed fibre with no ramification, evenly spread points. Returns list of `Point`s.
192190
"""
193-
# number of points
191+
# number of points
194192
N = sum(l[1] for l in frob_cycle_list)
195193
if N == 1:
196194
cyc_len = frob_cycle_list[0][0]
@@ -226,11 +224,11 @@ def ram_coords(local_alg_dict, p, x_coord, y_centre, spread, deg=1):
226224
y_offset = 0
227225
point = Point(x_coord, y_centre - y_offset, residue_deg, hsl_color(ram_index, max_ram_index))
228226
point_list.append(point)
229-
227+
230228
return point_list
231229

232-
233-
def hsl_color(n, n_max, sec = [0,45]):
230+
231+
def hsl_color(n, n_max, sec=[0,45]):
234232
"""
235233
Vary hue in hsl color between 0 and n_max within sector sec
236234
"""
@@ -245,11 +243,9 @@ def hsl_color(n, n_max, sec = [0,45]):
245243
return f"hsl({h},{s}%,{l}%)"
246244

247245

248-
249-
250246
### Testing
251247
def test_drawspec(n=1, gaga=False):
252-
if n == 1:
248+
if n == 1:
253249
frobs = [[2, [[3, 2], [1, 1]]], [3, [[6, 1], [1, 1]]], [5, [[6, 1], [1, 1]]], [7, [0]], [11, [[3, 2], [1, 1]]], [13, [[2, 3], [1, 1]]], [17, [[6, 1], [1, 1]]], [19, [[6, 1], [1, 1]]], [23, [[3, 2], [1, 1]]], [29, [[1, 7]]], [31, [[6, 1], [1, 1]]], [37, [[3, 2], [1, 1]]], [41, [0]], [43, [[7, 1]]], [47, [[6, 1], [1, 1]]], [53, [[3, 2], [1, 1]]], [59, [[6, 1], [1, 1]]]]
254250

255251
local_algs = {"7": [[7,1]], "41": [[7,1]]}
@@ -259,9 +255,9 @@ def test_drawspec(n=1, gaga=False):
259255

260256
num_primes = 7 if gaga else 100
261257
canvas = draw_spec(frobs, local_algs, True,
262-
gaga=gaga,num_primes = num_primes)
258+
gaga=gaga,num_primes=num_primes)
263259
filename = f"/tmp/{'gaga' if gaga else 'test'}.svg"
264-
with open(filename, mode='w') as f:
260+
with open(filename, mode='w') as f:
265261
f.write(canvas.as_str())
266262

267263
print(f"Saved spectrum to {filename}")

lmfdb/number_fields/web_number_field.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,16 +1020,15 @@ def spec_data(self):
10201020
else:
10211021
local_algebra_dict[str(p)].append(thisdat)
10221022
return self.frobs(), local_algebra_dict
1023-
1023+
10241024
def draw_spectrum(self, num_primes=20):
10251025
frobs, local_algebra_dict = self.spec_data()
10261026
return draw_spec(frobs[:num_primes], local_algebra_dict).as_str()
10271027

10281028
def draw_gaga(self, num_primes=7):
10291029
frobs, local_algebra_dict = self.spec_data()
10301030
return draw_gaga(frobs[:num_primes], local_algebra_dict).as_str()
1031-
1032-
1031+
10331032
def make_code_snippets(self):
10341033
# read in code.yaml from numberfields directory:
10351034
_curdir = os.path.dirname(os.path.abspath(__file__))

0 commit comments

Comments
 (0)