Skip to content

add add_entry and anti_restrict methods to SkewTableau #39918

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

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from

Conversation

jmcdonough98
Copy link

add_entry and anti_restrict are already existing methods in Tableau, but they also make sense for SkewTableau.
This PR ports these methods to SkewTableau, and adds a simple check to add_entry to avoid trying to construct a new tableau when the given cell is too large.

📝 Checklist

  • The title is concise and informative.
  • The description explains in detail what this PR is about.
  • I have linked a relevant issue or discussion.
  • I have created tests covering the changes.
  • I have updated the documentation and checked the documentation preview.

⌛ Dependencies

None

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

src/sage/combinat/tableau.py:3193

  • The new condition in add_entry adds a constraint that may unintentionally block valid cells in edge cases. Please verify that this additional check correctly handles all tableau shapes and add a comment explaining its intent.
if c == len(tab_r) and (r == 0 or len(tab_r) < len(tab[r-1])):

sage: S.anti_restrict(1).anti_restrict(2) == S.anti_restrict(2)
True
"""
t_new = [[None if g <= n else g for g in row] for row in self]
Copy link
Preview

Copilot AI Apr 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comparing elements to n without first checking for None may raise a TypeError if a row contains None values. Consider adding an explicit check (e.g., 'if g is not None and g <= n') to safely perform the comparison.

Suggested change
t_new = [[None if g <= n else g for g in row] for row in self]
t_new = [[None if g is not None and g <= n else g for g in row] for row in self]

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Write a test to address this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just kidding - None acts like -oo

sage: S.add_entry([1000,1000], 3)
Traceback (most recent call last):
...
IndexError: (1000, 1000) is not an addable cell of the tableau
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add tests for [0,1000], [1000,0] also maybe adding [1000,0] to [2,1]/[1] (should err). This should address any concerns Copilot is potentially raising.

if c == len(tab_r) and (r == 0 or len(tab_r) < len(tab[r-1])):
tab_r.append(m)
else:
raise IndexError('%s is not an addable cell of the tableau' % ((r, c),))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider saying if the issue is with row or column?

if r == len(tab) and c == 0:
tab.append([m])
else:
raise IndexError('%s is not an addable cell of the tableau' % ((r, c),))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe check here for bottom left cell None (per our in-person conversation)

else:
try:
return self.parent().Element(tab)
except Exception:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this except be more narrow? (Maybe also change in regular Tableau?)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(E.g. TypeError)

@@ -3190,7 +3190,7 @@ def add_entry(self, cell, m):
raise IndexError('%s is not an addable cell of the tableau' % ((r, c),))
else:
tab_r = tab[r]
if c == len(tab_r):
if c == len(tab_r) and (r == 0 or len(tab_r) < len(tab[r-1])):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a test where c== len(tab_r) and r != 0, and another test where c == len(tab_r) and len(tab_r) < len(tab[r-1]).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants