Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
fix mistake in initialisation of LinearExtensions and adapt doctests
Browse files Browse the repository at this point in the history
  • Loading branch information
mantepse committed Jul 17, 2018
1 parent 8050b00 commit f1705d8
Show file tree
Hide file tree
Showing 8 changed files with 152 additions and 142 deletions.
4 changes: 2 additions & 2 deletions src/sage/combinat/interval_posets.py
Expand Up @@ -1920,8 +1920,8 @@ def linear_extensions(self):
sage: list(ip.linear_extensions())
[[3, 1, 2], [1, 3, 2]]
sage: ip = TamariIntervalPoset(4,[(1,2),(2,3),(4,3)])
sage: list(ip.linear_extensions())
[[4, 1, 2, 3], [1, 4, 2, 3], [1, 2, 4, 3]]
sage: sorted(ip.linear_extensions())
[[1, 2, 4, 3], [1, 4, 2, 3], [4, 1, 2, 3]]
"""
for ext in self._poset.linear_extensions():
yield Permutation(ext)
Expand Down
43 changes: 22 additions & 21 deletions src/sage/combinat/permutation.py
Expand Up @@ -3972,7 +3972,7 @@ def right_permutohedron_interval(self, other):
ValueError: len([2, 4, 1, 3]) and len([2, 1, 4, 5, 3]) must be equal
"""
P = Permutations()
return [P(p) for p in self.right_permutohedron_interval_iterator(other)]
return sorted(P(p) for p in self.right_permutohedron_interval_iterator(other))

