Hi Florent, Thanks for your comments, but unfortunately this does not work. My class has a _classcall_private_. Is that the problem?
Cheers, Anne ********************************************************************* File "/Applications/sage-5.0.beta3/devel/sage-combinat/sage/combinat/posets/linear_extensions.py", line 289: sage: TestSuite(L).run() Expected nothing Got: Failure in _test_an_element: Traceback (most recent call last): File "/Applications/sage-5.0.beta3/local/lib/python/site-packages/sage/misc/sage_unittest.py", line 279, in run test_method(tester = tester) File "/Applications/sage-5.0.beta3/local/lib/python/site-packages/sage/categories/sets_cat.py", line 404, in _test_an_element an_element = self.an_element() File "parent.pyx", line 2519, in sage.structure.parent.Parent.an_element (sage/structure/parent.c:17566) File "parent.pyx", line 2545, in sage.structure.parent.Parent.an_element (sage/structure/parent.c:17510) File "parent.pyx", line 2613, in sage.structure.parent.Parent._an_element_ (sage/structure/parent.c:18101) NotImplementedError: please implement _an_element_ for The set of all linear extensions of Finite poset containing 4 elements ------------------------------------------------------------ Failure in _test_elements: Traceback (most recent call last): File "/Applications/sage-5.0.beta3/local/lib/python/site-packages/sage/misc/sage_unittest.py", line 279, in run test_method(tester = tester) File "/Applications/sage-5.0.beta3/local/lib/python/site-packages/sage/categories/sets_cat.py", line 468, in _test_elements an_element = self.an_element() File "parent.pyx", line 2519, in sage.structure.parent.Parent.an_element (sage/structure/parent.c:17566) File "parent.pyx", line 2545, in sage.structure.parent.Parent.an_element (sage/structure/parent.c:17510) File "parent.pyx", line 2613, in sage.structure.parent.Parent._an_element_ (sage/structure/parent.c:18101) NotImplementedError: please implement _an_element_ for The set of all linear extensions of Finite poset containing 4 elements ------------------------------------------------------------ Failure in _test_elements_eq: Traceback (most recent call last): File "/Applications/sage-5.0.beta3/local/lib/python/site-packages/sage/misc/sage_unittest.py", line 279, in run test_method(tester = tester) File "/Applications/sage-5.0.beta3/local/lib/python/site-packages/sage/categories/sets_cat.py", line 555, in _test_elements_eq elements = list(self.some_elements())+[None, 0] File "/Applications/sage-5.0.beta3/local/lib/python/site-packages/sage/categories/enumerated_sets.py", line 514, in _some_elements_from_iterator for i in self: File "/Applications/sage-5.0.beta3/local/lib/python/site-packages/sage/categories/enumerated_sets.py", line 390, in _iterator_from_list for x in self.list(): File "/Applications/sage-5.0.beta3/local/lib/python/site-packages/sage/combinat/posets/linear_extensions.py", line 330, in list return [ LinearExtensionOfPoset([i.element for i in p],self._poset) for p in self._poset.linear_extensions() ] File "/Applications/sage-5.0.beta3/local/lib/python/site-packages/sage/misc/classcall_metaclass.py", line 274, in __call__ return cls.__classcall_private__(cls, *args, **options) File "/Applications/sage-5.0.beta3/local/lib/python/site-packages/sage/combinat/posets/linear_extensions.py", line 106, in __classcall_private__ return LinearExtensionsOfPoset(P)(lin_ext) File "parent.pyx", line 1059, in sage.structure.parent.Parent.__call__ (sage/structure/parent.c:7886) File "coerce_maps.pyx", line 82, in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (sage/structure/coerce_maps.c:3344) File "coerce_maps.pyx", line 77, in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (sage/structure/coerce_maps.c:3247) File "/Applications/sage-5.0.beta3/local/lib/python/site-packages/sage/categories/sets_cat.py", line 309, in _element_constructor_from_element_class return self.element_class(parent = self, *args, **keywords) File "/Applications/sage-5.0.beta3/local/lib/python/site-packages/sage/misc/classcall_metaclass.py", line 278, in __call__ return type.__call__(cls, *args, **options) TypeError: __init__() got multiple values for keyword argument 'parent' ------------------------------------------------------------ Failure in _test_enumerated_set_contains: Traceback (most recent call last): File "/Applications/sage-5.0.beta3/local/lib/python/site-packages/sage/misc/sage_unittest.py", line 279, in run test_method(tester = tester) File "/Applications/sage-5.0.beta3/local/lib/python/site-packages/sage/categories/enumerated_sets.py", line 621, in _test_enumerated_set_contains for w in self: File "/Applications/sage-5.0.beta3/local/lib/python/site-packages/sage/categories/enumerated_sets.py", line 390, in _iterator_from_list for x in self.list(): File "/Applications/sage-5.0.beta3/local/lib/python/site-packages/sage/combinat/posets/linear_extensions.py", line 330, in list return [ LinearExtensionOfPoset([i.element for i in p],self._poset) for p in self._poset.linear_extensions() ] File "/Applications/sage-5.0.beta3/local/lib/python/site-packages/sage/misc/classcall_metaclass.py", line 274, in __call__ return cls.__classcall_private__(cls, *args, **options) File "/Applications/sage-5.0.beta3/local/lib/python/site-packages/sage/combinat/posets/linear_extensions.py", line 106, in __classcall_private__ return LinearExtensionsOfPoset(P)(lin_ext) File "parent.pyx", line 1059, in sage.structure.parent.Parent.__call__ (sage/structure/parent.c:7886) File "coerce_maps.pyx", line 82, in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (sage/structure/coerce_maps.c:3344) File "coerce_maps.pyx", line 77, in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (sage/structure/coerce_maps.c:3247) File "/Applications/sage-5.0.beta3/local/lib/python/site-packages/sage/categories/sets_cat.py", line 309, in _element_constructor_from_element_class return self.element_class(parent = self, *args, **keywords) File "/Applications/sage-5.0.beta3/local/lib/python/site-packages/sage/misc/classcall_metaclass.py", line 278, in __call__ return type.__call__(cls, *args, **options) TypeError: __init__() got multiple values for keyword argument 'parent' On 2/19/12 1:15 PM, Florent Hivert wrote: > Hi Anne, > >> Thanks! I do not understand how to use it though. If I inherit >> >> from sage.structure.list_clone import ClonableIntArray, ClonableElement >> >> and replace >> >> class LinearExtensionOfPoset(CombinatorialObject, Element): >> >> by >> >> class LinearExtensionOfPoset(ClonableIntArray, ClonableElement): >> >> and put >> >> ClonableIntArray.__init__(self, linear_extension) >> ClonableElement.__init__(self, parent) > > Since ClonableIntArray inherits from ClonableElement you shouldn't write > both. Just write > > class LinearExtensionOfPoset(ClonableIntArray): > > Also, you don't need to write an init if your constructor is just taking the > parent and the list of the value. > > If you need some other parameters then write your init as > > def __init__(self, parent, linear_extension, other_params): > ... > ClonableIntArray.__init__(self, parent, linear_extension) > ... > > >> in my _init__ file, then I get a lot of error messages (whereas all tests >> pass before the >> change). >> >> Do I need to replace >> >> Element = LinearExtensionOfPoset >> >> as well by >> >> ClonableElement = LinearExtensionOfPoset? > > no ! > > Element = LinearExtensionOfPoset > > is correct. > > Florent -- 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.