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 pycodestyle E265 and E241 #96

Merged
merged 1 commit into from
Mar 24, 2023
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
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,E221,E222,E225,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,E241,E262,E265,E271,E272,E30,E401,E701,E702,E703,E704,E711,E713,E721,W2,W3,W6 python/

env:
MAKEFLAGS: -j2
6 changes: 3 additions & 3 deletions python/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# import the SnapPy bindings
#import logging
#logging.basicConfig(filename='example.log',level=logging.DEBUG)
#logging.debug('This message should go to the log file')
# import logging
# logging.basicConfig(filename='example.log',level=logging.DEBUG)
# logging.debug('This message should go to the log file')
import sys
from .SnapPy import (AbelianGroup, HolonomyGroup, FundamentalGroup,
DirichletDomain, CuspNeighborhood, SymmetryGroup,
Expand Down
16 changes: 8 additions & 8 deletions python/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ def __init__(self):
self.window.createcommand("::tk::mac::OpenDocument", self.OSX_open_filelist)
else:
self.window.tk.call('namespace', 'import', '::tk::dialog::file::')
self.window.tk.call('set', '::tk::dialog::file::showHiddenBtn', '1')
self.window.tk.call('set', '::tk::dialog::file::showHiddenVar', '0')
self.window.tk.call('set', '::tk::dialog::file::showHiddenBtn', '1')
self.window.tk.call('set', '::tk::dialog::file::showHiddenVar', '0')
self.encoding = None

def add_bindings(self):
Expand Down Expand Up @@ -406,7 +406,7 @@ def set_icon(window):
window.eval('wm iconphoto . -default %s' % dock_icon)


#from multiprocessing import Process
# from multiprocessing import Process
class SnapPyKernelServer():
"""
Placeholder for a real SnapPyKernelServer which the app can use to
Expand Down Expand Up @@ -434,12 +434,12 @@ def __del__(self):
def main():
global terminal
import snappy
#kernel_server = SnapPyKernelServer()
# kernel_server = SnapPyKernelServer()
terminal = SnapPyTerm()
sys.stdout = terminal
set_icon(terminal.window)
SnapPy_ns = dict([(x, getattr(snappy,x)) for x in snappy.__all__])
#SnapPy_ns['kernel_server'] = kernel_server
SnapPy_ns = dict([(x, getattr(snappy, x)) for x in snappy.__all__])
# SnapPy_ns['kernel_server'] = kernel_server
SnapPy_ns['exit'] = SnapPy_ns['quit'] = SnapPyExit()
SnapPy_ns['pager'] = None
helper = pydoc.Helper(input=terminal, output=terminal)
Expand All @@ -459,11 +459,11 @@ def main():
LP.Browser = HP.Browser = SnapPyBrowser
LP.msg_stream.write = HP.msg_stream.write = terminal.write2
LP.UI_callback = HP.UI_callback = terminal.SnapPea_callback
#if not snappy.SnapPy._within_sage:
# if not snappy.SnapPy._within_sage:
# snappy.pari.UI_callback = terminal.PARI_callback
terminal.window.lift()
terminal.window.mainloop()
#kernel_server.stop()
# kernel_server.stop()


if __name__ == "__main__":
Expand Down
4 changes: 2 additions & 2 deletions python/app_menus.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ def inside_view_menus(self):
menubar.add_cascade(label='Edit ', menu=EditMenu(menubar, self.master.edit_actions))
menubar.add_cascade(label='Window', menu=WindowMenu(menubar))
help_menu = HelpMenu(menubar)
#help_menu.extra_command(label=help_polyhedron_viewer_label, command=self.widget.help)
#help_menu.activate([help_polyhedron_viewer_label, help_report_bugs_label])
# help_menu.extra_command(label=help_polyhedron_viewer_label, command=self.widget.help)
# help_menu.activate([help_polyhedron_viewer_label, help_report_bugs_label])
help_menu.activate([help_report_bugs_label])
self.menubar.add_cascade(label='Help', menu=help_menu)
4 changes: 2 additions & 2 deletions python/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@


main_window = None
#TODO: Find these dimensions by introspection.
# TODO: Find these dimensions by introspection.
cusp_box_height = 105
if sys.platform == 'darwin':
cusp_box_width = 180
Expand Down Expand Up @@ -406,7 +406,7 @@ def build_invariants(self):
height=6, show='headings', selectmode='none',
columns=['mult', 'length', 'topology', 'parity'],
)
#TODO: compute column widths by measuring text.
# TODO: compute column widths by measuring text.
geodesics.heading('mult', text='Mult.')
geodesics.column('mult', stretch=False, width=60)
geodesics.heading('length', text='Complex Length')
Expand Down
10 changes: 5 additions & 5 deletions python/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,16 +326,16 @@ def siblings(self, mfld):
Return all manifolds in the census which have the same hash value.
"""
vol = mfld.volume()
epsilon = vol/1e5
epsilon = vol / 1e5
v_lower, v_upper = vol - epsilon, vol + epsilon
cusps = mfld.cusp_info('is_complete').count(True)
H = mfld.homology()
betti = H.betti_number()
torsion = [c for c in H.elementary_divisors() if c != 0]
initial_candidates = self.find(
"volume between %f and %f and cusps=%d and betti=%d and torsion='%s'"
% (v_lower, v_upper, cusps, betti, torsion))
if len(initial_candidates) == 0:
txt = "volume between %f and %f and cusps=%d and betti=%d and torsion='%s'"
initial_candidates = self.find(txt % (v_lower, v_upper, cusps,
betti, torsion))
if not initial_candidates:
return []
return self.find("hash = '%s'" % self.mfld_hash(mfld))

Expand Down
2 changes: 1 addition & 1 deletion python/drilling/cusps.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def refill_and_adjust_peripheral_curves(
manifold.dehn_fill([ info.filling for info in post_drill_infos])

for info in post_drill_infos:
if not info.peripheral_matrix is None:
if info.peripheral_matrix is not None:
manifold.set_peripheral_curves(
info.peripheral_matrix, which_cusp = info.index)

Expand Down
26 changes: 13 additions & 13 deletions python/drilling/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ def check_peripheral_curves(tets):
for sheet_index in range(2):
sheet = tet.PeripheralCurves[ml][sheet_index][v]
if f == v_comp:
if not sum(sheet.values()) == 0:
if sum(sheet.values()) != 0:
raise Exception("Not adding up to zero. %r" % tet)
if not sheet[v_comp] == 0:
if sheet[v_comp] != 0:
raise Exception("Diagonal entry for peripheral curve.")
else:
if sgn == 0:
Expand All @@ -41,7 +41,7 @@ def check_peripheral_curves(tets):
other_sheet_index = sheet_index
a = sheet[f]
b = neighbor.PeripheralCurves[ml][other_sheet_index][other_v][other_f]
if not a + b == 0:
if a + b != 0:
raise Exception("Peripheral curve not adding up.")


Expand All @@ -51,7 +51,7 @@ def check_vertex_indices(tets):
index = tet.post_drill_infos[v]
for f in simplex.TwoSubsimplices:
if v & f:
if not tet.Neighbor[f].post_drill_infos[tet.Gluing[f].image(v)] == index:
if tet.Neighbor[f].post_drill_infos[tet.Gluing[f].image(v)] != index:
print("tet, v face:", tet, v, f)
print("index and other index:", index, tet.Neighbor[f].post_drill_infos, [tet.Gluing[f].image(v)])
raise Exception("Neighbors don't have same vertex.")
Expand Down Expand Up @@ -100,7 +100,7 @@ def check_geodesic1(tets):

for tet in tets:
for geodesic_segment in tet.geodesic_pieces:
if not geodesic_segment.tet is tet:
if geodesic_segment.tet is not tet:
raise Exception("Geodesic tet inconsistency")

for ptInClass in geodesic_segment.endpoints:
Expand All @@ -124,12 +124,12 @@ def check_consistency_segments(segments):
s0 = segments[i]
s1 = segments[(i+1) % len(segments)]

if not s0.tet.Class[s0.endpoints[1].subsimplex] is s1.tet.Class[s1.endpoints[0].subsimplex]:
if s0.tet.Class[s0.endpoints[1].subsimplex] is not s1.tet.Class[s1.endpoints[0].subsimplex]:
raise Exception("Classes of consecutive segments not matching %i" % i)

if not s0.next_ is s1:
if s0.next_ is not s1:
raise Exception("Linked list broken (next)")
if not s1.prev is s0:
if s1.prev is not s0:
raise Exception("Linked list broken (prev)")

if s0.endpoints[1].subsimplex in simplex.TwoSubsimplices:
Expand Down Expand Up @@ -206,17 +206,17 @@ def check_consistency_2(piece):

num_pieces += 1

if not piece.tet is tet:
if piece.tet is not tet:
raise Exception("Piece.tet not pointing to tet.")
if not piece.next_.prev is piece:
if piece.next_.prev is not piece:
raise Exception("Link list broken.")
if not piece.prev.next_ is piece:
if piece.prev.next_ is not piece:
raise Exception("Link list broken.")

if not piece.index == piece.next_.index:
if piece.index != piece.next_.index:
raise Exception("Index inconsistent.")

if not piece.index == piece.prev.index:
if piece.index != piece.prev.index:
raise Exception("Index inconsistent.")

if piece.index not in to_pieces_map:
Expand Down
2 changes: 1 addition & 1 deletion python/drilling/geodesic_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def find_tet_or_core_curve(self) -> None:
# Do some verification work for the above information to fill
# self.tet, self.lifted_tetrahedra and self.core_curve_cusp.

if not cusp_curve_vertex is None:
if cusp_curve_vertex is not None:
# Verify that the the geodesic is really the core curve and
# determine whether the geodesic and core curve or parallel
# or anti-parallel.
Expand Down
2 changes: 1 addition & 1 deletion python/drilling/peripheral_curves.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def _install_longitude(start_tet : Tetrahedron):
# first reached. Thus, we can later trace back a path to the starting
# tetrahedron.
visited_tet_to_face = { tet1 : simplex.F3 }
pending_tets = deque([( tet0, simplex.F2)])
pending_tets = deque([( tet0, simplex.F2)])
while True:
tet, entry_f = pending_tets.popleft()
if tet in visited_tet_to_face:
Expand Down
2 changes: 1 addition & 1 deletion python/drilling/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def trace_geodesic(geodesic : GeodesicInfo, verified : bool):
Endpoint(start_point + hit_param * direction, hit_face)]))

