Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typing and details in tableaux files #39477

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
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
22 changes: 13 additions & 9 deletions src/sage/combinat/ribbon_tableau.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
from sage.rings.integer import Integer
from sage.combinat.combinat import CombinatorialElement
from sage.combinat.skew_partition import SkewPartition, SkewPartitions
from sage.combinat.skew_tableau import SkewTableau, SkewTableaux, SemistandardSkewTableaux
from sage.combinat.skew_tableau import (SkewTableau, SkewTableaux,
SemistandardSkewTableaux)
from sage.combinat.tableau import Tableaux
from sage.combinat.partition import Partition, _Partitions
from sage.combinat.permutation import to_standard
Expand Down Expand Up @@ -94,7 +95,8 @@
try:
rt = [tuple(row) for row in rt]
except TypeError:
raise TypeError("each element of the ribbon tableau must be an iterable")
raise TypeError("each element of the ribbon tableau "

Check warning on line 98 in src/sage/combinat/ribbon_tableau.py

View check run for this annotation

Codecov / codecov/patch

src/sage/combinat/ribbon_tableau.py#L98

Added line #L98 was not covered by tests
"must be an iterable")
if not all(row for row in rt):
raise TypeError("a ribbon tableau cannot have empty rows")
# calls the inherited __init__ method (of SkewTableau )
Expand Down Expand Up @@ -195,9 +197,10 @@

REFERENCES:

.. [vanLeeuwen91] Marc. A. A. van Leeuwen, *Edge sequences, ribbon tableaux,
and an action of affine permutations*. Europe J. Combinatorics. **20**
(1999). http://wwwmathlabo.univ-poitiers.fr/~maavl/pdf/edgeseqs.pdf
.. [vanLeeuwen91] Marc. A. A. van Leeuwen, *Edge sequences,
ribbon tableaux, and an action of affine permutations*.
Europe J. Combinatorics. **20** (1999).
http://wwwmathlabo.univ-poitiers.fr/~maavl/pdf/edgeseqs.pdf
"""
@staticmethod
def __classcall_private__(cls, shape=None, weight=None, length=None):
Expand Down Expand Up @@ -318,10 +321,11 @@
sage: RibbonTableaux([[2,2],[]],[1,1],2).list()
[[[0, 0], [1, 2]], [[1, 0], [2, 0]]]
"""
for x in graph_implementation_rec(self._shape, self._weight, self._length, list_rec):
for x in graph_implementation_rec(self._shape, self._weight,
self._length, list_rec):
yield self.from_expr(x)

def _repr_(self):
def _repr_(self) -> str:
"""
Return a string representation of ``self``.

Expand All @@ -332,7 +336,7 @@
"""
return "Ribbon tableaux of shape %s and weight %s with %s-ribbons" % (repr(self._shape), list(self._weight), self._length)

def __contains__(self, x):
def __contains__(self, x) -> bool:
"""
Note that this just checks to see if ``x`` appears in ``self``.

Expand Down Expand Up @@ -855,7 +859,7 @@
[5, 3, 1]
"""
weights = [x.weight() for x in self]
m = max([len(x) for x in weights])
m = max(len(x) for x in weights)
weight = [0] * m
for w in weights:
for i in range(len(w)):
Expand Down
18 changes: 9 additions & 9 deletions src/sage/combinat/skew_tableau.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ def weight(self):

evaluation = weight

def is_standard(self):
def is_standard(self) -> bool:
"""
Return ``True`` if ``self`` is a standard skew tableau and ``False``
otherwise.
Expand All @@ -640,7 +640,7 @@ def is_standard(self):
w = [i for row in self for i in row if i is not None]
return sorted(w) == list(range(1, len(w) + 1)) and self.is_semistandard()

def is_semistandard(self):
def is_semistandard(self) -> bool:
"""
Return ``True`` if ``self`` is a semistandard skew tableau and
``False`` otherwise.
Expand Down Expand Up @@ -1324,7 +1324,7 @@ def shuffle(self, t2):
corner = self.cells_containing(i)[0]

