Skip to content

Commit

Permalink
fix and activate pycodestyle E221 and E225 (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
fchapoton authored Mar 17, 2023
1 parent 6332714 commit 2caac3f
Show file tree
Hide file tree
Showing 56 changed files with 160 additions and 160 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Run pycodestyle
shell: bash -l {0}
# We currently only check for some warnings. We should enable & fix more of them.
run: pycodestyle --select=E111,E21,E222,E227,E228,E262,E271,E272,E30,E401,E701,E702,E703,E704,E711,E713,E721,W2,W3,W6 python/
run: pycodestyle --select=E111,E21,E221,E222,E225,E227,E228,E262,E271,E272,E30,E401,E701,E702,E703,E704,E711,E713,E721,W2,W3,W6 python/

env:
MAKEFLAGS: -j2
2 changes: 1 addition & 1 deletion python/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def save_file_as(self, event=None):
inputs = self.IP.history_manager.input_hist_raw
results = self.IP.history_manager.output_hist
for n in range(1,len(inputs)):
savefile.write('\n'+re.sub('\n+','\n',inputs[n]) +'\n')
savefile.write('\n'+re.sub('\n+','\n',inputs[n]) + '\n')
try:
output = repr(results[n]).split('\n')
except:
Expand Down
4 changes: 2 additions & 2 deletions python/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def build_side_panel(self):
canvas.configure(background=self.style.groupBG)
canvas.grid(row=0, column=0, sticky=Tk_.NSEW)
filling_scrollbar.config(command=canvas.yview)
self.filling_vars=[]
self.filling_vars = []

# Embedded windows in a canvas are clipped to their parent, not to
# the canvas.
Expand Down Expand Up @@ -391,7 +391,7 @@ def build_invariants(self):
ttk.Label(self.length_spectrum_frame, text='Cutoff:').grid(
row=0, column=0, sticky=Tk_.E, pady=5)
self.length_cutoff = 1.0
self.cutoff_var=Tk_.StringVar(self, self.length_cutoff)
self.cutoff_var = Tk_.StringVar(self, self.length_cutoff)
self.cutoff_entry = cutoff_entry = ttk.Entry(
self.length_spectrum_frame,
takefocus=False,
Expand Down
2 changes: 1 addition & 1 deletion python/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def _manifold_factory(self, row, M=None):
isosig = m.group(1)
M._from_isosig(isosig)

fillings = eval( '[' + m.group(2).replace(')(', '),(')+ ']', {})
fillings = eval( '[' + m.group(2).replace(')(', '),(') + ']', {})

if fillings:
M.dehn_fill(fillings)
Expand Down
4 changes: 2 additions & 2 deletions python/drilling/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,10 +430,10 @@ def drill_words_hp(*args, **kwargs):

def _add_methods(mfld_class, high_precision = False):
if high_precision:
mfld_class.drill_word = drill_word_hp
mfld_class.drill_word = drill_word_hp
mfld_class.drill_words = drill_words_hp
else:
mfld_class.drill_word = drill_word
mfld_class.drill_word = drill_word
mfld_class.drill_words = drill_words


Expand Down
2 changes: 1 addition & 1 deletion python/drilling/fixed_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def r13_fixed_points_of_psl2c_matrix(m):
if e0 > e1:
return _r13_fixed_points_of_psl2c_matrix(m)

t = matrix([[ 1, 0],[ 1, 1]], ring = m.base_ring())
t = matrix([[ 1, 0],[ 1, 1]], ring = m.base_ring())
tinv = matrix([[ 1, 0],[-1, 1]], ring = m.base_ring())

pts = _r13_fixed_points_of_psl2c_matrix(tinv * m * t)
Expand Down
6 changes: 3 additions & 3 deletions python/drilling/moves.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,12 +309,12 @@ def two_three_move(given_pieces : Sequence[GeodesicPiece],
continue

start_subsimplex = old_piece.endpoints[0].subsimplex
end_subsimplex = old_piece.endpoints[1].subsimplex
end_subsimplex = old_piece.endpoints[1].subsimplex

if (start_subsimplex | end_subsimplex) in simplex.OneSubsimplices:
for i, new_tet in enumerate(new_tets):
new_start_subsimplex = old_to_new_tets[j][i].image(start_subsimplex)
new_end_subsimplex = old_to_new_tets[j][i].image(end_subsimplex)
new_end_subsimplex = old_to_new_tets[j][i].image(end_subsimplex)

if (new_start_subsimplex | new_end_subsimplex) == simplex.E23:
GeodesicPiece.replace_by(
Expand Down Expand Up @@ -345,7 +345,7 @@ def two_three_move(given_pieces : Sequence[GeodesicPiece],
end_j = j

r13_endpoints = [
O13_embeddings[j] * old_pieces[ 0].endpoints[0].r13_point,
O13_embeddings[j] * old_pieces[ 0].endpoints[0].r13_point,
O13_embeddings[end_j] * old_pieces[-1].endpoints[1].r13_point
]

Expand Down
2 changes: 1 addition & 1 deletion python/exterior_to_link/barycentric_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ def barycentric_edge_embedding(arrow, north_pole=None):
"""
if north_pole is None:
north_pole = N
assert len(arrow.linking_cycle())==3
assert len(arrow.linking_cycle()) == 3
arrow = arrow.copy()
verts = [A, B, C, A]
ans = []
Expand Down
4 changes: 2 additions & 2 deletions python/exterior_to_link/link_projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def straightenable_tri(points, extra_arcs=None):
for i in range(n):
indices = i, (i + 1) % n, (i + 2) % n
tri = [points[k] for k in indices]
other_arcs = [(points[k], points[(k+1)% n])
other_arcs = [(points[k], points[(k+1) % n])
for k in range(n) if k not in indices[:2]]
if pl_utils.colinear(*tri):
return indices
Expand All @@ -87,7 +87,7 @@ def arcs_from_points(points_list):
arcs = []
for p in points_list:
n = len(p)
arcs += [(p[k], p[(k+1)% n]) for k in range(n)]
arcs += [(p[k], p[(k+1) % n]) for k in range(n)]
return arcs


Expand Down
2 changes: 1 addition & 1 deletion python/exterior_to_link/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def print_status(*args, **kwargs):
f'PL segments; max denom of coor is {M._curr_max_denom()}.')
print_status(' Embedding in S3...', end='')
link_in_R3 = put_in_S3.embed_link_in_S3(M)
link_in_R3 = link_projection.straighten_link(link_in_R3)
link_in_R3 = link_projection.straighten_link(link_in_R3)
num_seg = sum(len(component) + 1 for component in link_in_R3)
print_status('got PL link of', num_seg ,'segments.')
print_status(' Projecting...', end='')
Expand Down
2 changes: 1 addition & 1 deletion python/exterior_to_link/mcomplex_with_expansion.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def _two_to_zero_base(self, arrow):
implemented as a compound of four 2<->3 moves.
"""
assert arrow.axis().valence() == 2
assert arrow.equator().valence()==2
assert arrow.equator().valence() == 2
a = arrow.copy()
a.opposite().next().reverse().opposite()
if a.Tetrahedron == a.glued().Tetrahedron:
Expand Down
4 changes: 2 additions & 2 deletions python/exterior_to_link/mcomplex_with_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,8 @@ def safe_perturbation(self):
check = True
min_b, max_b = coor_min[b], coor_max[b]
for i in range(3):
if (((min_a[i]-max_b[i])**2 >= min_distance_sq and (min_a[i]-max_b[i])>0)
or ((min_b[i]-max_a[i])**2 >= min_distance_sq and (min_b[i]-max_a[i])>0)):
if (((min_a[i]-max_b[i])**2 >= min_distance_sq and (min_a[i]-max_b[i]) > 0)
or ((min_b[i]-max_a[i])**2 >= min_distance_sq and (min_b[i]-max_a[i]) > 0)):
# arcs lie in different regions which are far apart so dont compare
check = False
break
Expand Down
2 changes: 1 addition & 1 deletion python/horoviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def __init__(self, master, nbhd=None, which_cusp=0, cutoff=None,
widget.set_background(1.0,1.0,1.0)
widget.autospin_allowed = 0
cyglSetStandardLighting()
option_frame= ttk.Frame(top_frame)
option_frame = ttk.Frame(top_frame)
view_button = ttk.Menubutton(option_frame, text='View Options')
self.view_menu = view_menu = Tk_.Menu(view_button, tearoff=0)
view_menu.add_checkbutton(label='parallelogram', command=self.view_check,
Expand Down
2 changes: 1 addition & 1 deletion python/infodialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def body(self, master):
if sys.platform == 'darwin':
message = Tk_.Message(box, text=self.content)
else:
bgColor=self.style.lookup('Button', 'background')
bgColor = self.style.lookup('Button', 'background')
message = Tk_.Message(box, text=self.content, bg=bgColor)
message.grid(row=0, column=1, padx=20, pady=10)
box.pack()
Expand Down
8 changes: 4 additions & 4 deletions python/numeric_output_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class NumericExample:
# Store in dict precision : FLAG
NUMERIC_DICT = {}
# All or'ed together
ALL_NUMERIC = 0
ALL_NUMERIC = 0


def init_precisions(precisions):
Expand Down Expand Up @@ -93,7 +93,7 @@ def get_precision(optionflags):

# 4.5?e-3 would split into groups ('4.5?e-3', '4.5', '?", 'e-3').
number_re = re.compile('(' + mantissa_pat + interval_pat + exponent_pat + ')')
number_group_count = 4
number_group_count = 4
number_split_stride = number_group_count + 1

# Use whitespace normalization for text pieces
Expand Down Expand Up @@ -182,13 +182,13 @@ def compare_numeric(self, want, got, optionflags):

# "[4.5e-9]" yields ('[', '4.5e-9', '4.5', None, 'e-9', ']')
split_want = re.split(number_re, want)
split_got = re.split(number_re, got)
split_got = re.split(number_re, got)

# Check same number of numbers
if len(split_want) != len(split_got):
return ('COUNT',
(len(split_want) // number_split_stride,
len(split_got) // number_split_stride))
len(split_got) // number_split_stride))

# Compare text pieces between numbers
flags = optionflags | NUMERIC_DEFAULT_OPTIONFLAGS
Expand Down
4 changes: 2 additions & 2 deletions python/polyviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def __init__(self, parent, facedicts=[], **kwargs):
self.main_window = kwargs.get('main_window', None)
self.topframe = topframe = ttk.Frame(self)
self.bottomframe = bottomframe = ttk.Frame(self)
self.model_var=Tk_.StringVar(self, value='Klein')
self.sphere_var=Tk_.IntVar(self, value=1)
self.model_var = Tk_.StringVar(self, value='Klein')
self.sphere_var = Tk_.IntVar(self, value=1)
self.klein = ttk.Radiobutton(topframe, text='Klein',
variable = self.model_var,
value='Klein',
Expand Down
22 changes: 11 additions & 11 deletions python/ptolemy/coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -1198,8 +1198,8 @@ def complex_volume(self, with_modulo = False):
if key[:2] == 'z_' ])

cvol = sum_L_functions / pari('I')
vol = cvol.real()
cs = cvol.imag() % m
vol = cvol.real()
cs = cvol.imag() % m

if cs > m/2 + pari('1e-12'):
cs = cs - m
Expand Down Expand Up @@ -2030,8 +2030,8 @@ def get_obstruction_variable(face):
s1 = get_obstruction_variable(1)
s2 = get_obstruction_variable(2)
s3 = get_obstruction_variable(3)
z = s0 * s1 * z
zp = s0 * s2 * zp
z = s0 * s1 * z
zp = s0 * s2 * zp
zpp = s0 * s3 * zpp

variable_end = '_%d%d%d%d' % tuple(index) + '_%d' % tet
Expand All @@ -2049,14 +2049,14 @@ def make_triple(w, z):
branch_factor, evenN)

return [
('z' + variable_end, make_triple(w ,z )),
('zp' + variable_end, make_triple(wp ,zp )),
('z' + variable_end, make_triple(w ,z )),
('zp' + variable_end, make_triple(wp ,zp )),
('zpp' + variable_end, make_triple(wpp,zpp)) ]

else:
return [
('z' + variable_end, z),
('zp' + variable_end, zp),
('z' + variable_end, z),
('zp' + variable_end, zp),
('zpp' + variable_end, zpp) ]

return dict(
Expand Down Expand Up @@ -2153,12 +2153,12 @@ def evaluate_key_for_root(key, value):
v = _evaluate_at_root(value, root)

if key[:2] == 'z_':
z = v
zp = 1 / (1 - z)
z = v
zp = 1 / (1 - z)
zpp = 1 - 1 / z

return [(key, z),
('zp_' + key[2:], zp),
('zp_' + key[2:], zp),
('zpp_' + key[2:], zpp)]
elif key[:3] == 'zp_' or key[:4] == 'zpp_':
return []
Expand Down
2 changes: 1 addition & 1 deletion python/ptolemy/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def col_is_zero(m, col):
if col < 0:
return True
for row in m:
if not row[col]==0:
if not row[col] == 0:
return False
return True

Expand Down
2 changes: 1 addition & 1 deletion python/ptolemy/processMagmaFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def run_magma(content,
else:
resolved_dir = tempfile.mkdtemp() + '/'

in_file = resolved_dir + filename_base + '.magma'
in_file = resolved_dir + filename_base + '.magma'
out_file = resolved_dir + filename_base + '.magma_out'

if verbose:
Expand Down
2 changes: 1 addition & 1 deletion python/ptolemy/ptolemyVariety.py
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ def merge_two_dicts(sign, power, var1, var2, dict1, dict2):
sign1, power1 = dict1[var1]
sign2, power2 = dict2[var2]

new_sign = sign1 * sign * sign2
new_sign = sign1 * sign * sign2
new_power = power1 - power - power2

for v2, (s2, p2) in dict2.items():
Expand Down
2 changes: 1 addition & 1 deletion python/ptolemy/reginaWrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ def _ptolemy_equations_identified_coordinates(self, N,
power = 0

# Get the two corresponding Ptolemy coordinates
ptolemy = ('c_%d%d%d%d' % ptolemy_index +
ptolemy = ('c_%d%d%d%d' % ptolemy_index +
'_%d' % tet_index)
other_ptolemy = ('c_%d%d%d%d' % other_ptolemy_index +
'_%d' % other_tet_index)
Expand Down
2 changes: 1 addition & 1 deletion python/ptolemy/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def is_close(cvol1, cvol2, epsilon):

from snappy import OrientableCuspedCensus

for M in (list(OrientableCuspedCensus()[0:10])+
for M in (list(OrientableCuspedCensus()[0:10]) +
list(OrientableCuspedCensus()[10000:10010])):

flattening = Flattenings.from_tetrahedra_shapes_of_manifold(M)
Expand Down
2 changes: 1 addition & 1 deletion python/raytracing/finite_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ def create_navigation_frame(self, parent):
label = ttk.Label(frame, text = u"Keys: \u2190\u2191\u2192\u2193xz")
label.grid(row = row, column = 3, sticky = tkinter.NSEW)

row +=1
row += 1
label = ttk.Label(frame, text = _mouse_gestures_text())
label.grid(row = row, column = 0, columnspan = 4)

Expand Down
4 changes: 2 additions & 2 deletions python/raytracing/gui_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,10 @@ def set_widths(self):
def set_scrollbar(self, low, high):
if float(low) <= 0.0 and float(high) >= 1.0:
self.scrollbar.pack_forget()
self.scrollbar.is_visible=False
self.scrollbar.is_visible = False
else:
self.scrollbar.pack(side="right", fill="y", anchor="nw", pady=10)
self.scrollbar.is_visible=True
self.scrollbar.is_visible = True
self.scrollbar.set(low, high)

def resize(self, event=None):
Expand Down
6 changes: 3 additions & 3 deletions python/raytracing/hyperboloid_navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ def _turn_ccw(rot_amount, trans_amount): # z


def _add_cursor_keys(d):
d['left'] = _turn_left
d['left'] = _turn_left
d['right'] = _turn_right
d['up'] = _turn_up
d['down'] = _turn_down
d['up'] = _turn_up
d['down'] = _turn_down
return d


Expand Down
4 changes: 2 additions & 2 deletions python/raytracing/ideal_raytracing_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ def _o13_matrix_for_face(tet, F):

def _compute_cusp_triangle_vertex_positions(tet, V, i):

z = tet.ShapeParameters[t3m.E01]
z = tet.ShapeParameters[t3m.E01]
CF = z.parent()

triangle = tet.horotriangles[V]
Expand Down Expand Up @@ -463,7 +463,7 @@ def _compute_cusp_to_tet_and_inverse_matrices(tet, vertex, i):

otherVerts = [ t3m.ZeroSubsimplices[(i + j) % 4] for j in range(1, 4) ]

tet_vertices = [ tet.complex_vertices[v] for v in otherVerts ]
tet_vertices = [ tet.complex_vertices[v] for v in otherVerts ]

cusp_vertices = [ trig.vertex_positions[vertex | v]
for v in otherVerts ]
Expand Down
Loading

0 comments on commit 2caac3f

Please sign in to comment.