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

P-partition enumerators in QSym #14136

Closed
darijgr opened this issue Feb 15, 2013 · 41 comments
Closed

P-partition enumerators in QSym #14136

darijgr opened this issue Feb 15, 2013 · 41 comments

Comments

@darijgr
Copy link
Contributor

darijgr commented Feb 15, 2013

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:

Depends on #14748

CC: @saliola

Component: combinatorics

Keywords: QSym, P-partitions, posets, days45, days49

Author: Darij Grinberg

Reviewer: Frédéric Chapoton, Travis Scrimshaw

Merged: sage-5.12.beta2

Issue created by migration from https://trac.sagemath.org/ticket/14136

@darijgr
Copy link
Contributor Author

darijgr commented Feb 15, 2013

P-partition enumerators for QSym

@darijgr
Copy link
Contributor Author

darijgr commented Feb 15, 2013

Changed keywords from QSym, P-partitions, posets to QSym, P-partitions, posets, days45

@darijgr
Copy link
Contributor Author

darijgr commented Feb 15, 2013

comment:1

Attachment: ppart.py.gz

@fchapoton
Copy link
Contributor

comment:3

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::

@fchapoton
Copy link
Contributor

comment:4

here is a patch. There remains a deprecation warning that need to be taken care of.

@darijgr
Copy link
Contributor Author

darijgr commented Apr 30, 2013

comment:5

Thank you, Frédéric! What exactly is deprecated? (I'm at work now so I can't compile.)

@fchapoton
Copy link
Contributor

comment:6

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).

@fchapoton
Copy link
Contributor

comment:7

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.

@darijgr
Copy link
Contributor Author

darijgr commented May 6, 2013

comment:8

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?

@fchapoton
Copy link
Contributor

comment:9

you should be in '/home/darij/sage-5.9.rc1/devel/sage-main' to use hg

@fchapoton
Copy link
Contributor

@fchapoton
Copy link
Contributor

comment:10

still the same failing doctest with 5.10.beta1 ..

@darijgr
Copy link
Contributor Author

darijgr commented May 9, 2013

comment:11

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...

@tscrim
Copy link
Collaborator

tscrim commented May 9, 2013

comment:12

Attachment: trac_14136-p_partition_enumerator-review-ts.patch.gz

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

@fchapoton
Copy link
Contributor

comment:13

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.

@tscrim
Copy link
Collaborator

tscrim commented May 9, 2013

comment:14

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.

@strogdon
Copy link

comment:15

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

@tscrim
Copy link
Collaborator

tscrim commented May 11, 2013

comment:16

Replying to @strogdon:

Without the patches, there does appear to be deprecations associated with the QuasiSymmetricFunctions class that points to

DeprecationWarning: 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.

@tscrim
Copy link
Collaborator

tscrim commented May 12, 2013

comment:17

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.

@strogdon
Copy link

comment:18

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.

@nthiery
Copy link
Contributor

nthiery commented Jun 7, 2013

comment:19

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!

@strogdon
Copy link

comment:20

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?

@fchapoton
Copy link
Contributor

comment:21

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 ?

@strogdon
Copy link

comment:22

Replying to @fchapoton:

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 ?

You're right. This is now ticket #14748

@tscrim
Copy link
Collaborator

tscrim commented Jun 16, 2013

comment:23

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?

@tscrim
Copy link
Collaborator

tscrim commented Jun 16, 2013

Changed author from darij to Darij Grinberg

@tscrim
Copy link
Collaborator

tscrim commented Jun 16, 2013

Reviewer: Frederic Chapoton, Travis Scrimshaw

@tscrim
Copy link
Collaborator

tscrim commented Jun 16, 2013

Dependencies: #14748

@darijgr

This comment has been minimized.

@fchapoton

This comment has been minimized.

@fchapoton
Copy link
Contributor

comment:25

the review patch introduces a typo "parition", that needs to be corrected

@darijgr

This comment has been minimized.

@darijgr
Copy link
Contributor Author

darijgr commented Jun 17, 2013

Attachment: trac_14136-p_partition_enumerator_folded.patch.gz

folded with Travis's review

@fchapoton
Copy link
Contributor

comment:27

it was not necessary to fold. The typo is still there

@darijgr
Copy link
Contributor Author

darijgr commented Jun 17, 2013

comment:28

Chapoton: thanks, done (edited the folded version).

@tscrim
Copy link
Collaborator

tscrim commented Jun 17, 2013

comment:29

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

@tscrim
Copy link
Collaborator

tscrim commented Jun 17, 2013

Changed keywords from QSym, P-partitions, posets, days45 to QSym, P-partitions, posets, days45, days49

@darijgr
Copy link
Contributor Author

darijgr commented Jun 17, 2013

comment:31

Frédéric and Travis: thank you!

@jdemeyer jdemeyer added this to the sage-5.12 milestone Jul 24, 2013
@jdemeyer jdemeyer removed the pending label Jul 24, 2013
@jdemeyer
Copy link

Merged: sage-5.12.beta2

@fchapoton
Copy link
Contributor

comment:34

missing accents

@fchapoton
Copy link
Contributor

Changed reviewer from Frederic Chapoton, Travis Scrimshaw to Frédéric Chapoton, Travis Scrimshaw

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

No branches or pull requests

6 participants