Skip to content

Commit 346459a

Browse files
author
Release Manager
committed
Trac #32952: some details in cyclic sieving
about code and annotations URL: https://trac.sagemath.org/32952 Reported by: chapoton Ticket author(s): Frédéric Chapoton Reviewer(s): Travis Scrimshaw
2 parents 20095b7 + aa3424f commit 346459a

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

src/sage/combinat/cyclic_sieving_phenomenon.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
# Distributed under the terms of the GNU General Public License (GPL)
2525
# https://www.gnu.org/licenses/
2626
# ****************************************************************************
27+
from __future__ import annotations
2728
from sage.rings.integer_ring import ZZ
2829
from sage.arith.all import lcm
2930
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
@@ -97,7 +98,7 @@ def CyclicSievingPolynomial(L, cyc_act=None, order=None, get_order=False):
9798
else:
9899
orbit_sizes[length] = 1
99100

100-
n = lcm(list(orbit_sizes))
101+
n = lcm(orbit_sizes)
101102

102103
if order:
103104
if order.mod(n):
@@ -110,19 +111,16 @@ def CyclicSievingPolynomial(L, cyc_act=None, order=None, get_order=False):
110111
if i == 0:
111112
j = sum(orbit_sizes.values())
112113
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))
115116
p += j * q**i
116117

117118
p = p(q**(order // n))
118119

119-
if get_order:
120-
return [p, order]
121-
else:
122-
return p
120+
return [p, order] if get_order else p
123121

124122

125-
def CyclicSievingCheck(L, cyc_act, f, order=None):
123+
def CyclicSievingCheck(L, cyc_act, f, order=None) -> bool:
126124
"""
127125
Return whether the triple ``(L, cyc_act, f)`` exhibits
128126
the cyclic sieving phenomenon.
@@ -162,11 +160,10 @@ def CyclicSievingCheck(L, cyc_act, f, order=None):
162160
get_order=True)
163161
R = p1.parent()
164162
q = R.gen()
165-
p2 = R(f).mod(q**n - 1)
166-
return p1 == p2
163+
return p1 == R(f).mod(q**n - 1)
167164

168165

169-
def orbit_decomposition(L, cyc_act):
166+
def orbit_decomposition(L, cyc_act) -> list[list]:
170167
"""
171168
Return the orbit decomposition of ``L`` by the action of ``cyc_act``.
172169
@@ -196,7 +193,7 @@ def orbit_decomposition(L, cyc_act):
196193
"""
197194
orbits = []
198195
L_prime = set(L)
199-
while L_prime != set():
196+
while L_prime:
200197
obj = L_prime.pop()
201198
orbit = [obj]
202199
obj = cyc_act(obj)

0 commit comments

Comments
 (0)