# slide t2_new backwards, record i in the vacated square
(t2_new, (x, y)) = t2_new.slide(corner, True)
t2_new, (x, y) = t2_new.slide(corner, True)
t1_new[x][y] = i

t1_new = SkewTableau(t1_new)
Expand Down Expand Up @@ -1582,10 +1582,12 @@ def to_expr(self):
rows.reverse()
return [self.inner_shape(), rows]

def is_ribbon(self):
def is_ribbon(self) -> bool:
r"""
Return ``True`` if and only if the shape of ``self`` is a
ribbon, that is, if it has exactly one cell in each of `q`
ribbon.

This means that it has exactly one cell in each of `q`
consecutive diagonals for some nonnegative integer `q`.

EXAMPLES::
Expand Down Expand Up @@ -1824,7 +1826,7 @@ def cells_containing(self, i):
cell_list.append((r, c))
return cell_list

def is_k_tableau(self, k):
def is_k_tableau(self, k) -> bool:
r"""
Check whether ``self`` is a valid skew weak `k`-tableau.

Expand Down Expand Up @@ -1857,11 +1859,9 @@ def _label_skew(list_of_cells, sk):
sage: skew_tableau._label_skew(l, empty)
[[1, 4], [3, 2]]
"""
i = 1
skew = [list(row) for row in sk]
for row, column in list_of_cells:
for i, (row, column) in enumerate(list_of_cells, start=1):
skew[row][column] = i
i += 1
return skew


Expand Down
28 changes: 14 additions & 14 deletions src/sage/combinat/tableau.py
Original file line number Diff line number Diff line change
Expand Up @@ -1298,7 +1298,7 @@
raise ValueError("the entries must be nonnegative integers")
from sage.matrix.matrix_space import MatrixSpace
if max_entry is None:
max_entry = max([max(c) for c in self])
max_entry = max(max(c) for c in self)

Check warning on line 1301 in src/sage/combinat/tableau.py

View check run for this annotation

Codecov / codecov/patch

src/sage/combinat/tableau.py#L1301

Added line #L1301 was not covered by tests
MS = MatrixSpace(ZZ, len(self[0]), max_entry)
Tconj = self.conjugate()
conj_len = len(Tconj)
Expand Down Expand Up @@ -1694,7 +1694,7 @@

evaluation = weight

def is_row_strict(self):
def is_row_strict(self) -> bool:
"""
Return ``True`` if ``self`` is a row strict tableau and ``False``
otherwise.
Expand All @@ -1715,7 +1715,7 @@
"""
return all(row[i] < row[i+1] for row in self for i in range(len(row)-1))

def is_row_increasing(self, weak=False):
def is_row_increasing(self, weak=False) -> bool:
r"""
Return ``True`` if the entries in each row are in increasing order,
and ``False`` otherwise.
Expand All @@ -1741,7 +1741,7 @@
return a < b
return all(test(a, b) for row in self for (a, b) in zip(row, row[1:]))

def is_column_increasing(self, weak=False):
def is_column_increasing(self, weak=False) -> bool:
r"""
Return ``True`` if the entries in each column are in increasing order,
and ``False`` otherwise.
Expand Down Expand Up @@ -1770,7 +1770,7 @@
return all(test(a[i], b_i) for i, b_i in enumerate(b))
return all(tworow(self[r], self[r + 1]) for r in range(len(self) - 1))

def is_column_strict(self):
def is_column_strict(self) -> bool:
"""
Return ``True`` if ``self`` is a column strict tableau and ``False``
otherwise.
Expand Down Expand Up @@ -1801,7 +1801,7 @@
return all(a[i] < b_i for i, b_i in enumerate(b))
return all(tworow(self[r], self[r+1]) for r in range(len(self)-1))

def is_semistandard(self):
def is_semistandard(self) -> bool:
r"""
Return ``True`` if ``self`` is a semistandard tableau, and ``False``
otherwise.
Expand All @@ -1824,7 +1824,7 @@
"""
return self.is_row_increasing(weak=True) and self.is_column_increasing()