def permutohedron_join(self, other, side="right"):
r"""
Expand Down Expand Up @@ -5185,7 +5185,7 @@ class Permutations(UniqueRepresentation, Parent):
sage: p = Permutations(descents=([1], 4)); p
Standard permutations of 4 with descents [1]
sage: p.list()
sage: sorted(p)
[[1, 3, 2, 4], [1, 4, 2, 3], [2, 3, 1, 4], [2, 4, 1, 3], [3, 4, 1, 2]]
::
Expand All @@ -5206,14 +5206,14 @@ class Permutations(UniqueRepresentation, Parent):
sage: p = Permutations(recoils_finer=[2,1]); p
Standard permutations whose recoils composition is finer than [2, 1]
sage: p.list()
sage: sorted(p)
[[1, 2, 3], [1, 3, 2], [3, 1, 2]]
::
sage: p = Permutations(recoils_fatter=[2,1]); p
Standard permutations whose recoils composition is fatter than [2, 1]
sage: p.list()
sage: sorted(p)
[[1, 3, 2], [3, 1, 2], [3, 2, 1]]
::
Expand Down Expand Up @@ -7364,22 +7364,22 @@ def __iter__(self):
EXAMPLES::
sage: Permutations(descents=([2,0],5)).list()
sage: sorted(Permutations(descents=([2,0],5)))
[[2, 1, 4, 3, 5],
[2, 1, 5, 3, 4],
[3, 1, 4, 2, 5],
[3, 1, 5, 2, 4],
[4, 1, 3, 2, 5],
[5, 1, 3, 2, 4],
[4, 1, 5, 2, 3],
[5, 1, 4, 2, 3],
[3, 2, 4, 1, 5],
[3, 2, 5, 1, 4],
[4, 1, 3, 2, 5],
[4, 1, 5, 2, 3],
[4, 2, 3, 1, 5],
[5, 2, 3, 1, 4],
[4, 2, 5, 1, 3],
[5, 2, 4, 1, 3],
[4, 3, 5, 1, 2],
[5, 1, 3, 2, 4],
[5, 1, 4, 2, 3],
[5, 2, 3, 1, 4],
[5, 2, 4, 1, 3],
[5, 3, 4, 1, 2]]
"""
return iter( descents_composition_list(Composition(descents=(self.d,self.n))) )
Expand All @@ -7392,23 +7392,24 @@ def descents_composition_list(dc):
EXAMPLES::
sage: import sage.combinat.permutation as permutation
sage: permutation.descents_composition_list([1,2,2])
sage: sorted(permutation.descents_composition_list([1,2,2]))
[[2, 1, 4, 3, 5],
[2, 1, 5, 3, 4],
[3, 1, 4, 2, 5],
[3, 1, 5, 2, 4],
[4, 1, 3, 2, 5],
[5, 1, 3, 2, 4],
[4, 1, 5, 2, 3],
[5, 1, 4, 2, 3],
[3, 2, 4, 1, 5],
[3, 2, 5, 1, 4],
[4, 1, 3, 2, 5],
[4, 1, 5, 2, 3],
[4, 2, 3, 1, 5],
[5, 2, 3, 1, 4],
[4, 2, 5, 1, 3],
[5, 2, 4, 1, 3],
[4, 3, 5, 1, 2],
[5, 1, 3, 2, 4],
[5, 1, 4, 2, 3],
[5, 2, 3, 1, 4],
[5, 2, 4, 1, 3],
[5, 3, 4, 1, 2]]
"""
return [p.inverse() for p in StandardPermutations_recoils(dc)]

Expand Down Expand Up @@ -7503,7 +7504,7 @@ def __iter__(self):
EXAMPLES::
sage: Permutations(recoils_finer=[2,2]).list()
sage: sorted(Permutations(recoils_finer=[2,2]))
[[1, 2, 3, 4],
[1, 3, 2, 4],
[1, 3, 4, 2],
Expand Down Expand Up @@ -7570,7 +7571,7 @@ def __iter__(self):
EXAMPLES::
sage: Permutations(recoils_fatter=[2,2]).list()
sage: sorted(Permutations(recoils_fatter=[2,2]))
[[1, 3, 2, 4],
[1, 3, 4, 2],
[1, 4, 3, 2],
Expand Down Expand Up @@ -7644,7 +7645,7 @@ def __iter__(self):
EXAMPLES::
sage: Permutations(recoils=[2,2]).list()
sage: sorted(Permutations(recoils=[2,2]))
[[1, 3, 2, 4], [1, 3, 4, 2], [3, 1, 2, 4], [3, 1, 4, 2], [3, 4, 1, 2]]
"""
recoils = self.recoils
Expand Down
6 changes: 3 additions & 3 deletions src/sage/combinat/posets/posets.py
Expand Up @@ -6061,8 +6061,8 @@ def linear_extensions_graph(self):
sage: N = Poset({1: [3, 4], 2: [4]})
sage: G = N.linear_extensions_graph(); G
Graph on 5 vertices
sage: G.neighbors(N.linear_extension([1,2,3,4]))
[[2, 1, 3, 4], [1, 2, 4, 3], [1, 3, 2, 4]]
sage: sorted(G.neighbors(N.linear_extension([1,2,3,4])))
[[1, 2, 4, 3], [1, 3, 2, 4], [2, 1, 3, 4]]
sage: chevron = Poset({1: [2, 6], 2: [3], 4: [3, 5], 6: [5]})
sage: G = chevron.linear_extensions_graph(); G
Expand All @@ -6082,7 +6082,7 @@ def linear_extensions_graph(self):
"""
from sage.graphs.graph import Graph
# Direct implementation, no optimizations
L = self.linear_extensions()
L = sorted(self.linear_extensions())
G = Graph()
G.add_vertices(L)
for i in range(len(L)):
Expand Down
23 changes: 12 additions & 11 deletions src/sage/combinat/ribbon_shaped_tableau.py
Expand Up @@ -290,7 +290,7 @@ def __iter__(self):
[[None, 1], [2, 3]],
[[1], [2], [3]],
[[1, 2, 3, 4]],
[[None, None, 3], [1, 2, 4]]]
[[None, None, 2], [1, 3, 4]]]
"""
from sage.combinat.partition import _Partitions
for p in _Partitions:
Expand Down Expand Up @@ -363,12 +363,12 @@ class StandardRibbonShapedTableaux_shape(StandardRibbonShapedTableaux):
[[None, 1, 2], [3, 4]]
sage: StandardRibbonShapedTableaux([2,2]).cardinality()
5
sage: StandardRibbonShapedTableaux([2,2]).list()
[[[None, 2, 4], [1, 3]],
[[None, 2, 3], [1, 4]],
[[None, 1, 4], [2, 3]],
sage: sorted(StandardRibbonShapedTableaux([2,2]))
[[[None, 1, 2], [3, 4]],
[[None, 1, 3], [2, 4]],
[[None, 1, 2], [3, 4]]]
[[None, 1, 4], [2, 3]],
[[None, 2, 3], [1, 4]],
[[None, 2, 4], [1, 3]]]
sage: StandardRibbonShapedTableaux([3,2,2]).cardinality()
155
"""
Expand Down Expand Up @@ -433,12 +433,13 @@ def __iter__(self):
EXAMPLES::
sage: [t for t in StandardRibbonShapedTableaux([2,2])]
[[[None, 2, 4], [1, 3]],
[[None, 2, 3], [1, 4]],
[[None, 1, 4], [2, 3]],
sage: sorted(StandardRibbonShapedTableaux([2,2]))
[[[None, 1, 2], [3, 4]],
[[None, 1, 3], [2, 4]],
[[None, 1, 2], [3, 4]]]
[[None, 1, 4], [2, 3]],
[[None, 2, 3], [1, 4]],
[[None, 2, 4], [1, 3]]]
"""
for p in descents_composition_list(self.shape):
yield self.from_permutation(p)
Expand Down
23 changes: 12 additions & 11 deletions src/sage/combinat/skew_tableau.py
Expand Up @@ -1748,15 +1748,16 @@ class StandardSkewTableaux(SkewTableaux):
::
sage: StandardSkewTableaux([[3, 2, 1], [1, 1]]).list()
sage: sorted(StandardSkewTableaux([[3, 2, 1], [1, 1]]))
[[[None, 1, 2], [None, 3], [4]],
[[None, 1, 2], [None, 4], [3]],
[[None, 1, 3], [None, 2], [4]],
[[None, 1, 4], [None, 2], [3]],
[[None, 1, 3], [None, 4], [2]],
[[None, 1, 4], [None, 2], [3]],
[[None, 1, 4], [None, 3], [2]],
[[None, 2, 3], [None, 4], [1]],
[[None, 2, 4], [None, 3], [1]]]
"""
@staticmethod
def __classcall_private__(cls, skp=None):
Expand Down Expand Up @@ -1833,7 +1834,7 @@ def __iter__(self):
[[1]],
[[1, 2]], [[1], [2]], [[None, 1], [2]], [[None, 2], [1]],
[[1, 2, 3]], [[1, 2], [3]], [[1, 3], [2]],
[[None, 1, 2], [3]]]
[[None, 1, 3], [2]]]
"""
n = 0
while True:
Expand Down Expand Up @@ -1897,16 +1898,16 @@ def __iter__(self):
sage: StandardSkewTableaux(3).list()
[[[1, 2, 3]],
[[1, 2], [3]], [[1, 3], [2]],
[[None, 1, 2], [3]], [[None, 1, 3], [2]],
[[None, 1, 3], [2]], [[None, 1, 2], [3]],
[[None, 2, 3], [1]],
[[None, 1], [2, 3]], [[None, 2], [1, 3]],
[[None, None, 1], [2, 3]], [[None, None, 2], [1, 3]], [[None, None, 3], [1, 2]],
[[None, None, 1], [2, 3]], [[None, None, 3], [1, 2]], [[None, None, 2], [1, 3]],
[[1], [2], [3]],
[[None, 1], [None, 2], [3]], [[None, 1], [None, 3], [2]], [[None, 2], [None, 3], [1]],
[[None, 1], [2], [3]], [[None, 2], [1], [3]], [[None, 3], [1], [2]],
[[None, 1], [None, 3], [2]], [[None, 1], [None, 2], [3]], [[None, 2], [None, 3], [1]],
[[None, 1], [2], [3]], [[None, 3], [1], [2]], [[None, 2], [1], [3]],
[[None, None, 1], [None, 2], [3]], [[None, None, 1], [None, 3], [2]],
[[None, None, 2], [None, 1], [3]], [[None, None, 3], [None, 1], [2]],
[[None, None, 2], [None, 3], [1]], [[None, None, 3], [None, 2], [1]]]
[[None, None, 2], [None, 3], [1]], [[None, None, 3], [None, 2], [1]],
[[None, None, 3], [None, 1], [2]], [[None, None, 2], [None, 1], [3]]]
"""
for skp in SkewPartitions(self.n):
for sst in StandardSkewTableaux_shape(skp):
Expand Down Expand Up @@ -1986,12 +1987,12 @@ def __iter__(self):
EXAMPLES::
sage: [st for st in StandardSkewTableaux([[3, 2, 1], [1, 1]])]
sage: sorted(StandardSkewTableaux([[3, 2, 1], [1, 1]]))
[[[None, 1, 2], [None, 3], [4]],
[[None, 1, 2], [None, 4], [3]],
[[None, 1, 3], [None, 2], [4]],
[[None, 1, 4], [None, 2], [3]],
[[None, 1, 3], [None, 4], [2]],
[[None, 1, 4], [None, 2], [3]],
[[None, 1, 4], [None, 3], [2]],
[[None, 2, 3], [None, 4], [1]],
[[None, 2, 4], [None, 3], [1]]]
Expand Down

0 comments on commit f1705d8

Please sign in to comment.