@@ -304,7 +304,7 @@ def reduced_word(self):
304
304
sage: p.reduced_word()
305
305
[0, 7, 4, 1, 0, 7, 5, 4, 2, 1]
306
306
"""
307
- #This is about 25% faster than the default algorithm.
307
+ # This is about 25% faster than the default algorithm.
308
308
x = self
309
309
i = 0
310
310
word = []
@@ -409,10 +409,10 @@ def grassmannian_quotient(self, i=0, side='right'):
409
409
410
410
411
411
class AffinePermutationTypeA (AffinePermutation ):
412
- #----------------------
413
- #Type-specific methods.
414
- #(Methods existing in all types, but with type-specific definition.)
415
- #----------------------
412
+ # ----------------------
413
+ # Type-specific methods.
414
+ # (Methods existing in all types, but with type-specific definition.)
415
+ # ----------------------
416
416
def check (self ):
417
417
r"""
418
418
Check that ``self`` is an affine permutation.
@@ -510,11 +510,11 @@ def apply_simple_reflection_right(self, i):
510
510
Type A affine permutation with window [3, -1, 6, 0, 5, 4, 10, 9]
511
511
"""
512
512
j = i % (self .k + 1 )
513
- #Cloning is currently kinda broken, in that caches don't clear which
514
- #leads to strangeness with the cloned object.
515
- #The clone approach is quite a bit (2x) faster, though, so this should
516
- #switch once the caching situation is fixed.
517
- #with self.clone(check=False) as l:
513
+ # Cloning is currently kinda broken, in that caches don't clear which
514
+ # leads to strangeness with the cloned object.
515
+ # The clone approach is quite a bit (2x) faster, though, so this should
516
+ # switch once the caching situation is fixed.
517
+ # with self.clone(check=False) as l:
518
518
l = self [:]
519
519
if j == 0 :
520
520
a = l [0 ]
@@ -524,7 +524,6 @@ def apply_simple_reflection_right(self, i):
524
524
a = l [j - 1 ]
525
525
l [j - 1 ] = l [j ]
526
526
l [j ] = a
527
- #return l
528
527
return type (self )(self .parent (), l , check = False )
529
528
530
529
def apply_simple_reflection_left (self , i ):
@@ -539,18 +538,18 @@ def apply_simple_reflection_left(self, i):
539
538
sage: p.apply_simple_reflection_left(11)
540
539
Type A affine permutation with window [4, -1, 0, 6, 5, 3, 10, 9]
541
540
"""
542
- #Here are a couple other methods we tried out, but turned out
543
- #to be slower than the current implementation.
544
- #1) This one was very bad:
545
- # return self.inverse().apply_simple_reflection_right(i).inverse()
546
- #2) Also bad, though not quite so bad:
547
- # return (self.parent().simple_reflection(i))*self
548
- i = i % (self .k + 1 )
549
- #Cloning is currently kinda broken, in that caches don't clear which
550
- #leads to strangeness with the cloned object.
551
- #The clone approach is quite a bit faster, though, so this should switch
552
- #once the caching situation is fixed.
553
- #with self.clone(check=False) as l:
541
+ # Here are a couple other methods we tried out, but turned out
542
+ # to be slower than the current implementation.
543
+ # 1) This one was very bad:
544
+ # return self.inverse().apply_simple_reflection_right(i).inverse()
545
+ # 2) Also bad, though not quite so bad:
546
+ # return (self.parent().simple_reflection(i))*self
547
+ i = i % (self .k + 1 )
548
+ # Cloning is currently kinda broken, in that caches don't clear which
549
+ # leads to strangeness with the cloned object.
550
+ # The clone approach is quite a bit faster, though,
551
+ # so this should switch once the caching situation is fixed.
552
+ # with self.clone(check=False) as l:
554
553
l = []
555
554
if i != self .k :
556
555
for m in range (self .k + 1 ):
@@ -627,10 +626,10 @@ def to_type_a(self):
627
626
"""
628
627
return self
629
628
630
- #----------------------
631
- #Type-A-specific methods.
632
- #Only available in Type A.
633
- #----------------------
629
+ # ----------------------
630
+ # Type-A-specific methods.
631
+ # Only available in Type A.
632
+ # ----------------------
634
633
635
634
def flip_automorphism (self ):
636
635
r"""
@@ -699,7 +698,7 @@ def maximal_cyclic_factor(self, typ='decreasing', side='right', verbose=False):
699
698
else :
700
699
descents = self .descents (side = 'left' )
701
700
side = 'left'
702
- #for now, assume side is 'right')
701
+ # for now, assume side is 'right')
703
702
best_T = []
704
703
for i in descents :
705
704
y = self .clone ().apply_simple_reflection (i ,side )
@@ -834,18 +833,18 @@ def to_lehmer_code(self, typ='decreasing', side='right'):
834
833
"""
835
834
code = [0 for i in range (self .k + 1 )]
836
835
if typ [0 ] == 'i' and side [0 ] == 'r' :
837
- #Find number of positions to the right of position i with smaller
838
- #value than the number in position i.
836
+ # Find number of positions to the right of position i with smaller
837
+ # value than the number in position i.
839
838
for i in range (self .k + 1 ):
840
839
a = self (i )
841
840
for j in range (i + 1 , i + self .k + 1 ):
842
841
b = self (j )
843
842
if b < a :
844
843
code [i ] += (a - b ) // (self .k + 1 ) + 1
845
844
elif typ [0 ] == 'd' and side [0 ] == 'r' :
846
- #Find number of positions to the left of position i with larger
847
- #value than the number in position i. Then cyclically shift
848
- #the resulting vector.
845
+ # Find number of positions to the left of position i with larger
846
+ # value than the number in position i. Then cyclically shift
847
+ # the resulting vector.
849
848
for i in range (self .k + 1 ):
850
849
a = self (i )
851
850
for j in range (i - self .k , i ):
@@ -855,18 +854,18 @@ def to_lehmer_code(self, typ='decreasing', side='right'):
855
854
if a < b :
856
855
code [i - 1 ] += ((b - a )// (self .k + 1 )+ 1 )
857
856
elif typ [0 ] == 'i' and side [0 ] == 'l' :
858
- #Find number of positions to the right of i smaller than i, then
859
- #cyclically shift the resulting vector.
857
+ # Find number of positions to the right of i smaller than i, then
858
+ # cyclically shift the resulting vector.
860
859
for i in range (self .k + 1 ):
861
860
pos = self .position (i )
862
861
for j in range (pos + 1 , pos + self .k + 1 ):
863
862
b = self (j )
864
- #A small rotation is necessary for the reduced word from
865
- #the lehmer code to match the element.
863
+ # A small rotation is necessary for the reduced word from
864
+ # the lehmer code to match the element.
866
865
if b < i :
867
866
code [i - 1 ] += (i - b ) // (self .k + 1 ) + 1
868
867
elif typ [0 ] == 'd' and side [0 ] == 'l' :
869
- #Find number of positions to the left of i larger than i.
868
+ # Find number of positions to the left of i larger than i.
870
869
for i in range (self .k + 1 ):
871
870
pos = self .position (i )
872
871
for j in range (pos - self .k , pos ):
@@ -1103,7 +1102,7 @@ def value(self, i):
1103
1102
1104
1103
sage: C = AffinePermutationGroup(['C',4,1])
1105
1104
sage: x = C.one()
1106
- sage: [ x.value(i) for i in range(-10,10)] == list( range(-10,10))
1105
+ sage: all( x.value(i) == i for i in range(-10,10))
1107
1106
True
1108
1107
"""
1109
1108
N = 2 * self .k + 1
@@ -1124,7 +1123,7 @@ def position(self, i):
1124
1123
1125
1124
sage: C = AffinePermutationGroup(['C',4,1])
1126
1125
sage: x = C.one()
1127
- sage: [ x.position(i) for i in range(-10,10)] == list( range(-10,10))
1126
+ sage: all( x.position(i) == i for i in range(-10,10))
1128
1127
True
1129
1128
"""
1130
1129
N = 2 * self .k + 1
@@ -2242,12 +2241,12 @@ def one(self):
2242
2241
True
2243
2242
sage: TestSuite(A).run()
2244
2243
"""
2245
- return self (list ( range (1 , self .k + 2 ) ))
2244
+ return self (range (1 , self .k + 2 ))
2246
2245
2247
- #------------------------
2248
- #Type-unique methods.
2249
- #(Methods which do not exist in all types.)
2250
- #------------------------
2246
+ # ------------------------
2247
+ # Type-unique methods.
2248
+ # (Methods which do not exist in all types.)
2249
+ # ------------------------
2251
2250
def from_lehmer_code (self , C , typ = 'decreasing' , side = 'right' ):
2252
2251
r"""
2253
2252
Return the affine permutation with the supplied Lehmer code (a weak
@@ -2353,7 +2352,7 @@ def one(self):
2353
2352
True
2354
2353
sage: TestSuite(C).run()
2355
2354
"""
2356
- return self (list ( range (1 , self .k + 1 ) ))
2355
+ return self (range (1 , self .k + 1 ))
2357
2356
2358
2357
Element = AffinePermutationTypeC
2359
2358
0 commit comments