Opened 10 years ago
Closed 10 years ago
#13743 closed defect (fixed)
Bug in k-bounded symmetric functions
Reported by: | Chris Berg | Owned by: | Sage Combinat CC user |
---|---|---|---|
Priority: | major | Milestone: | sage-5.9 |
Component: | combinatorics | Keywords: | |
Cc: | Anne Schilling, Mike Zabrocki, Travis Scrimshaw, | Merged in: | sage-5.9.beta0 |
Authors: | Travis Scrimshaw | Reviewers: | Mike Zabrocki |
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | #13605 #14228 | Stopgaps: |
Description
The indices method of the KBoundedSubspace class is done wrong. The code is:
self.indices = ConstantFunction(Partitions(NonNegativeIntegers(), max_part=k))
Partitions is not meant to take a set. It will usually complain if you input something like NonNegativeIntegers? but due to a bug in partitions, it allows it if you have optional arguments.
This creates the following bugs when playing around with k-Schur functions:
sage: ks = SymmetricFunctions(QQ).kBoundedSubspace(3,1).kschur() sage: f = ks[2,1] sage: f.coefficient(f.support()[0]) --------------------------------------------------------------------------- AssertionError Traceback (most recent call last) /Users/chrisberg/<ipython console> in <module>() /Applications/sage/local/lib/python2.7/site-packages/sage/combinat/free_module.pyc in coefficient(self, m) 479 # that can be turned on or off 480 C = self.parent()._basis_keys --> 481 assert m in C, "%s should be an element of %s"%(m, C) 482 if hasattr(C, "element_class") and not isinstance(m, C.element_class): 483 m = C(m) AssertionError: [2, 1] should be an element of Partitions of the integer An example of an infinite enumerated set: the non negative integers satisfying constraints max_part=3
Attachments (1)
Change History (22)
comment:1 follow-up: 2 Changed 10 years ago by
comment:2 Changed 10 years ago by
You can just do
sage: ks = SymmetricFunctions(QQ).kschur(3,1) sage: f = ks[2,1] sage: f[Partition([2,1])] 1
Anne
comment:3 follow-up: 4 Changed 10 years ago by
Cc: | Travis Scrimshaw added |
---|---|
Dependencies: | → 13605 |
As far as I can tell, Travis' changes to Partitions may fix this bug. I am adding him as cc on this ticket. There are currently still conflicts between the symmetric functions and Partitions. Perhaps they are resolved it is possible that they will fix this problem so he can take this into account as he writes his patch. So for instance after I apply Travis' patch trac_13605-partition_options-ts.patch I have:
sage: ks = SymmetricFunctions(QQ).kBoundedSubspace(3,1).kschur() sage: f = ks([2,1]) sage: f.coefficient(f.support()[0]) 1
However the same patch currently causes a different problem with symmetric functions:
sage: ks[2,1] --------------------------------------------------------------------------- TypeError Traceback (most recent call last) /Applications/sage-5.4.rc2/devel/sage-combinat/<ipython console> in <module>() /Applications/sage-5.4.rc2/local/lib/python2.7/site-packages/sage/combinat/sf/new_kschur.pyc in __getitem__(self, c, *rest) 298 ks3[] 299 """ --> 300 if isinstance(c, Partition_class): 301 assert len(rest) == 0 302 else: TypeError: isinstance() arg 2 must be a class, type, or tuple of classes and types
Travis, was it your intention to allow Partitions( NonNegativeIntegers(), max_part=k )
to represent the set of all Partitions with max_part=k?
comment:4 follow-up: 5 Changed 10 years ago by
Replying to zabrocki:
However the [trac_13605-partition_options-ts.patch] currently causes a different problem with symmetric functions:
sage: ks[2,1] --------------------------------------------------------------------------- TypeError Traceback (most recent call last) /Applications/sage-5.4.rc2/devel/sage-combinat/<ipython console> in <module>() /Applications/sage-5.4.rc2/local/lib/python2.7/site-packages/sage/combinat/sf/new_kschur.pyc in __getitem__(self, c, *rest) 298 ks3[] 299 """ --> 300 if isinstance(c, Partition_class): 301 assert len(rest) == 0 302 else: TypeError: isinstance() arg 2 must be a class, type, or tuple of classes and types
I'll go through now and scrub all instances of Partition_class
from the sage code so you can adequately test to see if the patch (unintentionally) fixes this problem.
Travis, was it your intention to allow
Partition( NonNegativeInteger(), max_part=k )
to represent the set of all Partitions with max_part=k?
Do you mean Partitions(NonNegativeIntegers(), max_part=k)
with the s
's? If so, this has some quirks noted in the wierdness page. However, if you mean exactly what you wrote, then I believe that should raise an exception since Partition()
should return a single partition, although maybe with that input, one should get a random partition with max part k
...
comment:5 Changed 10 years ago by
Do you mean
Partitions(NonNegativeIntegers(), max_part=k)
with thes
's? If so, this has some quirks noted in the wierdness page. However, if you mean exactly what you wrote, then I believe that should raise an exception sincePartition()
should return a single partition, although maybe with that input, one should get a random partition with max partk
...
I meant Partitions(NonNegativeIntegers(), max_part=k)
. Sorry for the double typos (corrected in comment).
comment:6 Changed 10 years ago by
Dependencies: | 13605 → #13605 |
---|
comment:7 Changed 10 years ago by
In an ideal world, yes, that should be all partitions with max part k
.
What I'm doing in #13605 won't really affect how input is handled, and if I understand this ticket correctly, it is to port the list input aspect of IntegerListsLex
into Partitions
. For this, my first thoughts give me one of three possibilities:
- Create new classes which act like
Partitions_all
which just iterates over all of the classes with specifiedn
in the passed in set. - Create
DisjointUnionEnumeratedSets
with an appropriateFamily
. - Copy how
IntegerListsLex
does things
On a slight side note, IntegerListsLex
has some finiteness issues that will might also need to be addressed; see #13749.
comment:8 Changed 10 years ago by
Two small comments:
First,
Partitions(NonNegativeIntegers())
returns a value error.
Second, your set
Partitions(NonNegativeIntegers(), max_part = 3)
has repr:
Partitions of the integer Non negative integers satisfying constraints max_part=3
which is confusing. I have implemented something similar to Travis' first suggested solution to deal with the k-quotient side of things.
comment:9 Changed 10 years ago by
Found another bug which is really related to this one. If we give an input to a kSchur function which isn't k-bounded, then it should return an error:
ks = SymmetricFunctions(QQ).kBoundedSubspace(3,1).kschur() ks([4,1]) Traceback (click to the left of this block for traceback) ... TypeError: do not know how to make x (= [4, 1]) an element of self (=3-bounded Symmetric Functions over Rational Field with t=1 in the 3-Schur basis also with t=1)
But this should also return an error:
ks(Partition([4,1])) ks3[4, 1]
comment:10 follow-up: 11 Changed 10 years ago by
Dependencies: | #13605 → #13605 #14228 |
---|---|
Status: | new → needs_review |
comment:11 Changed 10 years ago by
comment:12 Changed 10 years ago by
We both end up deleting the NonNegativeIntegers
import (which is essentially trivial cleanup for both our patches), but other than that, the patches should^{(tm)} commute.
comment:13 Changed 10 years ago by
Status: | needs_review → positive_review |
---|
Everything looks good. This seems to catch all the issues with having the correct indices in k-Schur functions that I can find. Thanks for coming back to this one.
comment:15 Changed 10 years ago by
Milestone: | sage-5.8 → sage-5.9 |
---|---|
Reviewers: | → Mike Zabrocki |
comment:16 Changed 10 years ago by
Authors: | Chris Berg → Travis Scrimshaw |
---|
comment:17 Changed 10 years ago by
Status: | positive_review → needs_work |
---|
This should be rebased to sage-5.8.rc0.
comment:19 Changed 10 years ago by
It still doesn't apply properly, are you sure you have a clean build of sage-5.8.rc0?
applying /release/merger/patches/trac_13743-fix_kschur-ts.2.patch patching file sage/combinat/partition.py Hunk #3 succeeded at 304 with fuzz 2 (offset -1 lines).
Changed 10 years ago by
Attachment: | trac_13743-fix_kschur-ts.2.patch added |
---|
comment:20 Changed 10 years ago by
Status: | needs_work → positive_review |
---|
I am restoring positive review. I had to recompile sage-5.8.rc0 to ensure that I didn't have a problem. This patch now applies cleanly.
comment:21 Changed 10 years ago by
Merged in: | → sage-5.9.beta0 |
---|---|
Resolution: | → fixed |
Status: | positive_review → closed |
That Partitions accepts a set is in fact not a bug. Granted, it should be documented, and there certainly are many cases like this one where this is not supported (so I agree with the existence of this ticket). But this is definitely a feature we want (and that is, more or less, implemented in IntegerListsLex?).
Cheers,