Skip to content

Commit 699024b

Browse files
committed
more details in needs annotations in posets
1 parent dd3bc96 commit 699024b

File tree

1 file changed

+35
-32
lines changed

1 file changed

+35
-32
lines changed

src/sage/combinat/posets/posets.py

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ def Poset(data=None, element_labels=None, cover_relations=False, linear_extensio
434434
With a function that identifies the cover relations: the set
435435
partitions of `\{1, 2, 3\}` ordered by refinement::
436436
437-
sage: # optional - sage.combinat
437+
sage: # needs sage.combinat
438438
sage: elms = SetPartitions(3)
439439
sage: def fcn(A, B):
440440
....: if len(A) != len(B)+1:
@@ -1933,14 +1933,14 @@ def plot(self, label_elements=True, element_labels=None,
19331933
19341934
This function can be used without any parameters::
19351935
1936-
sage: # optional - sage.plot
1936+
sage: # needs sage.plot
19371937
sage: D12 = posets.DivisorLattice(12)
19381938
sage: D12.plot()
19391939
Graphics object consisting of 14 graphics primitives
19401940
19411941
Just the abstract form of the poset; examples of relabeling::
19421942
1943-
sage: # optional - sage.plot
1943+
sage: # needs sage.plot
19441944
sage: D12.plot(label_elements=False)
19451945
Graphics object consisting of 8 graphics primitives
19461946
sage: d = {1: 0, 2: 'a', 3: 'b', 4: 'c', 6: 'd', 12: 1}
@@ -1952,14 +1952,14 @@ def plot(self, label_elements=True, element_labels=None,
19521952
19531953
Some settings for coverings::
19541954
1955-
sage: # optional - sage.plot
1955+
sage: # needs sage.plot
19561956
sage: d = {(a, b): b/a for a, b in D12.cover_relations()}
19571957
sage: D12.plot(cover_labels=d, cover_color='gray', cover_style='dotted')
19581958
Graphics object consisting of 21 graphics primitives
19591959
19601960
To emphasize some elements and show some options::
19611961
1962-
sage: # optional - sage.plot
1962+
sage: # needs sage.plot
19631963
sage: L = LatticePoset({0: [1, 2, 3, 4], 1: [12], 2: [6, 7],
19641964
....: 3: [5, 9], 4: [5, 6, 10, 11], 5: [13],
19651965
....: 6: [12], 7: [12, 8, 9], 8: [13], 9: [13],
@@ -1978,7 +1978,7 @@ def plot(self, label_elements=True, element_labels=None,
19781978
19791979
We check that ``label_elements`` and ``element_labels`` are honored::
19801980
1981-
sage: # optional - sage.plot
1981+
sage: # needs sage.plot
19821982
sage: def get_plot_labels(P):
19831983
....: return sorted(t.string for t in P
19841984
....: if isinstance(t, sage.plot.text.Text))
@@ -1996,7 +1996,7 @@ def plot(self, label_elements=True, element_labels=None,
19961996
19971997
The following checks that :trac:`18936` has been fixed and labels still work::
19981998
1999-
sage: # optional - sage.plot
1999+
sage: # needs sage.plot
20002000
sage: P = Poset({0: [1,2], 1:[3]})
20012001
sage: heights = {1 : [0], 2 : [1], 3 : [2,3]}
20022002
sage: P.plot(heights=heights)
@@ -2007,7 +2007,7 @@ def plot(self, label_elements=True, element_labels=None,
20072007
20082008
The following checks that equal labels are allowed (:trac:`15206`)::
20092009
2010-
sage: # optional - sage.plot
2010+
sage: # needs sage.plot
20112011
sage: P = Poset({1: [2,3]})
20122012
sage: labs = {i: P.rank(i) for i in range(1, 4)}; labs
20132013
{1: 0, 2: 1, 3: 1}
@@ -2016,7 +2016,7 @@ def plot(self, label_elements=True, element_labels=None,
20162016
20172017
The following checks that non-hashable labels are allowed (:trac:`15206`)::
20182018
2019-
sage: # optional - sage.plot
2019+
sage: # needs sage.plot
20202020
sage: P = Poset({1: [2,3]})
20212021
sage: labs = {1: [2, 3], 2: [], 3: []}; labs
20222022
{1: [2, 3], 2: [], 3: []}
@@ -2025,7 +2025,7 @@ def plot(self, label_elements=True, element_labels=None,
20252025
20262026
Plot of the empty poset::
20272027
2028-
sage: # optional - sage.plot
2028+
sage: # needs sage.plot
20292029
sage: P = Poset({})
20302030
sage: P.plot()
20312031
Graphics object consisting of 0 graphics primitives
@@ -2113,7 +2113,7 @@ def show(self, label_elements=True, element_labels=None,
21132113
21142114
EXAMPLES::
21152115
2116-
sage: # optional - sage.plot
2116+
sage: # needs sage.plot
21172117
sage: D = Poset({ 0:[1,2], 1:[3], 2:[3,4] })
21182118
sage: D.plot(label_elements=False)
21192119
Graphics object consisting of 6 graphics primitives
@@ -2123,7 +2123,7 @@ def show(self, label_elements=True, element_labels=None,
21232123
21242124
One more example with cover labels::
21252125
2126-
sage: # optional - sage.plot
2126+
sage: # needs sage.plot
21272127
sage: P = posets.PentagonPoset()
21282128
sage: P.show(cover_labels=lambda a, b: a - b)
21292129
"""
@@ -3716,37 +3716,39 @@ def magnitude(self) -> Integer:
37163716
37173717
EXAMPLES::
37183718
3719+
sage: needs sage.groups sage.libs.flint
37193720
sage: P = posets.PentagonPoset()
3720-
sage: P.magnitude() # needs sage.libs.flint
3721+
sage: P.magnitude()
37213722
1
37223723
3723-
sage: W = SymmetricGroup(4) # needs sage.groups
3724-
sage: P = W.noncrossing_partition_lattice().without_bounds() # needs sage.groups
3725-
sage: P.magnitude() # needs sage.groups sage.libs.flint
3724+
sage: W = SymmetricGroup(4)
3725+
sage: P = W.noncrossing_partition_lattice().without_bounds()
3726+
sage: P.magnitude()
37263727
-4
37273728
37283729
sage: P = posets.TamariLattice(4).without_bounds()
3729-
sage: P.magnitude() # needs sage.libs.flint
3730+
sage: P.magnitude()
37303731
0
37313732
37323733
.. SEEALSO:: :meth:`order_complex`
37333734
37343735
TESTS::
37353736
3737+
sage: needs sage.groups sage.libs.flint
37363738
sage: P1 = posets.RandomPoset(20, 0.05)
37373739
sage: P2 = posets.RandomPoset(20, 0.05)
3738-
sage: m1 = P1.magnitude() # needs sage.libs.flint
3739-
sage: m2 = P2.magnitude() # needs sage.libs.flint
3740+
sage: m1 = P1.magnitude()
3741+
sage: m2 = P2.magnitude()
37403742
sage: U = P1.disjoint_union(P2)
37413743
sage: P = P1.product(P2)
3742-
sage: U.magnitude() == m1 + m2 # needs sage.libs.flint
3744+
sage: U.magnitude() == m1 + m2
37433745
True
3744-
sage: P.magnitude() == m1*m2 # needs sage.libs.flint
3746+
sage: P.magnitude() == m1*m2
37453747
True
37463748
3747-
sage: Poset({}).magnitude() # needs sage.libs.flint
3749+
sage: Poset({}).magnitude()
37483750
0
3749-
sage: Poset({1:[]}).magnitude() # needs sage.libs.flint
3751+
sage: Poset({1:[]}).magnitude()
37503752
1
37513753
"""
37523754
H = self._hasse_diagram
@@ -6721,14 +6723,14 @@ def order_ideal_plot(self, elements):
67216723
67226724
EXAMPLES::
67236725
6724-
sage: # optional - sage.plot
6726+
sage: # needs sage.plot
67256727
sage: P = Poset((divisors(1000), attrcall("divides")))
67266728
sage: P.order_ideal_plot([20, 25])
67276729
Graphics object consisting of 41 graphics primitives
67286730
67296731
TESTS::
67306732
6731-
sage: # optional - sage.plot
6733+
sage: # needs sage.plot
67326734
sage: P = Poset() # Test empty poset
67336735
sage: P.order_ideal_plot([])
67346736
Graphics object consisting of 0 graphics primitives
@@ -8389,34 +8391,35 @@ def greene_shape(self):
83898391
83908392
EXAMPLES::
83918393
8394+
sage: # needs sage.combinat
83928395
sage: P = Poset([[3,2,1], [[3,1],[2,1]]])
8393-
sage: P.greene_shape() # needs sage.combinat
8396+
sage: P.greene_shape()
83948397
[2, 1]
83958398
sage: P = Poset([[1,2,3,4], [[1,4],[2,4],[4,3]]])
8396-
sage: P.greene_shape() # needs sage.combinat
8399+
sage: P.greene_shape()
83978400
[3, 1]
83988401
sage: P = Poset([[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22],
83998402
....: [[1,4],[2,4],[4,3]]])
8400-
sage: P.greene_shape() # needs sage.combinat
8403+
sage: P.greene_shape()
84018404
[3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
84028405
sage: P = Poset([[],[]])
8403-
sage: P.greene_shape() # needs sage.combinat
8406+
sage: P.greene_shape()
84048407
[]
84058408
84068409
AUTHOR:
84078410
84088411
- Darij Grinberg (2013-05-09)
84098412
"""
84108413
from sage.combinat.partition import Partition
8411-
(G, a) = self.frank_network()
8414+
G, a = self.frank_network()
84128415
n = len(self)
84138416
chron = _ford_fulkerson_chronicle(G, (-1, 0), (2, 0), a)
84148417
size = 0
84158418
ps = []
84168419
part = 0
8417-
(pold, vold) = (0, 0)
8420+
pold, vold = (0, 0)
84188421
while size != n:
8419-
(p, v) = next(chron)
8422+
p, v = next(chron)
84208423
if v > vold:
84218424
size += p
84228425
if part > 0:

0 commit comments

Comments
 (0)