#14136 closed enhancement (fixed)
P-partition enumerators in QSym
Reported by: | darij | Owned by: | sage-combinat |
---|---|---|---|
Priority: | minor | Milestone: | sage-5.12 |
Component: | combinatorics | Keywords: | QSym, P-partitions, posets, days45, days49 |
Cc: | saliola | Merged in: | sage-5.12.beta2 |
Authors: | Darij Grinberg | Reviewers: | Frédéric Chapoton, Travis Scrimshaw |
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | #14748 | Stopgaps: |
Description (last modified by )
Or did someone already implement them?
Here's my code. Its weakest point is probably the input; instead of an actual pair of a poset and a map from its elements to {1,2,3,...}, it takes a pair of a poset and a linear order on it represented as a tuple of its elements. (See docstring for details. By the way, I'm hoping the LaTeX does work... no idea how to check that.)
Apply:
Attachments (4)
Change History (38)
Changed 7 years ago by
comment:1 Changed 7 years ago by
- Keywords days45 added
comment:2 Changed 7 years ago by
- Cc saliola added
comment:3 Changed 6 years ago by
You need to choose where to put this function :
- as a method of finite posets ?
- as a method of Quasisymmetric functions ?
Once this choice is made, please upload a patch rather than a python file
You need a white line after the EXAMPLES::
comment:4 Changed 6 years ago by
here is a patch. There remains a deprecation warning that need to be taken care of.
comment:5 Changed 6 years ago by
Thank you, Frédéric! What exactly is deprecated? (I'm at work now so I can't compile.)
comment:6 Changed 6 years ago by
new patch, better doc, almost pass tests, but I have not been able to solve this deprecation problem.
It may come from the line QR=QuasiSymmetric?(R).
comment:7 Changed 6 years ago by
I confirm that the DeprecationWarning? comes from the line
QR = QuasiSymmetricFunctions(R)
But I am not able so far to understand exactly what the problem is.
comment:8 Changed 6 years ago by
hg is driving me nuts...
darij@travis-virtualbox:~/sage-5.9.rc1$ hg qpush -v applying trac_14136_p_partition_enumerator_v1.patch [Errno 20] Not a directory: '/home/darij/sage-5.9.rc1/sage/combinat/posets/posets.py' patch failed, rejects left in working dir errors during apply, please fix and refresh trac_14136_p_partition_enumerator_v1.patch darij@travis-virtualbox:~/sage-5.9.rc1$
I was trying to install the patch on a fresh sage-5.9rc1, main branch (due to QSym being involved).
EDIT: Oh... should I just manually replace "combinat" by "sage" in the patch file?
comment:9 Changed 6 years ago by
you should be in '/home/darij/sage-5.9.rc1/devel/sage-main' to use hg
Changed 6 years ago by
comment:10 Changed 6 years ago by
still the same failing doctest with 5.10.beta1 ..
comment:11 Changed 6 years ago by
Thanks for the help with hg!!
I can confirm the annoying doctest:201: DeprecationWarning: object.__init__() takes no parameters
in response to QR = QuasiSymmetricFunctions(R)
(unless there is some delay between the causing of the bug and the message). I'm using sage-main, so the breakage of QSym is out of question. No idea where it comes from...
Changed 6 years ago by
comment:12 Changed 6 years ago by
I've uploaded a small review patch which does some additional tweaks to the documentation and removes the print statements. I'm also getting the same error, and even adding this method above it:
def test(self, R): """ EXAMPLES:: sage: P = Poset([[],[]]) sage: P.test(QQ) """ from sage.combinat.ncsf_qsym.qsym import QuasiSymmetricFunctions return QuasiSymmetricFunctions(R)
the error gets pushed into this method. I'm thinking we should post something to sage-devel about this (since the error cannot be reproduced in sage), and as a possible solution, just copy the output of the doctest with a comment about it basically saying we have no idea what is happening.
Best,
Travis
comment:13 Changed 6 years ago by
Hello, thanks for getting involved in this patch.
Have you asked the question on sage-devel ?
You have introduced a typo "parition" in your review patch.
comment:14 Changed 6 years ago by
- Status changed from new to needs_info
Hey,
Here's the topic:
https://groups.google.com/forum/?fromgroups#!topic/sage-devel/wQoCEeKrZ3w
I'll fix the typo once we figure out what to do with the deprecation warning.
comment:15 follow-up: ↓ 16 Changed 6 years ago by
Without the patches, there does appear to be deprecations associated with the QuasiSymmetricFunctions
class that points to
DeprecationWarning: object.__init__() takes no parameters
A Traceback of the warning may be obtained by converting warnings to errors, i.e.
sage: import warnings sage: warnings.simplefilter('error', DeprecationWarning) sage: QuasiSymmetricFunctions(QQ)
which is fairly lengthy. It is curious that the patches now expose the warning. FWIW, the SymmetricFunctions
class doesn't exhibit the warning:
sage: import warnings sage: warnings.simplefilter('error', DeprecationWarning) sage: SymmetricFunctions(QQ) Symmetric Functions over Rational Field
comment:16 in reply to: ↑ 15 Changed 6 years ago by
Replying to strogdon:
Without the patches, there does appear to be deprecations associated with the
QuasiSymmetricFunctions
class that points toDeprecationWarning: object.__init__() takes no parameters
Where/how did you see this? In particular, was this placed in another doctest somewhere?
A Traceback of the warning may be obtained by converting warnings to errors, i.e.
sage: import warnings sage: warnings.simplefilter('error', DeprecationWarning) sage: QuasiSymmetricFunctions(QQ)which is fairly lengthy. It is curious that the patches now expose the warning. FWIW, the
SymmetricFunctions
class doesn't exhibit the warning:sage: import warnings sage: warnings.simplefilter('error', DeprecationWarning) sage: SymmetricFunctions(QQ) Symmetric Functions over Rational Field
Hmmm, I didn't know that (kinda cool). I'll take a look at it. Thanks.
comment:17 Changed 6 years ago by
Here's the backtrace I got:
File "posets.py", line 3271, in sage.combinat.posets.posets.FinitePoset.p_partition_enumerator Failed example: FP = P.p_partition_enumerator((3,1,2,4), QQ, check=True); FP Exception raised: Traceback (most recent call last): File "/home/travis/sage-5.9.beta5/local/lib/python2.7/site-packages/sage/doctest/forker.py", line 466, in _run self.execute(example, compiled, test.globs) File "/home/travis/sage-5.9.beta5/local/lib/python2.7/site-packages/sage/doctest/forker.py", line 825, in execute exec compiled in globs File "<doctest sage.combinat.posets.posets.FinitePoset.p_partition_enumerator[3]>", line 1, in <module> FP = P.p_partition_enumerator((Integer(3),Integer(1),Integer(2),Integer(4)), QQ, check=True); FP File "/home/travis/sage-5.9.beta5/local/lib/python2.7/site-packages/sage/combinat/posets/posets.py", line 3288, in p_partition_enumerator QR = QuasiSymmetricFunctions(R) File "classcall_metaclass.pyx", line 330, in sage.misc.classcall_metaclass.ClasscallMetaclass.__call__ (sage/misc/classcall_metaclass.c:977) File "cachefunc.pyx", line 992, in sage.misc.cachefunc.WeakCachedFunction.__call__ (sage/misc/cachefunc.c:5175) File "/home/travis/sage-5.9.beta5/local/lib/python2.7/site-packages/sage/structure/unique_representation.py", line 447, in __classcall__ instance = typecall(cls, *args, **options) File "classcall_metaclass.pyx", line 518, in sage.misc.classcall_metaclass.typecall (sage/misc/classcall_metaclass.c:1339) File "/home/travis/sage-5.9.beta5/local/lib/python2.7/site-packages/sage/combinat/ncsf_qsym/qsym.py", line 427, in __init__ Parent.__init__(self, category = category.WithRealizations()) File "parent.pyx", line 339, in sage.structure.parent.Parent.__init__ (sage/structure/parent.c:4095) File "/home/travis/sage-5.9.beta5/local/lib/python2.7/site-packages/sage/categories/algebras.py", line 159, in __init_extra__ one = self.one() File "/home/travis/sage-5.9.beta5/local/lib/python2.7/site-packages/sage/categories/monoids.py", line 270, in one return self.a_realization().one() File "/home/travis/sage-5.9.beta5/local/lib/python2.7/site-packages/sage/combinat/ncsf_qsym/qsym.py", line 480, in a_realization return self.Monomial() File "classcall_metaclass.pyx", line 429, in sage.misc.classcall_metaclass.ClasscallMetaclass.__get__ (sage/misc/classcall_metaclass.c:1106) File "/home/travis/sage-5.9.beta5/local/lib/python2.7/site-packages/sage/misc/bindable_class.py", line 152, in __classget__ return BoundClass(cls, instance) File "/home/travis/sage-5.9.beta5/local/lib/python2.7/site-packages/sage/misc/bindable_class.py", line 201, in __init__ super(BoundClass, self).__init__(*args) DeprecationWarning: object.__init__() takes no parameters
It seems like the BoundClass
(of Monomial
) is calling up to the base object
and at this point I don't understand why.
comment:18 Changed 6 years ago by
There seems to be one other place in Sage where QuasiSymmetricFunctions()
is called in the same manner as in p_partition_enumerator - in devel/sage/sage/combinat/dyck_word.py where when doctesting there is no apparent DeprecationWarning
. However, after converting warnings to exceptions I get the following backtrace:
File "devel/sage/sage/combinat/dyck_word.py", line 1542, in sage.combinat.dyck_word.DyckWord_complete.characteristic_symmetric_function Failed example: f = sum(t**D.area()*D.characteristic_symmetric_function() for D in DyckWords(3)); f Exception raised: Traceback (most recent call last): File "/storage/sage/sage-5.9.beta5/local/lib/python2.7/site-packages/sage/doctest/forker.py", line 466, in _run self.execute(example, compiled, test.globs) File "/storage/sage/sage-5.9.beta5/local/lib/python2.7/site-packages/sage/doctest/forker.py", line 825, in execute exec compiled in globs File "<doctest sage.combinat.dyck_word.DyckWord_complete.characteristic_symmetric_function[2]>", line 1, in <module> f = sum(t**D.area()*D.characteristic_symmetric_function() for D in DyckWords(Integer(3))); f File "/storage/sage/sage-5.9.beta5/local/lib/python2.7/site-packages/sage/misc/functional.py", line 656, in symbolic_sum return sum(expression, *args) File "<doctest sage.combinat.dyck_word.DyckWord_complete.characteristic_symmetric_function[2]>", line 1, in <genexpr> f = sum(t**D.area()*D.characteristic_symmetric_function() for D in DyckWords(Integer(3))); f File "/storage/sage/sage-5.9.beta5/local/lib/python2.7/site-packages/sage/combinat/dyck_word.py", line 1556, in characteristic_symmetric_function F = QuasiSymmetricFunctions(R).Fundamental() File "classcall_metaclass.pyx", line 279, in sage.misc.classcall_metaclass.ClasscallMetaclass.__call__ (sage/misc/classcall_metaclass.c:932) File "cachefunc.pyx", line 992, in sage.misc.cachefunc.WeakCachedFunction.__call__ (sage/misc/cachefunc.c:5175) File "/storage/sage/sage-5.9.beta5/local/lib/python2.7/site-packages/sage/structure/unique_representation.py", line 447, in __classcall__ instance = typecall(cls, *args, **options) File "classcall_metaclass.pyx", line 467, in sage.misc.classcall_metaclass.typecall (sage/misc/classcall_metaclass.c:1294) File "/storage/sage/sage-5.9.beta5/local/lib/python2.7/site-packages/sage/combinat/ncsf_qsym/qsym.py", line 427, in __init__ Parent.__init__(self, category = category.WithRealizations()) File "parent.pyx", line 339, in sage.structure.parent.Parent.__init__ (sage/structure/parent.c:4095) File "/storage/sage/sage-5.9.beta5/local/lib/python2.7/site-packages/sage/categories/algebras.py", line 159, in __init_extra__ one = self.one() File "/storage/sage/sage-5.9.beta5/local/lib/python2.7/site-packages/sage/categories/monoids.py", line 270, in one return self.a_realization().one() File "/storage/sage/sage-5.9.beta5/local/lib/python2.7/site-packages/sage/combinat/ncsf_qsym/qsym.py", line 480, in a_realization return self.Monomial() File "classcall_metaclass.pyx", line 378, in sage.misc.classcall_metaclass.ClasscallMetaclass.__get__ (sage/misc/classcall_metaclass.c:1061) File "/storage/sage/sage-5.9.beta5/local/lib/python2.7/site-packages/sage/misc/bindable_class.py", line 152, in __classget__ return BoundClass(cls, instance) File "/storage/sage/sage-5.9.beta5/local/lib/python2.7/site-packages/sage/misc/bindable_class.py", line 201, in __init__ super(BoundClass, self).__init__(*args) DeprecationWarning: object.__init__() takes no parameters
This looks very much like the above backtrace, but of course the DeprecationWarning
does not present itself under norm doctesting. So something very subtle must be happening.
comment:19 Changed 6 years ago by
For the records, here is where the warning comes from. The BindableClass? things uses a class BoundClass? that inherit from functools.partial. And there seems to be an issue there:
sage: import warnings sage: warnings.simplefilter('error', DeprecationWarning) sage: import functools sage: def f(x): return x sage: g = functools.partial(f,1) sage: g() 1 sage: class mypartial(functools.partial): ....: def __init__(self, f, i): ....: functools.partial.__init__(self, f,i) sage: g = mypartial(f,1) Traceback (most recent call last) ... ----> 3 functools.partial.__init__(self, f,i) DeprecationWarning: object.__init__() takes no parameters sage: g() 1
I had never noticed this. Please explore what's the best workaround!
comment:20 Changed 6 years ago by
This is somewhat non-intuitive but the following seems to work
sage: import warnings sage: warnings.simplefilter('error', DeprecationWarning) sage: import functools sage: def f(x, y): return x^y sage: g = functools.partial(f, 2, 3) sage: g() 8 sage: class mypartial(functools.partial): ....: def __init__(self, f, i, j): ....: functools.partial.__init__(self) ....: sage: g = mypartial(f, 2, 3) sage: g() 8
or
sage: class mynewpartial(functools.partial): ....: def __init__(self, f, i, j): ....: super(mynewpartial, self).__init__() ....: sage: g = mynewpartial(f, 2, 3) sage: g() 8
This perhaps suggests the __init__
method of the BoundClass
should be
def __init__(self, *args): super(BoundClass, self).__init__() self.__doc__ = self.func.__doc__
instead of
super(BoundClass, self).__init__(*args)
I don't know whether this breaks anything?
comment:21 follow-up: ↓ 22 Changed 6 years ago by
maybe this should be tried and solved in another ticket ? the purpose of the present one is only to introduce something new related to posets and quasi-symmetric functions ?
comment:22 in reply to: ↑ 21 Changed 6 years ago by
comment:23 Changed 6 years ago by
- Dependencies set to #14748
- Reviewers set to Frederic Chapoton, Travis Scrimshaw
- Status changed from needs_info to needs_review
Since the problem has been isolated to #14748 (I've added it as a dependency), I'm thinking we should set this to positive review. Any objections?
comment:24 Changed 6 years ago by
- Description modified (diff)
comment:25 Changed 6 years ago by
- Description modified (diff)
the review patch introduces a typo "parition", that needs to be corrected
comment:26 Changed 6 years ago by
- Description modified (diff)
comment:27 Changed 6 years ago by
it was not necessary to fold. The typo is still there
comment:28 Changed 6 years ago by
Chapoton: thanks, done (edited the folded version).
comment:29 Changed 6 years ago by
- Milestone changed from sage-5.11 to sage-pending
- Status changed from needs_review to positive_review
I don't see the typo in the folded patch, so I'm going to set this to positive review.
Apply: trac_14136-p_partition_enumerator_folded.patch
comment:30 Changed 6 years ago by
- Keywords days49 added
comment:31 Changed 6 years ago by
Frédéric and Travis: thank you!
comment:32 Changed 6 years ago by
- Milestone changed from sage-pending to sage-5.12
comment:33 Changed 6 years ago by
- Merged in set to sage-5.12.beta2
- Resolution set to fixed
- Status changed from positive_review to closed
comment:34 Changed 2 years ago by
- Reviewers changed from Frederic Chapoton, Travis Scrimshaw to Frédéric Chapoton, Travis Scrimshaw
missing accents
P-partition enumerators for QSym