-
-
Notifications
You must be signed in to change notification settings - Fork 648
Convert partitions into skew partitions automatically #40580
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
darijgr
wants to merge
4
commits into
sagemath:develop
Choose a base branch
from
darijgr:skewpar
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+55
−6
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -121,6 +121,14 @@ | |||||||||||||||||||||||
sage: SkewPartition([[4,3,1],[2]]).outer_corners() | ||||||||||||||||||||||||
[(0, 3), (1, 2), (2, 0)] | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
Any partition `p` can be viewed as a skew partition | ||||||||||||||||||||||||
`p / ()`. This is implemented as a default conversion:: | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
sage: SkewPartition([2,2,1]) | ||||||||||||||||||||||||
[2, 2, 1] / [] | ||||||||||||||||||||||||
sage: SkewPartition(Partition([2])) | ||||||||||||||||||||||||
[2] / [] | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
AUTHORS: | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
- Mike Hansen: Initial version | ||||||||||||||||||||||||
|
@@ -154,7 +162,7 @@ | |||||||||||||||||||||||
from sage.misc.lazy_import import lazy_import | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
from sage.combinat.combinat import CombinatorialElement | ||||||||||||||||||||||||
from sage.combinat.partition import Partitions, _Partitions | ||||||||||||||||||||||||
from sage.combinat.partition import Partitions, _Partitions, Partition | ||||||||||||||||||||||||
from sage.combinat.tableau import Tableaux | ||||||||||||||||||||||||
from sage.combinat.composition import Compositions | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
|
@@ -183,18 +191,36 @@ | |||||||||||||||||||||||
[2, 1] | ||||||||||||||||||||||||
sage: skp.outer() | ||||||||||||||||||||||||
[3, 2, 1] | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
Partitions can be converted into skew partitions:: | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
sage: skp = SkewPartition([3,3,2]); skp | ||||||||||||||||||||||||
[3, 3, 2] / [] | ||||||||||||||||||||||||
sage: skp = SkewPartition(Partition([3,3,2])); skp | ||||||||||||||||||||||||
[3, 3, 2] / [] | ||||||||||||||||||||||||
sage: skp = SkewPartition([]); skp | ||||||||||||||||||||||||
[] / [] | ||||||||||||||||||||||||
""" | ||||||||||||||||||||||||
skp = [_Partitions(p) for p in skp] | ||||||||||||||||||||||||
if skp not in SkewPartitions(): | ||||||||||||||||||||||||
try: | ||||||||||||||||||||||||
skp_list = [_Partitions(p) for p in skp] | ||||||||||||||||||||||||
except ValueError: | ||||||||||||||||||||||||
if skp in _Partitions: | ||||||||||||||||||||||||
return SkewPartitions()([_Partitions(skp), _Partitions([])]) | ||||||||||||||||||||||||
raise ValueError("invalid skew partition: %s" % p) | ||||||||||||||||||||||||
if skp_list not in SkewPartitions(): | ||||||||||||||||||||||||
if not skp_list: | ||||||||||||||||||||||||
return SkewPartitions()([_Partitions([]), _Partitions([])]) | ||||||||||||||||||||||||
raise ValueError("invalid skew partition: %s" % skp) | ||||||||||||||||||||||||
return SkewPartitions()(skp) | ||||||||||||||||||||||||
return SkewPartitions()(skp_list) | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
def __init__(self, parent, skp): | ||||||||||||||||||||||||
""" | ||||||||||||||||||||||||
TESTS:: | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
sage: skp = SkewPartition([[3,2,1],[2,1]]) | ||||||||||||||||||||||||
sage: TestSuite(skp).run() | ||||||||||||||||||||||||
sage: skp = SkewPartition([3,2,1]) | ||||||||||||||||||||||||
sage: TestSuite(skp).run() | ||||||||||||||||||||||||
""" | ||||||||||||||||||||||||
CombinatorialElement.__init__(self, parent, | ||||||||||||||||||||||||
[_Partitions(skp[0]), _Partitions(skp[1])]) | ||||||||||||||||||||||||
|
@@ -1490,7 +1516,15 @@ | |||||||||||||||||||||||
sage: S = SkewPartitions() | ||||||||||||||||||||||||
sage: S([[3,1], [1]]) | ||||||||||||||||||||||||
[3, 1] / [1] | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
TESTS:: | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
sage: S = SkewPartitions() | ||||||||||||||||||||||||
sage: S(Partition([3,2])) | ||||||||||||||||||||||||
[3, 2] / [] | ||||||||||||||||||||||||
""" | ||||||||||||||||||||||||
if skp in _Partitions: | ||||||||||||||||||||||||
skp = SkewPartition(skp) | ||||||||||||||||||||||||
return self.element_class(self, skp) | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
def __contains__(self, x): | ||||||||||||||||||||||||
|
@@ -1535,9 +1569,13 @@ | |||||||||||||||||||||||
False | ||||||||||||||||||||||||
sage: [[1,1,1,0],[1,1,0,0]] in SkewPartitions() | ||||||||||||||||||||||||
True | ||||||||||||||||||||||||
sage: Partition([3,2]) in SkewPartitions() | ||||||||||||||||||||||||
True | ||||||||||||||||||||||||
""" | ||||||||||||||||||||||||
if isinstance(x, SkewPartition): | ||||||||||||||||||||||||
return True | ||||||||||||||||||||||||
if isinstance(x, Partition): | ||||||||||||||||||||||||
return True | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
try: | ||||||||||||||||||||||||
if len(x) != 2: | ||||||||||||||||||||||||
|
@@ -1798,9 +1836,15 @@ | |||||||||||||||||||||||
False | ||||||||||||||||||||||||
sage: [[7, 4, 3, 2], [5, 2, 1]] in SkewPartitions(8, overlap=-2) | ||||||||||||||||||||||||
True | ||||||||||||||||||||||||
sage: Partition([2, 1]) in SkewPartitions(3) | ||||||||||||||||||||||||
True | ||||||||||||||||||||||||
sage: Partition([2, 1]) in SkewPartitions(4) | ||||||||||||||||||||||||
False | ||||||||||||||||||||||||
""" | ||||||||||||||||||||||||
return x in SkewPartitions() \ | ||||||||||||||||||||||||
and sum(x[0])-sum(x[1]) == self.n \ | ||||||||||||||||||||||||
if not x in SkewPartitions(): | ||||||||||||||||||||||||
return False | ||||||||||||||||||||||||
x = SkewPartition(x) | ||||||||||||||||||||||||
return sum(x[0])-sum(x[1]) == self.n \ | ||||||||||||||||||||||||
and self.overlap <= SkewPartition(x).overlap() | ||||||||||||||||||||||||
Comment on lines
+1844
to
1848
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||
|
||||||||||||||||||||||||
def _repr_(self): | ||||||||||||||||||||||||
|
@@ -1972,8 +2016,13 @@ | |||||||||||||||||||||||
False | ||||||||||||||||||||||||
sage: [[5,4,3,1],[3,3,1]] in SkewPartitions(row_lengths=[2,1,2,1]) | ||||||||||||||||||||||||
True | ||||||||||||||||||||||||
sage: Partition([2, 1]) in SkewPartitions(row_lengths=[2,1]) | ||||||||||||||||||||||||
True | ||||||||||||||||||||||||
sage: Partition([2, 1]) in SkewPartitions(row_lengths=[2,2]) | ||||||||||||||||||||||||
False | ||||||||||||||||||||||||
""" | ||||||||||||||||||||||||
if x in SkewPartitions(): | ||||||||||||||||||||||||
x = SkewPartition(x) | ||||||||||||||||||||||||
Comment on lines
2024
to
+2025
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||
o = x[0] | ||||||||||||||||||||||||
i = x[1]+[0]*(len(x[0])-len(x[1])) | ||||||||||||||||||||||||
return [u[0]-u[1] for u in zip(o,i)] == self.co | ||||||||||||||||||||||||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Less indirection (so faster) and will result in the correct parent. Please add an analogous test with a different parent (such as
SkewPartitions(4)
) and make sure it has the correct output.