Skip to content

Commit

Permalink
remove trailing whitespaces in cython code too (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
fchapoton authored May 9, 2023
1 parent 5258131 commit b176619
Show file tree
Hide file tree
Showing 8 changed files with 202 additions and 200 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ 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,E241,E251,E262,E265,E271,E272,E30,E401,E701,E702,E703,E704,E711,E713,E714,E721,W2,W3,W6 python/
run: |
pycodestyle --select=E111,E21,E221,E222,E225,E227,E228,E241,E251,E262,E265,E271,E272,E30,E401,E701,E702,E703,E704,E711,E713,E714,E721,W2,W3,W6 python/
pycodestyle --filename=*.pyx --select=W2 cython/
env:
MAKEFLAGS: -j2
6 changes: 3 additions & 3 deletions cython/SnapPy.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ cdef extern from "triangulation.h":
c_TetShape *shape[2]
c_VertexCrossSections *cross_section
EdgeClass *edge_class[6]

ctypedef struct c_Triangulation "Triangulation":
c_Tetrahedron tet_list_begin
c_Tetrahedron tet_list_end
Expand Down Expand Up @@ -747,7 +747,7 @@ cdef extern from "addl_code.h":
extern void free_cusp_equation(int* equation)
extern c_Triangulation* triangulate_link_complement_from_file(char* file_name, char *path) except *
extern c_Triangulation* fibered_manifold_associated_to_braid(int numStrands, int braidLength, int* word) except *
extern void set_tet_shapes(c_Triangulation* manifold, Complex* filled_shapes, Complex* complete_shapes)
extern void set_tet_shapes(c_Triangulation* manifold, Complex* filled_shapes, Complex* complete_shapes)
extern void set_target_holonomy(c_Triangulation* manifold, int theCuspIndex, Complex theTarget, int theRecomputeFlag)
extern c_Triangulation* DT2Triangulation(char* c_link_record)
extern void choose_gen_tetrahedron_info(c_Triangulation* manifold, int tet_index, int *generator_path, int *face0_gen, int *face1_gen, int *face2_gen, int *face3_gen, Complex *corner0, Complex *corner1, Complex *corner2, Complex *corner3, int *neighbor0_idx, int *neighbor1_idx, int *neighbor2_idx, int *neighbor3_idx, int *perm0, int *perm1, int *perm2, int *perm3)
Expand All @@ -769,7 +769,7 @@ cdef extern from "ptolemy_types.h":
int *powers

extern void free_identification_of_variables(Identification_of_variables id)

ctypedef struct Integer_matrix_with_explanations:
int **entries
int num_rows
Expand Down
36 changes: 18 additions & 18 deletions cython/core/basic.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@ except ImportError:
asksaveasfile = None

# This is part of the UCS2 hack.
cdef public UCS2_hack (char *string, Py_ssize_t length, char *errors) :
cdef public UCS2_hack (char *string, Py_ssize_t length, char *errors) :
return string

def valid_index(i, n, format_str):
"""
Return range(n)[i] or raises a nicely formatted IndexError
using format_str.
This does several things for us::
* avoid that cython happily converts a float to an int, so a call
Expand All @@ -96,7 +96,7 @@ def valid_index(i, n, format_str):
* checks that i is in the right range
* supports Sage and numpy Integers: they are not python int's but
have __index__ (see PEP 357)
It is faster than reimplementing these behaviors.
"""
try:
Expand Down Expand Up @@ -157,7 +157,7 @@ def set_test_flag(int value):
global SnapPy_test_flag
old = SnapPy_test_flag
SnapPy_test_flag = value
return old
return old

# Implementation of the SnapPea UI functions and their global variables.
cdef public void uFatalError(const_char_ptr function,
Expand All @@ -168,7 +168,7 @@ cdef public void uFatalError(const_char_ptr function,
raise SnapPeaFatalError('SnapPea crashed in function %s(), '
'defined in %s.c.'%(function, file))

# Global variables used for interrupt processing
# Global variables used for interrupt processing
cdef public Boolean gLongComputationInProgress
cdef public Boolean gLongComputationCancelled
cdef public gLongComputationTicker
Expand Down Expand Up @@ -234,7 +234,7 @@ cdef public void uAbortMemoryFull():
sys.stderr.write('Out of memory.\n')
sys.exit(2)

cdef public int uQuery(const_char_ptr message,
cdef public int uQuery(const_char_ptr message,
const_int num_responses,
const_char_ptr responses[],
const_int default_response):
Expand All @@ -251,7 +251,7 @@ def cy_eval(s):
def smith_form(M):
if _within_sage:
if not hasattr(M, 'elementary_divisors'):
M = sage_matrix(M)
M = sage_matrix(M)
m, n = M.nrows(), M.ncols()
result = M.elementary_divisors(algorithm='pari')
else:
Expand Down Expand Up @@ -376,11 +376,11 @@ class MatrixWithExplanations():
def format_explain_list(l):
if len(l) <= 6:
return repr(l)

return "[ %s, ..., %s]" % (
', '.join(map(repr,l[:3])),
', '.join(map(repr,l[-3:])))


return (
"%s(\n"
Expand All @@ -395,7 +395,7 @@ class MatrixWithExplanations():
class NeumannZagierTypeEquations(MatrixWithExplanations):

def __init__(self, mat, explain_rows, explain_columns):
MatrixWithExplanations.__init__(self,
MatrixWithExplanations.__init__(self,
mat, explain_rows, explain_columns)

def __repr__(self):
Expand Down Expand Up @@ -525,8 +525,8 @@ cdef Complex Object2Complex(obj):
result.real = real
result.imag = imag
return result



cdef double Real2double(Real R):
cdef double* quad = <double *>&R
Expand All @@ -542,7 +542,7 @@ cdef Complex gen2Complex(g):

py_string = to_byte_str(str(g.real()).replace(' E','E')) # save a reference
c_string = py_string
real_part = <Real>c_string
real_part = <Real>c_string
py_string = to_byte_str(str(g.imag()).replace(' E','E')) # save a reference
c_string = py_string
imag_part = <Real>c_string
Expand Down Expand Up @@ -610,16 +610,16 @@ class CuspInfo(Info):
return ('Cusp %-2d: %s with Dehn filling coefficients (M, L) = %s'%
(self.index, self.topology, self.filling) )
_obsolete = {'complete?' : 'is_complete',
'holonomy precision' : 'holonomy_accuracy',
'holonomy precision' : 'holonomy_accuracy',
'shape precision' : 'shape_accuracy'}

class DualCurveInfo(Info):
def __repr__(self):
return ('%3d: %s curve of length %s'%
(self.index, MatrixParity[self.parity], self.filled_length))
_obsolete = {'complete length' : 'complete_length',
'filled length' : 'filled_length'}

def _StrLongestLen(l):
return str(max(len(e) for e in l))

Expand Down Expand Up @@ -674,7 +674,7 @@ class NormalSurfaceInfo(Info):
orient = 'Orientable' if self.orientable else 'Non-orientable'
sided = 'two-sided' if self.two_sided else 'one-sided'
return '%s %s with euler = %s' % (orient, sided, self.euler)

class LengthSpectrum(list):
def __repr__(self):
if len(self) > 0 and 'word' in self[0]:
Expand All @@ -688,7 +688,7 @@ class LengthSpectrum(list):
class ListOnePerLine(list):
def __repr__(self):
return '[' + ',\n '.join([repr(s) for s in self]) + ']'

# Isometry

def format_two_by_two(mat):
Expand Down
12 changes: 6 additions & 6 deletions cython/core/cusp_neighborhoods.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ cdef class CCuspNeighborhood():
else:
raise IndexError('The specified cusp (%s) does not '
'exist.'%which_cusp)

def num_cusps(self):
"""
Return the number of cusps.
Expand Down Expand Up @@ -146,15 +146,15 @@ cdef class CCuspNeighborhood():

def get_tie(self, which_cusp):
"""
Return True if the specified cusp is a member of the tied group.
The displacements of the tied cusps are all the same.
Return True if the specified cusp is a member of the tied group.
The displacements of the tied cusps are all the same.
"""
N = self.check_index(which_cusp)
return get_cusp_neighborhood_tie(self.c_cusp_neighborhood, N)

def set_tie(self, which_cusp, new_tie):
"""
Mark the specified cusp as a member of the tied group.
Mark the specified cusp as a member of the tied group.
"""
N = self.check_index(which_cusp)
set_cusp_neighborhood_tie(self.c_cusp_neighborhood, N, new_tie)
Expand Down Expand Up @@ -192,7 +192,7 @@ cdef class CCuspNeighborhood():
"""
Return a list of dictionaries describing the horoballs with
height at least cutoff. The keys are 'center', 'radius', 'index'.
If the high_precision flag is set to the default value False, these
are Python complexes and floats. Otherwise they are SnapPy Numbers.
"""
Expand Down Expand Up @@ -244,7 +244,7 @@ cdef class CCuspNeighborhood():
for n from 0 <= n < segment_list.num_segments:
segment = segment_list.segment[n]
if high_precision:
pair = (
pair = (
self._number_(Complex2Number(segment.endpoint[0])),
self._number_(Complex2Number(segment.endpoint[1])) )
else:
Expand Down
Loading

0 comments on commit b176619

Please sign in to comment.