def is_standard(self):
def is_standard(self) -> bool:
"""
Return ``True`` if ``self`` is a standard tableau and ``False``
otherwise.
Expand All @@ -1843,7 +1843,7 @@
entries = sorted(self.entries())
return entries == list(range(1, self.size() + 1)) and self.is_row_strict() and self.is_column_strict()

def is_increasing(self):
def is_increasing(self) -> bool:
"""
Return ``True`` if ``self`` is an increasing tableau and
``False`` otherwise.
Expand All @@ -1865,7 +1865,7 @@
"""
return self.is_row_strict() and self.is_column_strict()

def is_rectangular(self):
def is_rectangular(self) -> bool:
"""
Return ``True`` if the tableau ``self`` is rectangular and
``False`` otherwise.
Expand Down Expand Up @@ -2067,7 +2067,7 @@

return res

def is_k_tableau(self, k):
def is_k_tableau(self, k) -> bool:
r"""
Check whether ``self`` is a valid weak `k`-tableau.

Expand Down Expand Up @@ -2518,7 +2518,7 @@
if not (self.is_semistandard()):
raise ValueError("reverse bumping is only defined for semistandard tableaux")
try:
(r, c) = loc
r, c = loc
if (r, c) not in self.corners():
raise ValueError("invalid corner")
except TypeError:
Expand Down Expand Up @@ -3177,7 +3177,7 @@
IndexError: (2, 2) is not an addable cell of the tableau
"""
tab = self.to_list()
(r, c) = cell
r, c = cell
try:
tab[r][c] = m # will work if we are replacing an entry
except IndexError:
Expand Down Expand Up @@ -3616,7 +3616,7 @@
except Exception:
return Tableau([[w[entry-1] for entry in row] for row in self])

def is_key_tableau(self):
def is_key_tableau(self) -> bool:
r"""
Return ``True`` if ``self`` is a key tableau or ``False`` otherwise.

Expand Down Expand Up @@ -4788,7 +4788,7 @@
return all(self.restrict(m).shape().dominates(t.restrict(m).shape())
for m in range(1, 1 + self.size()))

def is_standard(self):
def is_standard(self) -> bool:
"""
Return ``True`` since ``self`` is a standard tableau.

Expand Down
12 changes: 6 additions & 6 deletions src/sage/combinat/tableau_tuple.py
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ def entry(self, l, r, c):
"""
return self[l][r][c]

def is_row_strict(self):
def is_row_strict(self) -> bool:
"""
Return ``True`` if the tableau ``self`` is row strict and ``False``
otherwise.
Expand Down Expand Up @@ -874,7 +874,7 @@ def first_row_descent(self):
return (k, cell[0], cell[1])
return None

def is_column_strict(self):
def is_column_strict(self) -> bool:
"""
Return ``True`` if the tableau ``self`` is column strict and ``False``
otherwise.
Expand Down Expand Up @@ -925,7 +925,7 @@ def first_column_descent(self):
return (k, cell[0], cell[1])
return None

def is_standard(self):
def is_standard(self) -> bool:
r"""
Return ``True`` if the tableau ``self`` is a standard tableau and
``False`` otherwise.
Expand Down Expand Up @@ -1173,7 +1173,7 @@ def add_entry(self, cell, m):
...
IndexError: (2, 1, 2) is not an addable cell of the tableau
"""
(k, r, c) = cell
k, r, c = cell
tab = self.to_list()

try:
Expand Down Expand Up @@ -5017,7 +5017,7 @@ def random_element(self):
while m < mu.size():
m += 1
i = randint(0, len(addables) - 1) # index for a random addable cell
(k, r, c) = addables[i] # the actual cell
k, r, c = addables[i] # the actual cell
# remove the cell we just added from the list addable nodes
addables.pop(i)
# add m into the tableau
Expand Down Expand Up @@ -5336,7 +5336,7 @@ def _add_entry_fast(T, cell, m):
6 8 12 14 2 11
10
"""
(k, r, c) = cell
k, r, c = cell
tab = T.to_list()

try:
Expand Down
Loading