Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/sage/combinat/alternating_sign_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ def number_of_negative_ones(self):

number_negative_ones = number_of_negative_ones

def is_permutation(self):
def is_permutation(self) -> bool:
"""
Return ``True`` if ``self`` is a permutation matrix
and ``False`` otherwise.
Expand Down
10 changes: 5 additions & 5 deletions src/sage/combinat/binary_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ def node_to_str(bt):
t_repr._baseline = t_repr._h - 1
return t_repr

def _sort_key(self):
def _sort_key(self) -> tuple:
"""
Return a tuple of nonnegative integers encoding the binary
tree ``self``.
Expand Down Expand Up @@ -673,7 +673,7 @@ def _sort_key(self):
resu = [l] + [u for t in self for u in t._sort_key()]
return tuple(resu)

def is_empty(self):
def is_empty(self) -> bool:
"""
Return whether ``self`` is empty.

Expand Down Expand Up @@ -3619,7 +3619,7 @@ def builder(i, p):
for p in shuffle(W(l), W([shift + ri for ri in r])):
yield builder(shift, p)

def is_full(self):
def is_full(self) -> bool:
r"""
Return ``True`` if ``self`` is full, else return ``False``.

Expand Down Expand Up @@ -3789,7 +3789,7 @@ def prune(self):
return BinaryTree()
return BinaryTree([self[0].prune(), self[1].prune()])

def is_perfect(self):
def is_perfect(self) -> bool:
r"""
Return ``True`` if ``self`` is perfect, else return ``False``.

Expand Down Expand Up @@ -3836,7 +3836,7 @@ def is_perfect(self):
"""
return 2 ** self.depth() - 1 == self.node_number()

def is_complete(self):
def is_complete(self) -> bool:
r"""
Return ``True`` if ``self`` is complete, else return ``False``.

Expand Down
2 changes: 1 addition & 1 deletion src/sage/combinat/cartesian_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def __iterate__(self):
"""
return iter(self._mrange)

def is_finite(self):
def is_finite(self) -> bool:
"""
The Cartesian product is finite if all of its inputs are
finite, or if any input is empty.
Expand Down
92 changes: 47 additions & 45 deletions src/sage/combinat/cluster_algebra_quiver/cluster_seed.py
Original file line number Diff line number Diff line change
Expand Up @@ -4175,7 +4175,7 @@
A seed for a cluster algebra of rank 10 of type ['E', 8, [1, 1]]
sage: S._mutation_type = S._quiver._mutation_type = None; S
A seed for a cluster algebra of rank 10
sage: S.mutation_type() # long time

Check warning on line 4178 in src/sage/combinat/cluster_algebra_quiver/cluster_seed.py

View workflow job for this annotation

GitHub Actions / Conda (ubuntu, Python 3.12, new)

Warning: slow doctest:

slow doctest:: Test ran for 47.04s cpu, 47.26s wall Check ran for 0.00s cpu, 0.00s wall

Check warning on line 4178 in src/sage/combinat/cluster_algebra_quiver/cluster_seed.py

View workflow job for this annotation

GitHub Actions / test-long (src/sage/[a-f]*)

Warning: slow doctest:

slow doctest:: Test ran for 238.52s cpu, 239.72s wall Check ran for 0.00s cpu, 0.00s wall
['E', 8, [1, 1]]

- the not yet working affine type D::
Expand Down Expand Up @@ -4833,7 +4833,7 @@
return ans


def is_LeeLiZel_allowable(T, n, m, b, c):
def is_LeeLiZel_allowable(T, n, m, b, c) -> bool:
"""
Check if the subset `T` contributes to the computation of the greedy element `x[m,n]` in the rank two `(b,c)`-cluster algebra.

