On 2/16/12 2:21 AM, Nicolas M. Thiery wrote:
> On Wed, Feb 15, 2012 at 02:47:04PM -0800, Anne Schilling wrote:
>> Perhaps I need
>>
>>     __metaclass__ = ClasscallMetaclass
>>
>>     @staticmethod
>>     def __classcall_private__(cls, p, order = None):
> 
> Yes, this sounds like it. You have:
> 
>       sage: type(p)
>       <class 'sage.combinat.posets.posets.LinearExtensionOfPoset'>
> 
> compared to:
> 
>       sage: type(Core([2,1],4))
>       <class 'sage.combinat.core.Cores_length_with_category.element_class'>
> 
> so p does not inherit the category code.

But how do I do this? Implementing the analogue of the cores method (see 
combinat-queue)
I get

sage: sage: P = Poset(([1,2,3,4], [[1,3],[1,4],[2,3]]), cover_relations = True)
sage:             sage: p = LinearExtensionOfPoset([1,4,2,3],P)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/Applications/sage-5.0.beta3/devel/sage-combinat/sage/combinat/posets/<ipython 
console> in <module>()

/Applications/sage-5.0.beta3/local/lib/python2.7/site-packages/sage/misc/classcall_metaclass.pyc
 in __call__(cls, *args, **options)
    272         """
    273         if '__classcall_private__' in cls.__dict__:
--> 274             return cls.__classcall_private__(cls, *args, **options)
    275         elif hasattr(cls, "__classcall__"):
    276             return cls.__classcall__(cls, *args, **options)

/Applications/sage-5.0.beta3/local/lib/python2.7/site-packages/sage/combinat/posets/posets.pyc
 in __classcall_private__(cls, lin_ext, P, order)
   2475         if isinstance(lin_ext, cls):
   2476             return lin_ext
-> 2477         return LinearExtensionsOfPoset(P,order sage: sage:             
sage: p = LinearExtensionOfPoset([1,4,2,3],P)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/Applications/sage-5.0.beta3/devel/sage-combinat/sage/combinat/posets/<ipython 
console> in <module>()

/Applications/sage-5.0.beta3/local/lib/python2.7/site-packages/sage/misc/classcall_metaclass.pyc
 in __call__(cls, *args, **options)
    272         """
    273         if '__classcall_private__' in cls.__dict__:
--> 274             return cls.__classcall_private__(cls, *args, **options)
    275         elif hasattr(cls, "__classcall__"):
    276             return cls.__classcall__(cls, *args, **options)

/Applications/sage-5.0.beta3/local/lib/python2.7/site-packages/sage/combinat/posets/posets.pyc
 in __classcall_private__(cls, lin_ext, P, order)
   2475         if isinstance(lin_ext, cls):
   2476             return lin_ext
-> 2477         return LinearExtensionsOfPoset(P,order = order)(lin_ext-> 2477
   2479     def poset(self):

/Appl---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/Applications/sage-5.0.beta3/devel/sage-combinat/sage/combinat/<ipython 
console> in <module>()

/Applications/sage-5.0.beta3/local/lib/python2.7/site-packages/sage/misc/classcall_metaclass.pyc
 in __call__(cls, *args, **options)
    272         """
    273         if '__classcall_private__' in cls.__dict__:
--> 274             return cls.__classcall_private__(cls, *args, **options)
    275         elif hasattr(cls, "__classcall__"):
    276             return cls.__classcall__(cls, *args, **options)

/Applications/sage-5.0.beta3/local/lib/python2.7/site-packages/sage/combinat/posets/posets.pyc
 in __classcall_private__(cls, lin_ext, P, order)
   2475         if isinstance(lin_ext, cls):
   2476             return lin_ext
-> 2477         return LinearExtensionsOfPoset(P,order = order)(lin_ext)
   2478
   2479     def poset(self):

/Applications/sage-5.0.beta3/local/lib/python2.7/site-packages/sage/structure/parent.so
 in sage.structure.parent.Parent.__call__ (sage/structure/parent.c:7886)()

/Applications/sage-5.0.beta3/local/lib/python2.7/site-packages/sage/structure/coerce_maps.so
 in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ 
(sage/structure/coerce_maps.c:3344)()

/Applications/sage-5.0.beta3/local/lib/python2.7/site-packages/sage/structure/coerce_maps.so
 in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ 
(sage/structure/coerce_maps.c:3247)()

/Applications/sage-5.0.beta3/local/lib/python2.7/site-packages/sage/categories/sets_cat.pyc
 in _element_constructor_from_element_class(self, *args, **keywords)
    307                 17
    308             """
--> 309             return self.element_class(parent = self, *args, **keywords)
    310
    311         def is_parent_of(self, element):

/Applications/sage-5.0.beta3/local/lib/python2.7/site-packages/sage/misc/classcall_metaclass.pyc
 in __call__(cls, *args, **options)
    276             return cls.__classcall__(cls, *args, **options)
    277         else:
--> 278             return type.__call__(cls, *args, **options)
    279
    280     def __contains__(cls, x):

TypeError: __init__() got an unexpected keyword argument 'parent'

> Alternatively, instead of having a new LinearExtensionOfPoset(P,
> [3,1,2]) function, you might want to use an idiom like:
> 
>       sage: P.linear_extension([3,1,2])
> 
> whose implementation would do the analogue of what classcall does for
> Cores, i.e. delegate the work to P.linear_extensions()([3,2,1]).

Well, since I do not know how to do it (since the analogue does not work) and
since P.linear_extensions() already exists, this might not be a good idea.

Cheers,

Anne

-- 
You received this message because you are subscribed to the Google Groups 
"sage-combinat-devel" group.
To post to this group, send email to sage-combinat-devel@googlegroups.com.
To unsubscribe from this group, send email to 
sage-combinat-devel+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sage-combinat-devel?hl=en.

Reply via email to