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

Commit

Permalink
doc test +1/2 iterators, move max_block_size, remove unused import st…
Browse files Browse the repository at this point in the history
…atement
  • Loading branch information
zabrocki committed Apr 13, 2018
1 parent bcad2c4 commit 737d383
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 30 deletions.
54 changes: 24 additions & 30 deletions src/sage/combinat/diagram_algebras.py
Expand Up @@ -31,7 +31,7 @@
from sage.structure.unique_representation import UniqueRepresentation
from sage.combinat.combinat import bell_number, catalan_number
from sage.structure.global_options import GlobalOptions
from sage.combinat.set_partition import SetPartitions, AbstractSetPartition, SetPartitions_set
from sage.combinat.set_partition import SetPartitions, AbstractSetPartition
from sage.combinat.partition import Partitions
from sage.combinat.symmetric_group_algebra import SymmetricGroupAlgebra_n
from sage.combinat.permutation import Permutations
Expand Down Expand Up @@ -375,21 +375,6 @@ def propagating_number(self):
"""
return ZZ(sum(1 for part in self._base_diagram if min(part) < 0 and max(part) > 0))

def max_block_size(self):
r"""
The maximum block size of the diagram.
EXAMPLES::
sage: from sage.combinat.diagram_algebras import PartitionDiagram, PartitionDiagrams
sage: pd = PartitionDiagram([[1,-3,-5],[2,4],[3,-1,-2],[5],[-4]])
sage: pd.max_block_size()
3
sage: [d.max_block_size() for d in PartitionDiagrams(2)]
[4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1]
"""
return max([len(block) for block in self])

def count_blocks_of_size(self, n):
r"""
Count the number of blocks of a given size.
Expand Down Expand Up @@ -1209,8 +1194,12 @@ def __iter__(self):
EXAMPLES::
sage: from sage.combinat.diagram_algebras import PartitionDiagrams
sage: list(PartitionDiagrams(1))
[{{-1, 1}}, {{-1}, {1}}]
sage: list(PartitionDiagrams(3/2))
[{{-2, -1, 1, 2}},
{{-2, -1, 2}, {1}},
{{-2, 2}, {-1, 1}},
{{-2, 1, 2}, {-1}},
{{-2, 2}, {-1}, {1}}]
sage: list(PartitionDiagrams(2))
[{{-2, -1, 1, 2}},
{{-2, -1, 2}, {1}},
Expand Down Expand Up @@ -1323,8 +1312,10 @@ def __iter__(self):
EXAMPLES::
sage: from sage.combinat.diagram_algebras import BrauerDiagrams
sage: list(BrauerDiagrams(1))
[{{-1, 1}}]
sage: list(BrauerDiagrams(5/2))
[{{-3, 3}, {-2, 1}, {-1, 2}},
{{-3, 3}, {-2, 2}, {-1, 1}},
{{-3, 3}, {-2, -1}, {1, 2}}]
sage: list(BrauerDiagrams(2))
[{{-2, 1}, {-1, 2}}, {{-2, 2}, {-1, 1}}, {{-2, -1}, {1, 2}}]
"""
Expand Down Expand Up @@ -1536,14 +1527,10 @@ def __iter__(self):
EXAMPLES::
sage: from sage.combinat.diagram_algebras import TemperleyLiebDiagrams
sage: list(TemperleyLiebDiagrams(5/2))
[{{-3, 3}, {-2, 2}, {-1, 1}}, {{-3, 3}, {-2, -1}, {1, 2}}]
sage: list(TemperleyLiebDiagrams(2))
[{{-2, 2}, {-1, 1}}, {{-2, -1}, {1, 2}}]
sage: list(TemperleyLiebDiagrams(3))
[{{-3, 1}, {-2, -1}, {2, 3}},
{{-3, 3}, {-2, 2}, {-1, 1}},
{{-3, 3}, {-2, -1}, {1, 2}},
{{-3, -2}, {-1, 1}, {2, 3}},
{{-3, -2}, {-1, 3}, {1, 2}}]
"""
for p in BrauerDiagrams(self.order):
if p.is_planar():
Expand Down Expand Up @@ -1624,8 +1611,12 @@ def __iter__(self):
EXAMPLES::
sage: from sage.combinat.diagram_algebras import PlanarDiagrams
sage: list(PlanarDiagrams(1))
[{{-1, 1}}, {{-1}, {1}}]
sage: list(PlanarDiagrams(3/2))
[{{-2, -1, 1, 2}},
{{-2, -1, 2}, {1}},
{{-2, 2}, {-1, 1}},
{{-2, 1, 2}, {-1}},
{{-2, 2}, {-1}, {1}}]
sage: list(PlanarDiagrams(2))
[{{-2, -1, 1, 2}},
{{-2, -1, 2}, {1}},
Expand Down Expand Up @@ -1708,8 +1699,11 @@ def __iter__(self):
EXAMPLES::
sage: from sage.combinat.diagram_algebras import IdealDiagrams
sage: list(IdealDiagrams(1))
[{{-1}, {1}}]
sage: list(IdealDiagrams(3/2))
[{{-2, -1, 1, 2}},
{{-2, -1, 2}, {1}},
{{-2, 1, 2}, {-1}},
{{-2, 2}, {-1}, {1}}]
sage: list(IdealDiagrams(2))
[{{-2, -1, 1, 2}},
{{-2, -1, 2}, {1}},
Expand Down
18 changes: 18 additions & 0 deletions src/sage/combinat/set_partition.py
Expand Up @@ -436,6 +436,24 @@ def union(s):
return ret
return [self.parent()(union(s)) for s in SP]

def max_block_size(self):
r"""
The maximum block size of the diagram.
EXAMPLES::
sage: from sage.combinat.diagram_algebras import PartitionDiagram, PartitionDiagrams
sage: pd = PartitionDiagram([[1,-3,-5],[2,4],[3,-1,-2],[5],[-4]])
sage: pd.max_block_size()
3
sage: [d.max_block_size() for d in PartitionDiagrams(2)]
[4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1]
sage: [sp.max_block_size() for sp in SetPartitions(3)]
[3, 2, 2, 2, 1]
"""
return max([len(block) for block in self])


@add_metaclass(InheritComparisonClasscallMetaclass)
class SetPartition(AbstractSetPartition):
"""
Expand Down

0 comments on commit 737d383

Please sign in to comment.