Skip to content

Commit 81b5467

Browse files
authored
Merge pull request #139 from fchapoton/varia_ruff_SIM
various ruff SIM fixes
2 parents 1935039 + 5f46601 commit 81b5467

File tree

9 files changed

+15
-30
lines changed

9 files changed

+15
-30
lines changed

surface_dynamics/flat_surfaces/abelian_strata.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,7 @@ def _cylinder_diagrams_with_symmetric(iterator):
201201
yield cd.inverse()
202202
elif sym == (True, False, False):
203203
yield cd.vertical_symmetry()
204-
elif sym == (False, True, False):
205-
yield cd.horizontal_symmetry()
206-
elif sym == (False, False, True):
204+
elif sym == (False, True, False) or sym == (False, False, True):
207205
yield cd.horizontal_symmetry()
208206
else:
209207
raise RuntimeError

surface_dynamics/flat_surfaces/masur_veech_volumes.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,7 @@ def masur_veech_volume(C, rational=False, method=None):
137137
elif isinstance(C, AbelianStratum):
138138
vol = sum(abelian_volumes_table[CC] for CC in C.components())
139139
S = C
140-
elif isinstance(C, QuadraticStratumComponent):
141-
raise NotImplementedError('quadratic differentials')
142-
elif isinstance(C, QuadraticStratum):
140+
elif isinstance(C, (QuadraticStratumComponent, QuadraticStratum)):
143141
raise NotImplementedError('quadratic differentials')
144142
else:
145143
raise ValueError('invalid input')

surface_dynamics/flat_surfaces/origamis/origami_database.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1594,7 +1594,7 @@ def build(self, comp, N, force_computation=False, verbose=False):
15941594
if key in self._data_to_entry:
15951595
data[key] = self._entry_to_data[key](data[key])
15961596

1597-
value = [data.get(e,None) for e in columns]
1597+
value = [data.get(e) for e in columns]
15981598
self.add_row('origamis', value, columns)
15991599

16001600
if verbose:

surface_dynamics/flat_surfaces/single_cylinder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1755,7 +1755,7 @@ def cylinder_concatenation(perm_1, perm_2, alphabet=None):
17551755
if bot_row1[i] == 1:
17561756
bot_row1[i] += length_1
17571757
for j in range(length_2):
1758-
if not bot_row2[j] == 1:
1758+
if bot_row2[j] != 1:
17591759
bot_row2[j] += length_1
17601760
bot_row = bot_row1 + bot_row2 + [0]
17611761
perm = GeneralizedPermutation(top_row,bot_row)

surface_dynamics/flat_surfaces/strata.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -402,9 +402,7 @@ def connected_components(self):
402402
s = sum(zeros)
403403
genus = s // 2 + 1
404404

405-
if genus == 1:
406-
return (HypASC(self),)
407-
elif genus == 2:
405+
if genus == 1 or genus == 2:
408406
return (HypASC(self),)
409407
elif genus == 3:
410408
if zeros == (2, 2) or zeros == (4,):
@@ -450,9 +448,7 @@ def connected_components(self):
450448
if zeros == (4,) or zeros == (3, 1):
451449
# empty!
452450
return ()
453-
elif zeros == (6, -1, -1):
454-
return (HQSC(self), GTNQSC(self))
455-
elif zeros == (3, 3, -1, -1):
451+
elif zeros == (6, -1, -1) or zeros == (3, 3, -1, -1):
456452
return (HQSC(self), GTNQSC(self))
457453
elif zeros == (2, 2) or zeros == (2, 1, 1) or zeros == (1, 1, 1, 1):
458454
return (GTHQSC(self),)
@@ -468,13 +464,7 @@ def connected_components(self):
468464
elif zeros == (6, 6) or zeros == (6, 3, 3) or zeros == (3, 3, 3, 3):
469465
return (HQSC(self), REQSC(self), IEQSC(self))
470466
else:
471-
if len(zeros) == 2 and zeros[0] % 4 == 2 and zeros[1] % 4 == 2:
472-
return (HQSC(self), NQSC(self))
473-
elif len(zeros) == 4 and zeros[0] == zeros[1] and zeros[2] == zeros[3] and zeros[0] % 2 and zeros[2] % 2:
474-
return (HQSC(self), NQSC(self))
475-
elif len(zeros) == 3 and zeros[0] == zeros[1] and zeros[0] % 2 and zeros[2] % 4 == 2:
476-
return (HQSC(self), NQSC(self))
477-
elif len(zeros) == 3 and zeros[1] == zeros[2] and zeros[1] % 2 and zeros[0] % 4 == 2:
467+
if len(zeros) == 2 and zeros[0] % 4 == 2 and zeros[1] % 4 == 2 or len(zeros) == 4 and zeros[0] == zeros[1] and zeros[2] == zeros[3] and zeros[0] % 2 and zeros[2] % 2 or (len(zeros) == 3 and zeros[0] == zeros[1] and zeros[0] % 2 and zeros[2] % 4 == 2 or len(zeros) == 3 and zeros[1] == zeros[2] and zeros[1] % 2 and zeros[0] % 4 == 2):
478468
return (HQSC(self), NQSC(self))
479469
else:
480470
return (CQSC(self),)

surface_dynamics/flat_surfaces/tests.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ def test_random(self):
132132
sage: Test().test_random() #random
133133
Doing random test
134134
"""
135-
tests = [a for a in Test.__dict__.keys() if a[:5] == "test_" and a != "test_random"]
135+
tests = [a for a in Test.__dict__
136+
if a[:5] == "test_" and a != "test_random"]
136137
name = prandom.choice(tests)
137138
print("Doing random test %s" % name)
138139
Test.__dict__[name](self)

surface_dynamics/misc/constellation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1325,7 +1325,7 @@ def random_element(self, mutable=False):
13251325

13261326
g = [SymmetricGroup(d).random_element() for _ in range(l-1)]
13271327
G = PermutationGroup(g)
1328-
while not G.degree() == d or (self._connected and not G.is_transitive()):
1328+
while G.degree() != d or (self._connected and not G.is_transitive()):
13291329
g = [SymmetricGroup(d).random_element() for _ in range(l-1)]
13301330
G = PermutationGroup(g)
13311331

surface_dynamics/misc/factored_denominator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def vector_to_linear_form_string(u, var_names):
122122
s += ' + %d*%s' % (j, var)
123123
first = False
124124

125-
return '0' if not s else s
125+
return s if s else '0'
126126

127127

128128
# NOTE: should this be an instance of Factorization?

surface_dynamics/misc/permutation.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def perm_check(l, n=None):
216216
return ra_seen == im_seen
217217

218218

219-
def perm_is_one(l, n=None):
219+
def perm_is_one(l, n=None) -> bool:
220220
r"""
221221
Test whether ``l`` is the identity on its domain.
222222
@@ -242,12 +242,10 @@ def perm_is_one(l, n=None):
242242
"""
243243
if n is None:
244244
n = len(l)
245-
for i in range(n):
246-
if l[i] != -1 and l[i] != i:
247-
return False
248-
return True
245+
return all(l[i] == -1 or l[i] == i for i in range(n))
246+
249247

250-
def perm_is_regular(p, k=None, n=None):
248+
def perm_is_regular(p, k=None, n=None) -> bool:
251249
r"""
252250
Return whether the cycle decomposition of ``p`` is only made of cycles
253251
of identical lengths.

0 commit comments

Comments
 (0)