From 45bf6051330ab507a2716fe52cf7e66200af207d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Tue, 2 Sep 2025 13:56:40 +0200 Subject: [PATCH 1/2] fixing ruff SIM103 --- surface_dynamics/flat_surfaces/homology.py | 7 +++--- .../flat_surfaces/separatrix_diagram.py | 22 ++++++++++------- .../interval_exchanges/template.py | 24 +++++++++---------- 3 files changed, 27 insertions(+), 26 deletions(-) diff --git a/surface_dynamics/flat_surfaces/homology.py b/surface_dynamics/flat_surfaces/homology.py index e16f9db8..5c019b27 100644 --- a/surface_dynamics/flat_surfaces/homology.py +++ b/surface_dynamics/flat_surfaces/homology.py @@ -1080,7 +1080,7 @@ def cycle_basis(self, intersection=False, verbose=False): return cycles, m return cycles - def is_cycle(self,c): + def is_cycle(self,c) -> bool: r""" Test whether ``c`` is a cycle. @@ -1091,9 +1091,8 @@ def is_cycle(self,c): for i in range(len(c)-1): if self.dart_to_vertex(c[i][1]) != self.dart_to_vertex(c[i+1][0]): return False - if self.dart_to_vertex(c[-1][1]) != self.dart_to_vertex(c[0][0]): - return False - return True + return self.dart_to_vertex(c[-1][1]) == self.dart_to_vertex(c[0][0]): + class RibbonGraphWithAngles(RibbonGraph): r""" diff --git a/surface_dynamics/flat_surfaces/separatrix_diagram.py b/surface_dynamics/flat_surfaces/separatrix_diagram.py index 1bf202da..c226b1b2 100644 --- a/surface_dynamics/flat_surfaces/separatrix_diagram.py +++ b/surface_dynamics/flat_surfaces/separatrix_diagram.py @@ -3137,23 +3137,27 @@ def is_hyperelliptic(self,verbose=False): for cy in self.cylinders(): for k in cy[0]: # check that p(k) is on the top of the cyl that has k on its bottom - if p[k] not in cy[1]: return False + if p[k] not in cy[1]: + return False # check that if k is on bot and top of cyl, then p(k) = k if k in cy[1]: - if k != p[k]: return False + if k != p[k]: + return False wsep += 1 if verbose: print("wsep", wsep) # check number of w pts - if wsep + 2*self.ncyls() != z[0] + 3: return False - # check that cylinders are stable under involution - if self != CylinderDiagram( - [(cy[0],tuple(map(lambda x: p[x],cy[0]))) for cy in self.cylinders()]): + if wsep + 2*self.ncyls() != z[0] + 3: return False - return True + # check that cylinders are stable under involution + return self == CylinderDiagram( + [(cy[0], tuple(map(lambda x: p[x], cy[0]))) + for cy in self.cylinders()]) elif len(z) == 2: # should be stratum H(g-1,g-1) - if z[0] != z[1]: return False + if z[0] != z[1]: + return False for cy in self.cylinders(): - if len(cy[0]) != len(cy[1]): return False + if len(cy[0]) != len(cy[1]): + return False b = self.bot() t = self.top() # build list of seps in cyclic order around first zero, starting by outgoing sep 0 diff --git a/surface_dynamics/interval_exchanges/template.py b/surface_dynamics/interval_exchanges/template.py index 188a3541..0b10b453 100644 --- a/surface_dynamics/interval_exchanges/template.py +++ b/surface_dynamics/interval_exchanges/template.py @@ -3594,31 +3594,29 @@ def has_rauzy_move(self, winner, side='right'): return False # winner or loser letter is repeated on the other interval (True) - if self._twin[0][-1][0] == 1: return True - if self._twin[1][-1][0] == 0: return True + if self._twin[0][-1][0] == 1: + return True + if self._twin[1][-1][0] == 0: + return True # the loser letter is the only letter repeated in # the loser interval (False) - if [i for i,_ in self._twin[loser]].count(loser) == 2: - return False - - return True + return [i for i,_ in self._twin[loser]].count(loser) != 2 elif side == 0: # the same letter at the left-end (False) - if (self._twin[0][0] == (1,0)): + if self._twin[0][0] == (1, 0): return False # winner or loser repeated on the other interval (True) - if self._twin[0][0][0] == 1: return True - if self._twin[1][0][0] == 0: return True + if self._twin[0][0][0] == 1: + return True + if self._twin[1][0][0] == 0: + return True # the loser letter is the only letter repeated in # the loser interval (False) - if [i for i,_ in self._twin[loser]].count(loser) == 2: - return False - - return True + return [i for i,_ in self._twin[loser]].count(loser) != 2 def orientation_cover(self): r""" From b8d7d6583e02468f997a74116e2a12591cbd3678 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Wed, 3 Sep 2025 08:20:43 +0200 Subject: [PATCH 2/2] fix mistake --- surface_dynamics/flat_surfaces/homology.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/surface_dynamics/flat_surfaces/homology.py b/surface_dynamics/flat_surfaces/homology.py index 5c019b27..6aa18475 100644 --- a/surface_dynamics/flat_surfaces/homology.py +++ b/surface_dynamics/flat_surfaces/homology.py @@ -1080,7 +1080,7 @@ def cycle_basis(self, intersection=False, verbose=False): return cycles, m return cycles - def is_cycle(self,c) -> bool: + def is_cycle(self, c) -> bool: r""" Test whether ``c`` is a cycle. @@ -1088,10 +1088,10 @@ def is_cycle(self,c) -> bool: where the preceding one ends. A *cycle* is a path which starts where it ends. """ - for i in range(len(c)-1): - if self.dart_to_vertex(c[i][1]) != self.dart_to_vertex(c[i+1][0]): + for i in range(len(c) - 1): + if self.dart_to_vertex(c[i][1]) != self.dart_to_vertex(c[i + 1][0]): return False - return self.dart_to_vertex(c[-1][1]) == self.dart_to_vertex(c[0][0]): + return self.dart_to_vertex(c[-1][1]) == self.dart_to_vertex(c[0][0]) class RibbonGraphWithAngles(RibbonGraph):