13
13
# ****************************************************************************
14
14
from itertools import repeat
15
15
16
- from sage .arith .misc import binomial
17
16
from sage .categories .affine_weyl_groups import AffineWeylGroups
18
17
from sage .combinat .composition import Composition
19
18
from sage .combinat .partition import Partition
@@ -77,13 +76,13 @@ def __init__(self, parent, lst, check=True):
77
76
"""
78
77
if check :
79
78
lst = [ZZ (val ) for val in lst ]
80
- self .k = parent .k
79
+ self .k = ZZ ( parent .k )
81
80
self .n = self .k + 1
82
- #This N doesn't matter for type A, but comes up in all other types.
81
+ # This N doesn't matter for type A, but comes up in all other types.
83
82
if parent .cartan_type ()[0 ] == 'A' :
84
83
self .N = self .n
85
84
elif parent .cartan_type ()[0 ] in ['B' , 'C' , 'D' ]:
86
- self .N = 2 * self .k + 1
85
+ self .N = 2 * self .k + 1
87
86
elif parent .cartan_type ()[0 ] == 'G' :
88
87
self .N = 6
89
88
else :
@@ -245,7 +244,7 @@ def is_i_grassmannian(self, i=0, side='right') -> bool:
245
244
"""
246
245
return self == self .parent ().one () or self .descents (side ) == [i ]
247
246
248
- def index_set (self ):
247
+ def index_set (self ) -> tuple :
249
248
r"""
250
249
Index set of the affine permutation group.
251
250
@@ -255,7 +254,7 @@ def index_set(self):
255
254
sage: A.index_set()
256
255
(0, 1, 2, 3, 4, 5, 6, 7)
257
256
"""
258
- return tuple (range (self .k + 1 ))
257
+ return tuple (range (self .k + 1 ))
259
258
260
259
def lower_covers (self , side = 'right' ):
261
260
r"""
@@ -440,13 +439,14 @@ def check(self):
440
439
if not self :
441
440
return
442
441
k = self .parent ().k
443
- #Type A.
442
+ # Type A
444
443
if len (self ) != k + 1 :
445
- raise ValueError ("length of list must be k+1=" + str (k + 1 ))
446
- if binomial (k + 2 ,2 ) != sum (self ):
447
- raise ValueError ("window does not sum to " + str (binomial ((k + 2 ),2 )))
448
- l = sorted ([i % (k + 1 ) for i in self ])
449
- if l != list (range (k + 1 )):
444
+ raise ValueError (f"length of list must be k+1={ k + 1 } " )
445
+ sigma = (k + 2 ).binomial (2 )
446
+ if sigma != sum (self ):
447
+ raise ValueError (f"window does not sum to { sigma } " )
448
+ l = sorted (i % (k + 1 ) for i in self )
449
+ if any (i != j for i , j in enumerate (l )):
450
450
raise ValueError ("entries must have distinct residues" )
451
451
452
452
def value (self , i , base_window = False ):
@@ -2001,9 +2001,9 @@ class AffinePermutationGroupGeneric(UniqueRepresentation, Parent):
2001
2001
methods for the specific affine permutation groups.
2002
2002
"""
2003
2003
2004
- #----------------------
2005
- #Type-free methods.
2006
- #----------------------
2004
+ # ----------------------
2005
+ # Type-free methods.
2006
+ # ----------------------
2007
2007
2008
2008
def __init__ (self , cartan_type ):
2009
2009
r"""
@@ -2014,13 +2014,13 @@ def __init__(self, cartan_type):
2014
2014
"""
2015
2015
Parent .__init__ (self , category = AffineWeylGroups ())
2016
2016
ct = CartanType (cartan_type )
2017
- self .k = ct .n
2017
+ self .k = ZZ ( ct .n )
2018
2018
self .n = ct .rank ()
2019
- #This N doesn't matter for type A, but comes up in all other types.
2019
+ # This N doesn't matter for type A, but comes up in all other types.
2020
2020
if ct .letter == 'A' :
2021
2021
self .N = self .k + 1
2022
2022
elif ct .letter == 'B' or ct .letter == 'C' or ct .letter == 'D' :
2023
- self .N = 2 * self .k + 1
2023
+ self .N = 2 * self .k + 1
2024
2024
elif ct .letter == 'G' :
2025
2025
self .N = 6
2026
2026
self ._cartan_type = ct
@@ -2034,14 +2034,14 @@ def _element_constructor_(self, *args, **keywords):
2034
2034
"""
2035
2035
return self .element_class (self , * args , ** keywords )
2036
2036
2037
- def _repr_ (self ):
2037
+ def _repr_ (self ) -> str :
2038
2038
r"""
2039
2039
TESTS::
2040
2040
2041
2041
sage: AffinePermutationGroup(['A',7,1])
2042
2042
The group of affine permutations of type ['A', 7, 1]
2043
2043
"""
2044
- return "The group of affine permutations of type " + str (self .cartan_type ())
2044
+ return "The group of affine permutations of type " + str (self .cartan_type ())
2045
2045
2046
2046
def _test_enumeration (self , n = 4 , ** options ):
2047
2047
r"""
0 commit comments