Expand All @@ -4848,52 +4848,54 @@
True
"""
horiz = set(T).intersection(PathSubset(n, 0))
vert = set(T).symmetric_difference(horiz)
if len(horiz) == 0 or len(vert) == 0:
if not horiz:
return True
else:
Latt = SetToPath(PathSubset(n, m))
for u in horiz:
from sage.combinat.words.word import Word
from sage.modules.free_module_element import vector
WW = Word(Latt)
LattCycled = vector(WW.conjugate(Latt.index(u))).list()
for v in vert:
uv_okay = False
for A in range(LattCycled.index(v)):
EA = []
AF = copy(LattCycled)
for i in range(LattCycled.index(v), len(LattCycled)-1):
AF.pop()
AF.reverse()
for i in range(A+1):
EA.append(LattCycled[i])
AF.pop()
AF.reverse()
nAF1 = 0
for i in range(len(AF)):
if AF[i] % 2 == 1:
nAF1 += 1
nAF2 = 0
for i in range(len(AF)):
if AF[i] % 2 == 0 and AF[i] in vert:
nAF2 += 1
nEA2 = 0
for i in range(len(EA)):
if EA[i] % 2 == 0:
nEA2 += 1
nEA1 = 0
for i in range(len(EA)):
if EA[i] % 2 == 1 and EA[i] in horiz:
nEA1 += 1
if nAF1 == b*nAF2 or nEA2 == c*nEA1:
uv_okay = True
if not uv_okay:
return False
vert = set(T).symmetric_difference(horiz)
if not vert:
return True


def get_green_vertices(C):
Latt = SetToPath(PathSubset(n, m))
for u in horiz:
from sage.combinat.words.word import Word
from sage.modules.free_module_element import vector
WW = Word(Latt)
LattCycled = vector(WW.conjugate(Latt.index(u))).list()
for v in vert:
uv_okay = False
for A in range(LattCycled.index(v)):
EA = []
AF = copy(LattCycled)
for i in range(LattCycled.index(v), len(LattCycled) - 1):
AF.pop()
AF.reverse()
for i in range(A + 1):
EA.append(LattCycled[i])
AF.pop()
AF.reverse()
nAF1 = 0
for i in range(len(AF)):
if AF[i] % 2 == 1:
nAF1 += 1
nAF2 = 0
for i in range(len(AF)):
if AF[i] % 2 == 0 and AF[i] in vert:
nAF2 += 1
nEA2 = 0
for i in range(len(EA)):
if EA[i] % 2 == 0:
nEA2 += 1
nEA1 = 0
for i in range(len(EA)):
if EA[i] % 2 == 1 and EA[i] in horiz:
nEA1 += 1
if nAF1 == b * nAF2 or nEA2 == c * nEA1:
uv_okay = True
if not uv_okay:
return False
return True


def get_green_vertices(C) -> list[int]:
r"""
Get the green vertices from a matrix.

Expand All @@ -4914,7 +4916,7 @@
return [i for i, v in enumerate(C.columns()) if any(x > 0 for x in v)]


def get_red_vertices(C):
def get_red_vertices(C) -> list[int]:
r"""
Get the red vertices from a matrix.

Expand Down
19 changes: 9 additions & 10 deletions src/sage/combinat/cluster_algebra_quiver/quiver_mutation_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ def cartan_matrix(self):
# return CartanMatrix(cmat)
return cmat

def is_irreducible(self):
def is_irreducible(self) -> bool:
"""
Return ``True`` if ``self`` is irreducible.

Expand All @@ -897,7 +897,7 @@ def is_irreducible(self):
"""
return self._info['irreducible']

def is_mutation_finite(self):
def is_mutation_finite(self) -> bool:
"""
Return ``True`` if ``self`` is of finite mutation type.

Expand All @@ -912,7 +912,7 @@ def is_mutation_finite(self):
"""
return self._info['mutation_finite']

def is_simply_laced(self):
def is_simply_laced(self) -> bool:
"""
Return ``True`` if ``self`` is simply laced.

Expand All @@ -935,7 +935,7 @@ def is_simply_laced(self):
"""
return self._info['simply_laced']

def is_skew_symmetric(self):
def is_skew_symmetric(self) -> bool:
"""
Return ``True`` if the B-matrix of ``self`` is skew-symmetric.

Expand All @@ -955,7 +955,7 @@ def is_skew_symmetric(self):
"""
return self._info['skew_symmetric']

def is_finite(self):
def is_finite(self) -> bool:
"""
Return ``True`` if ``self`` is of finite type.

Expand All @@ -974,7 +974,7 @@ def is_finite(self):
"""
return self._info['finite']

def is_affine(self):
def is_affine(self) -> bool:
"""
Return ``True`` if ``self`` is of affine type.

Expand All @@ -990,10 +990,9 @@ def is_affine(self):
"""
if self.is_irreducible():
return self._info['affine']
else:
return False
return False

def is_elliptic(self):
def is_elliptic(self) -> bool:
"""
Return ``True`` if ``self`` is of elliptic type.

Expand All @@ -1012,7 +1011,7 @@ def is_elliptic(self):
else:
return False

