> Thanks for the clarification. Let me restate it to check I am having > it right. You have a poset, say: > > sage: P = Poset((divisors(30), attrcall("divides"))) > > and then you want to manipulate a bunch of linear extensions of that > poset like:: > > sage: l1 = [1, 5, 3, 2, 10, 6, 15, 30] > sage: l2 = [1, 2, 3, 5, 6, 15, 10, 30] > ... > > Then, to apply an operation `blah` on a linear extension of P, you > need both P and the linear extension. A first approach is to put blah > as a method of P:: > > sage: P.blah(l1) > ... > > Another approach is to have a class LinearExtensionOfPoset so that one > can do:: > > sage: l1 = LinearExtensionOfPoset(P, [1, 5, 3, 2, 10, 6, 15, 30]) > sage: l1.blah() > ... > > The choice depends mostly on how many methods one wants to have: for > more than two or three, it is indeed more reasonable to not pollute > P's namespace. > > By the way, one might event want to have a class LinearExtensionsOfPoset:: > > sage: L = LinearExtensionsOfPoset(P); L > The set of all linear extensions of L > sage: L.cardinality() > ... > sage: L.an_element(): > ... > > And then one could do something like: > > sage: L.promotion_graph()
Yes, this option seems the most natural to me and I have implemented this now! As element class, I implemented class LinearExtensionOfPoset(CombinatorialObject, Element): ... class LinearExtensionsOfPoset(UniqueRepresentation, Parent): ... Element = LinearExtensionOfPoset The init method of the element method now takes as input a linear extension and a poset. Does that make sense? And then going to a poset is just def to_poset(self): Then indeed L should contain the various interesting graphs. > A variant of the above would be to have L be a facade parent, and call > the operations like `blah` as: > > sage: L.blah(l1) I do not know much about facade parents. How would this work? By the way, without my changes and using sage-4.8 and the sage-combinat queue up to trac_9280-graded-algebras-example.patch I get a lot of error messages in combinat/posets/posets.py (which makes it difficult to find my own errors). What should I use to get clean tests? Best, Anne --------------------------------------------------------------------- sage -t "devel/sage-combinat/sage/combinat/posets/posets.py" ********************************************************************** File "/Applications/sage-4.8/devel/sage-combinat/sage/combinat/posets/posets.py", line 1875: sage: Q = P.subposet(["a","b","f"]); Q Exception raised: Traceback (most recent call last): File "/Applications/sage-4.8/local/bin/ncadoctest.py", line 1231, in run_one_test self.run_one_example(test, example, filename, compileflags) File "/Applications/sage-4.8/local/bin/sagedoctest.py", line 38, in run_one_example OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags) File "/Applications/sage-4.8/local/bin/ncadoctest.py", line 1172, in run_one_example compileflags, 1) in test.globs File "<doctest __main__.example_60[3]>", line 1, in <module> Q = P.subposet(["a","b","f"]); Q###line 1875: sage: Q = P.subposet(["a","b","f"]); Q File "/Applications/sage-4.8/local/lib/python/site-packages/sage/combinat/posets/posets.py", line 1923, in subposet if not self._is_facade: File "parent.pyx", line 811, in sage.structure.parent.Parent.__getattr__ (sage/structure/parent.c:6277) File "parent.pyx", line 323, in sage.structure.parent.getattr_from_other_class (sage/structure/parent.c:3162) AttributeError: 'FinitePoset_with_category' object has no attribute '_is_facade' ********************************************************************** File "/Applications/sage-4.8/devel/sage-combinat/sage/combinat/posets/posets.py", line 1877: sage: Q.cover_relations() Exception raised: Traceback (most recent call last): File "/Applications/sage-4.8/local/bin/ncadoctest.py", line 1231, in run_one_test self.run_one_example(test, example, filename, compileflags) File "/Applications/sage-4.8/local/bin/sagedoctest.py", line 38, in run_one_example OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags) File "/Applications/sage-4.8/local/bin/ncadoctest.py", line 1172, in run_one_example compileflags, 1) in test.globs File "<doctest __main__.example_60[4]>", line 1, in <module> Q.cover_relations()###line 1877: sage: Q.cover_relations() NameError: name 'Q' is not defined ********************************************************************** File "/Applications/sage-4.8/devel/sage-combinat/sage/combinat/posets/posets.py", line 1883: sage: Q = P.subposet(["a","b","f"]); Q Exception raised: Traceback (most recent call last): File "/Applications/sage-4.8/local/bin/ncadoctest.py", line 1231, in run_one_test self.run_one_example(test, example, filename, compileflags) File "/Applications/sage-4.8/local/bin/sagedoctest.py", line 38, in run_one_example OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags) File "/Applications/sage-4.8/local/bin/ncadoctest.py", line 1172, in run_one_example compileflags, 1) in test.globs File "<doctest __main__.example_60[6]>", line 1, in <module> Q = P.subposet(["a","b","f"]); Q###line 1883: sage: Q = P.subposet(["a","b","f"]); Q File "/Applications/sage-4.8/local/lib/python/site-packages/sage/combinat/posets/posets.py", line 1923, in subposet if not self._is_facade: File "parent.pyx", line 811, in sage.structure.parent.Parent.__getattr__ (sage/structure/parent.c:6277) File "parent.pyx", line 323, in sage.structure.parent.getattr_from_other_class (sage/structure/parent.c:3162) AttributeError: 'FinitePoset_with_category' object has no attribute '_is_facade' ********************************************************************** File "/Applications/sage-4.8/devel/sage-combinat/sage/combinat/posets/posets.py", line 1885: sage: Q.cover_relations() Exception raised: Traceback (most recent call last): File "/Applications/sage-4.8/local/bin/ncadoctest.py", line 1231, in run_one_test self.run_one_example(test, example, filename, compileflags) File "/Applications/sage-4.8/local/bin/sagedoctest.py", line 38, in run_one_example OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags) File "/Applications/sage-4.8/local/bin/ncadoctest.py", line 1172, in run_one_example compileflags, 1) in test.globs File "<doctest __main__.example_60[7]>", line 1, in <module> Q.cover_relations()###line 1885: sage: Q.cover_relations() NameError: name 'Q' is not defined ********************************************************************** File "/Applications/sage-4.8/devel/sage-combinat/sage/combinat/posets/posets.py", line 1891: sage: Q = P.subposet([P("a"),P("b"),P("f")]); Q Exception raised: Traceback (most recent call last): File "/Applications/sage-4.8/local/bin/ncadoctest.py", line 1231, in run_one_test self.run_one_example(test, example, filename, compileflags) File "/Applications/sage-4.8/local/bin/sagedoctest.py", line 38, in run_one_example OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags) File "/Applications/sage-4.8/local/bin/ncadoctest.py", line 1172, in run_one_example compileflags, 1) in test.globs File "<doctest __main__.example_60[9]>", line 1, in <module> Q = P.subposet([P("a"),P("b"),P("f")]); Q###line 1891: sage: Q = P.subposet([P("a"),P("b"),P("f")]); Q File "/Applications/sage-4.8/local/lib/python/site-packages/sage/combinat/posets/posets.py", line 1923, in subposet if not self._is_facade: File "parent.pyx", line 811, in sage.structure.parent.Parent.__getattr__ (sage/structure/parent.c:6277) File "parent.pyx", line 323, in sage.structure.parent.getattr_from_other_class (sage/structure/parent.c:3162) AttributeError: 'FinitePoset_with_category' object has no attribute '_is_facade' ********************************************************************** File "/Applications/sage-4.8/devel/sage-combinat/sage/combinat/posets/posets.py", line 1893: sage: Q.cover_relations() Exception raised: Traceback (most recent call last): File "/Applications/sage-4.8/local/bin/ncadoctest.py", line 1231, in run_one_test self.run_one_example(test, example, filename, compileflags) File "/Applications/sage-4.8/local/bin/sagedoctest.py", line 38, in run_one_example OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags) File "/Applications/sage-4.8/local/bin/ncadoctest.py", line 1172, in run_one_example compileflags, 1) in test.globs File "<doctest __main__.example_60[10]>", line 1, in <module> Q.cover_relations()###line 1893: sage: Q.cover_relations() NameError: name 'Q' is not defined ********************************************************************** File "/Applications/sage-4.8/devel/sage-combinat/sage/combinat/posets/posets.py", line 1898: sage: Q = B.subposet(above) Exception raised: Traceback (most recent call last): File "/Applications/sage-4.8/local/bin/ncadoctest.py", line 1231, in run_one_test self.run_one_example(test, example, filename, compileflags) File "/Applications/sage-4.8/local/bin/sagedoctest.py", line 38, in run_one_example OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags) File "/Applications/sage-4.8/local/bin/ncadoctest.py", line 1172, in run_one_example compileflags, 1) in test.globs File "<doctest __main__.example_60[13]>", line 1, in <module> Q = B.subposet(above)###line 1898: sage: Q = B.subposet(above) File "/Applications/sage-4.8/local/lib/python/site-packages/sage/combinat/posets/posets.py", line 1923, in subposet if not self._is_facade: File "parent.pyx", line 811, in sage.structure.parent.Parent.__getattr__ (sage/structure/parent.c:6277) File "parent.pyx", line 323, in sage.structure.parent.getattr_from_other_class (sage/structure/parent.c:3162) AttributeError: 'FiniteLatticePoset_with_category' object has no attribute '_is_facade' ********************************************************************** File "/Applications/sage-4.8/devel/sage-combinat/sage/combinat/posets/posets.py", line 1899: sage: above_new = Q.principal_order_filter(Q.list()[0]) Exception raised: Traceback (most recent call last): File "/Applications/sage-4.8/local/bin/ncadoctest.py", line 1231, in run_one_test self.run_one_example(test, example, filename, compileflags) File "/Applications/sage-4.8/local/bin/sagedoctest.py", line 38, in run_one_example OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags) File "/Applications/sage-4.8/local/bin/ncadoctest.py", line 1172, in run_one_example compileflags, 1) in test.globs File "<doctest __main__.example_60[14]>", line 1, in <module> above_new = Q.principal_order_filter(Q.list()[Integer(0)])###line 1899: sage: above_new = Q.principal_order_filter(Q.list()[0]) NameError: name 'Q' is not defined ********************************************************************** File "/Applications/sage-4.8/devel/sage-combinat/sage/combinat/posets/posets.py", line 1900: sage: Q.subposet(above_new) Exception raised: Traceback (most recent call last): File "/Applications/sage-4.8/local/bin/ncadoctest.py", line 1231, in run_one_test self.run_one_example(test, example, filename, compileflags) File "/Applications/sage-4.8/local/bin/sagedoctest.py", line 38, in run_one_example OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags) File "/Applications/sage-4.8/local/bin/ncadoctest.py", line 1172, in run_one_example compileflags, 1) in test.globs File "<doctest __main__.example_60[15]>", line 1, in <module> Q.subposet(above_new)###line 1900: sage: Q.subposet(above_new) NameError: name 'Q' is not defined ********************************************************************** File "/Applications/sage-4.8/devel/sage-combinat/sage/combinat/posets/posets.py", line 1905: sage: P.subposet(("a","b","f")) Exception raised: Traceback (most recent call last): File "/Applications/sage-4.8/local/bin/ncadoctest.py", line 1231, in run_one_test self.run_one_example(test, example, filename, compileflags) File "/Applications/sage-4.8/local/bin/sagedoctest.py", line 38, in run_one_example OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags) File "/Applications/sage-4.8/local/bin/ncadoctest.py", line 1172, in run_one_example compileflags, 1) in test.globs File "<doctest __main__.example_60[16]>", line 1, in <module> P.subposet(("a","b","f"))###line 1905: sage: P.subposet(("a","b","f")) File "/Applications/sage-4.8/local/lib/python/site-packages/sage/combinat/posets/posets.py", line 1923, in subposet if not self._is_facade: File "parent.pyx", line 811, in sage.structure.parent.Parent.__getattr__ (sage/structure/parent.c:6277) File "parent.pyx", line 323, in sage.structure.parent.getattr_from_other_class (sage/structure/parent.c:3162) AttributeError: 'FinitePoset_with_category' object has no attribute '_is_facade' ********************************************************************** File "/Applications/sage-4.8/devel/sage-combinat/sage/combinat/posets/posets.py", line 1907: sage: P.subposet(["a","b","x"]) Expected: Traceback (most recent call last): ... ValueError: <type 'str'> is not an element of this poset Got: Traceback (most recent call last): File "/Applications/sage-4.8/local/bin/ncadoctest.py", line 1231, in run_one_test self.run_one_example(test, example, filename, compileflags) File "/Applications/sage-4.8/local/bin/sagedoctest.py", line 38, in run_one_example OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags) File "/Applications/sage-4.8/local/bin/ncadoctest.py", line 1172, in run_one_example compileflags, 1) in test.globs File "<doctest __main__.example_60[17]>", line 1, in <module> P.subposet(["a","b","x"])###line 1907: sage: P.subposet(["a","b","x"]) File "/Applications/sage-4.8/local/lib/python/site-packages/sage/combinat/posets/posets.py", line 1917, in subposet elements = [self(e) for e in elements] File "/Applications/sage-4.8/local/lib/python/site-packages/sage/combinat/posets/posets.py", line 682, in __call__ raise ValueError, "__call__ accepts a poset element or an integer; you passed %s"%type(element) ValueError: __call__ accepts a poset element or an integer; you passed <type 'str'> ********************************************************************** File "/Applications/sage-4.8/devel/sage-combinat/sage/combinat/posets/posets.py", line 1936: sage: Q = P.random_subposet(.25) Exception raised: Traceback (most recent call last): File "/Applications/sage-4.8/local/bin/ncadoctest.py", line 1231, in run_one_test self.run_one_example(test, example, filename, compileflags) File "/Applications/sage-4.8/local/bin/sagedoctest.py", line 38, in run_one_example OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags) File "/Applications/sage-4.8/local/bin/ncadoctest.py", line 1172, in run_one_example compileflags, 1) in test.globs File "<doctest __main__.example_61[3]>", line 1, in <module> Q = P.random_subposet(RealNumber('.25'))###line 1936: sage: Q = P.random_subposet(.25) File "/Applications/sage-4.8/local/lib/python/site-packages/sage/combinat/posets/posets.py", line 1943, in random_subposet return self.subposet(elements) File "/Applications/sage-4.8/local/lib/python/site-packages/sage/combinat/posets/posets.py", line 1923, in subposet if not self._is_facade: File "parent.pyx", line 811, in sage.structure.parent.Parent.__getattr__ (sage/structure/parent.c:6277) File "parent.pyx", line 323, in sage.structure.parent.getattr_from_other_class (sage/structure/parent.c:3162) AttributeError: 'FinitePoset_with_category' object has no attribute '_is_facade' ********************************************************************** File "/Applications/sage-4.8/devel/sage-combinat/sage/combinat/posets/posets.py", line 2115: sage: Q = P.subposet([1,2,3,4,5,6]) Exception raised: Traceback (most recent call last): File "/Applications/sage-4.8/local/bin/ncadoctest.py", line 1231, in run_one_test self.run_one_example(test, example, filename, compileflags) File "/Applications/sage-4.8/local/bin/sagedoctest.py", line 38, in run_one_example OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags) File "/Applications/sage-4.8/local/bin/ncadoctest.py", line 1172, in run_one_example compileflags, 1) in test.globs File "<doctest __main__.example_68[6]>", line 1, in <module> Q = P.subposet([Integer(1),Integer(2),Integer(3),Integer(4),Integer(5),Integer(6)])###line 2115: sage: Q = P.subposet([1,2,3,4,5,6]) File "/Applications/sage-4.8/local/lib/python/site-packages/sage/combinat/posets/posets.py", line 1923, in subposet if not self._is_facade: File "parent.pyx", line 811, in sage.structure.parent.Parent.__getattr__ (sage/structure/parent.c:6277) File "parent.pyx", line 323, in sage.structure.parent.getattr_from_other_class (sage/structure/parent.c:3162) AttributeError: 'FiniteLatticePoset_with_category' object has no attribute '_is_facade' ********************************************************************** File "/Applications/sage-4.8/devel/sage-combinat/sage/combinat/posets/posets.py", line 2116: sage: Q.order_complex().homology() # a circle Exception raised: Traceback (most recent call last): File "/Applications/sage-4.8/local/bin/ncadoctest.py", line 1231, in run_one_test self.run_one_example(test, example, filename, compileflags) File "/Applications/sage-4.8/local/bin/sagedoctest.py", line 38, in run_one_example OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags) File "/Applications/sage-4.8/local/bin/ncadoctest.py", line 1172, in run_one_example compileflags, 1) in test.globs File "<doctest __main__.example_68[7]>", line 1, in <module> Q.order_complex().homology() # a circle###line 2116: sage: Q.order_complex().homology() # a circle NameError: name 'Q' is not defined ********************************************************************** 3 items had failures: 11 of 20 in __main__.example_60 1 of 5 in __main__.example_61 2 of 12 in __main__.example_68 ***Test Failed*** 14 failures. For whitespace errors, see the file /Users/anne/.sage//tmp/posets_15918.py [10.2 s] ---------------------------------------------------------------------- The following tests failed: sage -t "devel/sage-combinat/sage/combinat/posets/posets.py" Total time for all tests: 10.2 seconds -- 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.