if hit_face == simplex.T:
if not tet is geodesic.tet:
if tet is not geodesic.tet:
raise InsufficientPrecisionError(
"Tracing geodesic ended up in a different "
"tetrahedron than it started. "
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 @@ -413,7 +413,7 @@ def barycentric_edge_embedding(arrow, north_pole=None):
return ans


#arrow, tail, head, opp_tail, opp_head
# arrow, tail, head, opp_tail, opp_head
def barycentric_quad_embedding0(arrow, north_pole=None):
"""
Take an arrow with 4 valent axis, then build embedding of the
Expand Down
10 changes: 5 additions & 5 deletions python/exterior_to_link/link_projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ def random_transform(steps=5):
>>> random_transform(5).det()
1
"""
I = Matrix([[1, 0, 0], [0, 1, 0], [ 0, 0, 1]])
X = Matrix([[0, 1, 0], [0, 0, 1], [ 1, 0, 0]])
Y = Matrix([[1, 0, 1], [0, -1, -1], [ 0, 1, 0]])
Z = Matrix([[0, 1, 0], [1, 0, 0], [-1, -1, -1]])
I = Matrix([[1, 0, 0], [0, 1, 0], [ 0, 0, 1]])
X = Matrix([[0, 1, 0], [0, 0, 1], [ 1, 0, 0]])
Y = Matrix([[1, 0, 1], [0, -1, -1], [ 0, 1, 0]])
Z = Matrix([[0, 1, 0], [1, 0, 0], [-1, -1, -1]])
# X and Y have order two and Z order three, so there are
# symmetric gens:
gens = [I, X, X*X, Y, Y*Y, Z, Z]
Expand Down Expand Up @@ -214,7 +214,7 @@ def __init__(self, points_by_component, mat=None):
self._setup_crossings()

def _setup_crossings(self):
#compute the over and under crossings of the link projection
# compute the over and under crossings of the link projection

pts = self.points
crossings, arcs = [], []
Expand Down
6 changes: 3 additions & 3 deletions python/exterior_to_link/mcomplex_with_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def pair_arcs_across_face(face):
arcs_a = tet_a.arcs
arcs_b = tet_b.arcs
perm = tet_a.Gluing[a_face]
#triple of [arc, zero_index, 0 or 1] where the 0/1 correspond to start/end
# triple of [arc, zero_index, 0 or 1] where the 0/1 correspond to start/end
face_arcs_a = []
face_ind = FaceIndex[a_face]
for arc in arcs_a:
Expand Down Expand Up @@ -588,8 +588,8 @@ def add_core_arc_in_one_tet_solid_torus(mcomplex, tet):
M = mcomplex
assert tet.Neighbor[F2] == tet.Neighbor[F3] == tet
assert no_fixed_point(tet.Gluing[F2]) and no_fixed_point(tet.Gluing[F3])
#c0, c1, c2, c3 = [QQ(x) for x in ['1/5', '1/7', '0', '23/35']] # original
#c0, c1, c2, c3 = [QQ(x) for x in ['21874/65536', '21841/65536', '0', '21821/65536']]
# c0, c1, c2, c3 = [QQ(x) for x in ['1/5', '1/7', '0', '23/35']] # original
# c0, c1, c2, c3 = [QQ(x) for x in ['21874/65536', '21841/65536', '0', '21821/65536']]
c0, c1, c2, c3 = [QQ(x) for x in ['1/3', '1/3', '0', '1/3']]
p1 = BarycentricPoint(c0, c1, c2, c3)
p2 = p1.permute(tet.Gluing[F2])
Expand Down
2 changes: 1 addition & 1 deletion python/manifolds/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#dummy "package" used to set paths for ../SnapPea.py
# dummy "package" used to set paths for ../SnapPea.py

pass
2 changes: 1 addition & 1 deletion python/ppm_to_png.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def line():
for y in range(height):
yield line()

##### Prior to this line, everything is identical to
# Prior to this line, everything is identical to


def convert_ppm_to_png(infile_object, outfile_object):
Expand Down
4 changes: 2 additions & 2 deletions python/ptolemy/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __init__(self, witnesses = [],
dimension = 'unknown', free_variables = None, genus = None,
p = None):

if not p is None:
if p is not None:
self.dimension = p.dimension
self.free_variables = p.free_variables
self.genus = p.genus
Expand All @@ -44,7 +44,7 @@ def _base_str_(self):
else:
f = ', free_variables = %r' % self.free_variables

if not self.genus is None:
if self.genus is not None:
f += ', genus = %d' % self.genus

return "NonZeroDimensionalComponent(dimension = %r%s)" % (
Expand Down
8 changes: 4 additions & 4 deletions python/ptolemy/coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -1159,7 +1159,7 @@ def get_zpq_triple(self, key_z):
raise Exception("Need to be called with cross ratio variable z_....")
key_zp = 'zp_' + key_z[2:]

w, z, p = self[key_z]
w, z, p = self[key_z]
wp, zp, q_canonical_branch_cut = self[key_zp]

# Note that the q in l(z;p,q) and in Definition 3.1 are different if
Expand Down Expand Up @@ -1242,8 +1242,8 @@ def check_against_manifold(self, M = None, epsilon = 1e-10):

for k in list(self.keys()):
if k[:2] == 'z_':
w, z, p = self[k]
wp, zp, q = self['zp_'+k[2:]]
w, z, p = self[k]
wp, zp, q = self['zp_'+k[2:]]
wpp, zpp, r = self['zpp_'+k[2:]]
_check_relation(
w + wp + wpp,
Expand Down Expand Up @@ -2157,7 +2157,7 @@ def evaluate_key_for_root(key, value):
zp = 1 / (1 - z)
zpp = 1 - 1 / z

return [(key, z),
return [(key, z),
('zp_' + key[2:], zp),
('zpp_' + key[2:], zpp)]
elif key[:3] == 'zp_' or key[:4] == 'zpp_':
Expand Down
Loading