def properties(self):
def properties(self) -> None:
"""
Print a scheme of all properties of ``self``.

Expand Down
2 changes: 1 addition & 1 deletion src/sage/combinat/colored_permutations.py
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,7 @@ def fixed_point_polynomial(self, q=None):
q = PolynomialRing(ZZ, 'q').gen(0)
return prod(q + d - 1 for d in self.degrees())

def is_well_generated(self):
def is_well_generated(self) -> bool:
r"""
Return if ``self`` is a well-generated complex reflection group.

Expand Down
4 changes: 2 additions & 2 deletions src/sage/combinat/composition_tableau.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def weight(self):
for row in self:
for i in row:
w[i] += 1
return Composition([w[i] for i in range(1, self.size()+1)])
return Composition([w[i] for i in range(1, self.size() + 1)])

def descent_set(self):
r"""
Expand Down Expand Up @@ -253,7 +253,7 @@ def shape_partition(self):
"""
return Partition(sorted((len(row) for row in self), reverse=True))

def is_standard(self):
def is_standard(self) -> bool:
r"""
Return ``True`` if ``self`` is a standard composition tableau and
``False`` otherwise.
Expand Down
15 changes: 7 additions & 8 deletions src/sage/combinat/constellation.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def __hash__(self):
raise ValueError("cannot hash mutable constellation")
return hash(tuple(self._g))

def set_immutable(self):
def set_immutable(self) -> None:
r"""
Do nothing, as ``self`` is already immutable.

Expand All @@ -245,7 +245,7 @@ def set_immutable(self):
"""
self._mutable = False

def is_mutable(self):
def is_mutable(self) -> bool:
r"""
Return ``False`` as ``self`` is immutable.

Expand Down Expand Up @@ -429,7 +429,7 @@ def mutable_copy(self):

# GENERAL PROPERTIES

def is_connected(self):
def is_connected(self) -> bool:
r"""
Test of connectedness.

Expand All @@ -444,10 +444,9 @@ def is_connected(self):
"""
if self._connected:
return True
else:
return perms_are_connected(self._g, self.degree())
return perms_are_connected(self._g, self.degree())

def connected_components(self):
def connected_components(self) -> list:
"""
Return the connected components.

Expand Down Expand Up @@ -946,7 +945,7 @@ def __init__(self, length, degree, sym=None, connected=True):

self._connected = bool(connected)

def is_empty(self):
def is_empty(self) -> bool:
r"""
Return whether this set of constellations is empty.

Expand All @@ -961,7 +960,7 @@ def is_empty(self):
"""
return self._connected and self._length == 1 and self._degree > 1

def __contains__(self, elt):
def __contains__(self, elt) -> bool:
r"""
TESTS::

Expand Down
2 changes: 1 addition & 1 deletion src/sage/combinat/crystals/littelmann_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ def weight(x):
return sum(q**(c[0].energy_function()) * B.sum(B(weight(b)) for b in c) for c in C)
return B.sum(q**(b.energy_function()) * B(weight(b)) for b in self)

def is_perfect(self, level=1):
def is_perfect(self, level=1) -> bool:
r"""
Check whether the crystal ``self`` is perfect (of level ``level``).

Expand Down
5 changes: 3 additions & 2 deletions src/sage/combinat/crystals/pbw_datum.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,11 @@ class PBWDatum():
self.long_word == other_PBWDatum.long_word and
self.lusztig_datum == other_PBWDatum.lusztig_datum)

def is_equivalent_to(self, other_pbw_datum):
def is_equivalent_to(self, other_pbw_datum) -> bool:
r"""
Return whether ``self`` is equivalent to ``other_pbw_datum``.
modulo the tropical Plücker relations.

Here equivalent means modulo the tropical Plücker relations.

EXAMPLES::

Expand Down
3 changes: 1 addition & 2 deletions src/sage/combinat/debruijn_sequence.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ cdef gen(int t, int p, k, n):
gen(t + 1, t, k, n)


def is_debruijn_sequence(seq, k, n):
def is_debruijn_sequence(seq, k, n) -> bool:
r"""
Given a sequence of integer elements in `0, \ldots, k-1`, tests whether it
corresponds to a De Bruijn sequence of parameters `k` and `n`.
Expand All @@ -133,7 +133,6 @@ def is_debruijn_sequence(seq, k, n):
sage: is_debruijn_sequence([1] + s[1:], 2, 3)
False
"""

if k == 1:
return seq == [0]

Expand Down
Loading
Loading