24
24
# Distributed under the terms of the GNU General Public License (GPL)
25
25
# https://www.gnu.org/licenses/
26
26
# ****************************************************************************
27
+ from __future__ import annotations
27
28
from sage .rings .integer_ring import ZZ
28
29
from sage .arith .all import lcm
29
30
from sage .rings .polynomial .polynomial_ring_constructor import PolynomialRing
@@ -97,7 +98,7 @@ def CyclicSievingPolynomial(L, cyc_act=None, order=None, get_order=False):
97
98
else :
98
99
orbit_sizes [length ] = 1
99
100
100
- n = lcm (list ( orbit_sizes ) )
101
+ n = lcm (orbit_sizes )
101
102
102
103
if order :
103
104
if order .mod (n ):
@@ -110,19 +111,16 @@ def CyclicSievingPolynomial(L, cyc_act=None, order=None, get_order=False):
110
111
if i == 0 :
111
112
j = sum (orbit_sizes .values ())
112
113
else :
113
- j = sum (orbit_sizes [ l ] for l in orbit_sizes
114
- if ZZ (i ).mod (n / l ) == 0 )
114
+ j = sum (orb for l , orb in orbit_sizes . items ()
115
+ if not ZZ (i ).mod (n // l ))
115
116
p += j * q ** i
116
117
117
118
p = p (q ** (order // n ))
118
119
119
- if get_order :
120
- return [p , order ]
121
- else :
122
- return p
120
+ return [p , order ] if get_order else p
123
121
124
122
125
- def CyclicSievingCheck (L , cyc_act , f , order = None ):
123
+ def CyclicSievingCheck (L , cyc_act , f , order = None ) -> bool :
126
124
"""
127
125
Return whether the triple ``(L, cyc_act, f)`` exhibits
128
126
the cyclic sieving phenomenon.
@@ -162,11 +160,10 @@ def CyclicSievingCheck(L, cyc_act, f, order=None):
162
160
get_order = True )
163
161
R = p1 .parent ()
164
162
q = R .gen ()
165
- p2 = R (f ).mod (q ** n - 1 )
166
- return p1 == p2
163
+ return p1 == R (f ).mod (q ** n - 1 )
167
164
168
165
169
- def orbit_decomposition (L , cyc_act ):
166
+ def orbit_decomposition (L , cyc_act ) -> list [ list ] :
170
167
"""
171
168
Return the orbit decomposition of ``L`` by the action of ``cyc_act``.
172
169
@@ -196,7 +193,7 @@ def orbit_decomposition(L, cyc_act):
196
193
"""
197
194
orbits = []
198
195
L_prime = set (L )
199
- while L_prime != set () :
196
+ while L_prime :
200
197
obj = L_prime .pop ()
201
198
orbit = [obj ]
202
199
obj = cyc_act (obj )
0 commit comments