Skip to content

Commit 9734dd9

Browse files
author
Release Manager
committed
gh-37610: src/sage/combinat: Doctest cosmetics <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes #12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes #12345". --> Standard reformatting of doctests and their outputs Split out from #35095 ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [ ] The title is concise and informative. - [ ] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - #12345: short description why this is a dependency --> <!-- - #34567: ... --> URL: #37610 Reported by: Matthias Köppe Reviewer(s): David Coudert, Matthias Köppe
2 parents ef7a598 + 82266d0 commit 9734dd9

20 files changed

+317
-231
lines changed

src/sage/combinat/binary_tree.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1617,7 +1617,7 @@ def to_tilting(self):
16171617
sage: t = from_hexacode('2020222002000', BinaryTrees())
16181618
sage: print(t.to_tilting())
16191619
[(0, 1), (2, 3), (4, 5), (6, 7), (4, 7), (8, 9), (10, 11),
1620-
(8, 11), (4, 11), (12, 13), (4, 13), (2, 13), (0, 13)]
1620+
(8, 11), (4, 11), (12, 13), (4, 13), (2, 13), (0, 13)]
16211621
16221622
sage: w = DyckWord([1,1,1,1,0,1,1,0,0,0,1,1,0,1,0,1,1,0,1,1,0,0,0,0,0,0]) # needs sage.combinat
16231623
sage: t2 = w.to_binary_tree() # needs sage.combinat

src/sage/combinat/designs/difference_family.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3186,11 +3186,12 @@ def difference_family(v, k, l=1, existence=False, explain_construction=False, ch
31863186
sage: print(designs.difference_family(15,7,3,explain_construction=True))
31873187
Singer difference set
31883188
3189-
sage: print(designs.difference_family(91,10,1,explain_construction=True)) # needs sage.libs.pari
3189+
sage: # needs sage.libs.pari
3190+
sage: print(designs.difference_family(91,10,1,explain_construction=True))
31903191
Singer difference set
3191-
sage: print(designs.difference_family(64,28,12, explain_construction=True)) # needs sage.libs.pari
3192+
sage: print(designs.difference_family(64,28,12, explain_construction=True))
31923193
McFarland 1973 construction
3193-
sage: print(designs.difference_family(576, 276, 132, explain_construction=True)) # needs sage.libs.pari
3194+
sage: print(designs.difference_family(576, 276, 132, explain_construction=True))
31943195
Hadamard difference set product from N1=2 and N2=3
31953196
31963197
For `k=6,7` we look at the set of small prime powers for which a
@@ -3203,9 +3204,10 @@ def difference_family(v, k, l=1, existence=False, explain_construction=False, ch
32033204
....: yield k
32043205
....: k += m
32053206
3207+
sage: # needs sage.libs.pari
32063208
sage: from itertools import islice
3207-
sage: l6 = {True:[], False: [], Unknown: []}
3208-
sage: for q in islice(prime_power_mod(1,30), int(60)): # needs sage.libs.pari
3209+
sage: l6 = {True: [], False: [], Unknown: []}
3210+
sage: for q in islice(prime_power_mod(1,30), int(60)):
32093211
....: l6[designs.difference_family(q,6,existence=True)].append(q)
32103212
sage: l6[True]
32113213
[31, 121, 151, 181, 211, ..., 3061, 3121, 3181]
@@ -3214,8 +3216,9 @@ def difference_family(v, k, l=1, existence=False, explain_construction=False, ch
32143216
sage: l6[False]
32153217
[]
32163218
3219+
sage: # needs sage.libs.pari
32173220
sage: l7 = {True: [], False: [], Unknown: []}
3218-
sage: for q in islice(prime_power_mod(1,42), int(60)): # needs sage.libs.pari
3221+
sage: for q in islice(prime_power_mod(1,42), int(60)):
32193222
....: l7[designs.difference_family(q,7,existence=True)].append(q)
32203223
sage: l7[True]
32213224
[169, 337, 379, 421, 463, 547, 631, 673, 757, 841, 883, 967, ..., 4621, 4957, 5167]

src/sage/combinat/free_dendriform_algebra.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ class FreeDendriformAlgebra(CombinatorialFreeModule):
8787
sage: F = algebras.FreeDendriform(ZZ, 'xyz')
8888
sage: x,y,z = F.gens()
8989
sage: (x * y) * z
90-
B[x[., y[., z[., .]]]] + B[x[., z[y[., .], .]]] + B[y[x[., .], z[., .]]] + B[z[x[., y[., .]], .]] + B[z[y[x[., .], .], .]]
90+
B[x[., y[., z[., .]]]] + B[x[., z[y[., .], .]]] + B[y[x[., .], z[., .]]]
91+
+ B[z[x[., y[., .]], .]] + B[z[y[x[., .], .], .]]
9192
9293
The free dendriform algebra is associative::
9394
@@ -114,7 +115,8 @@ class FreeDendriformAlgebra(CombinatorialFreeModule):
114115
sage: w = F1.gen(0); w
115116
B[[., .]]
116117
sage: w * w * w
117-
B[[., [., [., .]]]] + B[[., [[., .], .]]] + B[[[., .], [., .]]] + B[[[., [., .]], .]] + B[[[[., .], .], .]]
118+
B[[., [., [., .]]]] + B[[., [[., .], .]]] + B[[[., .], [., .]]]
119+
+ B[[[., [., .]], .]] + B[[[[., .], .], .]]
118120
119121
The set `E` can be infinite::
120122

src/sage/combinat/interval_posets.py

Lines changed: 45 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,7 +1129,8 @@ def rise_contact_involution(self) -> TIP:
11291129
11301130
EXAMPLES::
11311131
1132-
sage: tip = TamariIntervalPoset(8, [(1,2), (2,4), (3,4), (6,7), (3,2), (5,4), (6,4), (8,7)])
1132+
sage: tip = TamariIntervalPoset(8, [(1,2), (2,4), (3,4), (6,7),
1133+
....: (3,2), (5,4), (6,4), (8,7)])
11331134
sage: t = tip.rise_contact_involution(); t
11341135
The Tamari interval of size 8 induced by relations [(2, 8), (3, 8),
11351136
(4, 5), (5, 7), (6, 7), (7, 8), (8, 1), (7, 2), (6, 2), (5, 3),
@@ -1840,13 +1841,16 @@ def lower_binary_tree(self):
18401841
18411842
EXAMPLES::
18421843
1843-
sage: ip = TamariIntervalPoset(6,[(3,2),(4,3),(5,2),(6,5),(1,2),(4,5)]); ip
1844-
The Tamari interval of size 6 induced by relations [(1, 2), (4, 5), (6, 5), (5, 2), (4, 3), (3, 2)]
1844+
sage: ip = TamariIntervalPoset(6, [(3,2),(4,3),(5,2),(6,5),(1,2),(4,5)]); ip
1845+
The Tamari interval of size 6 induced by relations
1846+
[(1, 2), (4, 5), (6, 5), (5, 2), (4, 3), (3, 2)]
18451847
sage: ip.lower_binary_tree()
18461848
[[., .], [[., [., .]], [., .]]]
1847-
sage: TamariIntervalPosets.final_forest(ip.lower_binary_tree()) == ip.final_forest()
1849+
sage: ff = TamariIntervalPosets.final_forest(ip.lower_binary_tree())
1850+
sage: ff == ip.final_forest()
18481851
True
1849-
sage: ip == TamariIntervalPosets.from_binary_trees(ip.lower_binary_tree(),ip.upper_binary_tree())
1852+
sage: ip == TamariIntervalPosets.from_binary_trees(ip.lower_binary_tree(),
1853+
....: ip.upper_binary_tree())
18501854
True
18511855
"""
18521856
return self.min_linear_extension().binary_search_tree_shape(left_to_right=False)
@@ -1891,9 +1895,11 @@ def upper_binary_tree(self):
18911895
EXAMPLES::
18921896
18931897
sage: ip = TamariIntervalPoset(6,[(3,2),(4,3),(5,2),(6,5),(1,2),(4,5)]); ip
1894-
The Tamari interval of size 6 induced by relations [(1, 2), (4, 5), (6, 5), (5, 2), (4, 3), (3, 2)]
1898+
The Tamari interval of size 6 induced by relations
1899+
[(1, 2), (4, 5), (6, 5), (5, 2), (4, 3), (3, 2)]
18951900
sage: ip.upper_binary_tree()
18961901
[[., .], [., [[., .], [., .]]]]
1902+
18971903
sage: TamariIntervalPosets.initial_forest(ip.upper_binary_tree()) == ip.initial_forest()
18981904
True
18991905
sage: ip == TamariIntervalPosets.from_binary_trees(ip.lower_binary_tree(),ip.upper_binary_tree())
@@ -1941,8 +1947,9 @@ def subposet(self, start, end) -> TIP:
19411947
19421948
EXAMPLES::
19431949
1944-
sage: ip = TamariIntervalPoset(6,[(3,2),(4,3),(5,2),(6,5),(1,2),(3,5),(4,5)]); ip
1945-
The Tamari interval of size 6 induced by relations [(1, 2), (3, 5), (4, 5), (6, 5), (5, 2), (4, 3), (3, 2)]
1950+
sage: ip = TamariIntervalPoset(6, [(3,2),(4,3),(5,2),(6,5),(1,2),(3,5),(4,5)]); ip
1951+
The Tamari interval of size 6 induced by relations
1952+
[(1, 2), (3, 5), (4, 5), (6, 5), (5, 2), (4, 3), (3, 2)]
19461953
sage: ip.subposet(1,3)
19471954
The Tamari interval of size 2 induced by relations [(1, 2)]
19481955
sage: ip.subposet(1,4)
@@ -2109,12 +2116,16 @@ def lower_contained_intervals(self) -> Iterator[TIP]:
21092116
21102117
EXAMPLES::
21112118
2112-
sage: ip = TamariIntervalPoset(4,[(2,4),(3,4),(2,1),(3,1)])
2119+
sage: ip = TamariIntervalPoset(4, [(2,4),(3,4),(2,1),(3,1)])
21132120
sage: list(ip.lower_contained_intervals())
2114-
[The Tamari interval of size 4 induced by relations [(2, 4), (3, 4), (3, 1), (2, 1)],
2115-
The Tamari interval of size 4 induced by relations [(1, 4), (2, 4), (3, 4), (3, 1), (2, 1)],
2116-
The Tamari interval of size 4 induced by relations [(2, 3), (3, 4), (3, 1), (2, 1)],
2117-
The Tamari interval of size 4 induced by relations [(1, 4), (2, 3), (3, 4), (3, 1), (2, 1)]]
2121+
[The Tamari interval of size 4 induced by relations
2122+
[(2, 4), (3, 4), (3, 1), (2, 1)],
2123+
The Tamari interval of size 4 induced by relations
2124+
[(1, 4), (2, 4), (3, 4), (3, 1), (2, 1)],
2125+
The Tamari interval of size 4 induced by relations
2126+
[(2, 3), (3, 4), (3, 1), (2, 1)],
2127+
The Tamari interval of size 4 induced by relations
2128+
[(1, 4), (2, 3), (3, 4), (3, 1), (2, 1)]]
21182129
sage: ip = TamariIntervalPoset(4,[])
21192130
sage: len(list(ip.lower_contained_intervals()))
21202131
14
@@ -2256,12 +2267,15 @@ def maximal_chain_tamari_intervals(self) -> Iterator[TIP]:
22562267
22572268
EXAMPLES::
22582269
2259-
sage: ip = TamariIntervalPoset(4,[(2,4),(3,4),(2,1),(3,1)])
2270+
sage: ip = TamariIntervalPoset(4, [(2,4),(3,4),(2,1),(3,1)])
22602271
sage: list(ip.maximal_chain_tamari_intervals())
2261-
[The Tamari interval of size 4 induced by relations [(2, 4), (3, 4), (3, 1), (2, 1)],
2262-
The Tamari interval of size 4 induced by relations [(2, 4), (3, 4), (4, 1), (3, 1), (2, 1)],
2263-
The Tamari interval of size 4 induced by relations [(2, 4), (3, 4), (4, 1), (3, 2), (2, 1)]]
2264-
sage: ip = TamariIntervalPoset(4,[])
2272+
[The Tamari interval of size 4 induced by relations
2273+
[(2, 4), (3, 4), (3, 1), (2, 1)],
2274+
The Tamari interval of size 4 induced by relations
2275+
[(2, 4), (3, 4), (4, 1), (3, 1), (2, 1)],
2276+
The Tamari interval of size 4 induced by relations
2277+
[(2, 4), (3, 4), (4, 1), (3, 2), (2, 1)]]
2278+
sage: ip = TamariIntervalPoset(4, [])
22652279
sage: list(ip.maximal_chain_tamari_intervals())
22662280
[The Tamari interval of size 4 induced by relations [],
22672281
The Tamari interval of size 4 induced by relations [(2, 1)],
@@ -2405,7 +2419,8 @@ def tamari_inversions_iter(self) -> Iterator[tuple[int, int]]:
24052419
sage: list(T.tamari_inversions_iter())
24062420
[(4, 5)]
24072421
2408-
sage: T = TamariIntervalPoset(8, [(2, 7), (3, 7), (4, 7), (5, 7), (6, 7), (8, 7), (6, 4), (5, 4), (4, 3), (3, 2)])
2422+
sage: T = TamariIntervalPoset(8, [(2, 7), (3, 7), (4, 7), (5, 7), (6, 7),
2423+
....: (8, 7), (6, 4), (5, 4), (4, 3), (3, 2)])
24092424
sage: list(T.tamari_inversions_iter())
24102425
[(1, 2), (1, 7), (5, 6)]
24112426
@@ -2565,12 +2580,14 @@ def decomposition_to_triple(self) -> None | tuple[TIP, TIP, int]:
25652580
25662581
EXAMPLES::
25672582
2568-
sage: tip = TamariIntervalPoset(8, [(1,2), (2,4), (3,4), (6,7), (3,2), (5,4), (6,4), (8,7)])
2583+
sage: tip = TamariIntervalPoset(8, [(1,2), (2,4), (3,4), (6,7),
2584+
....: (3,2), (5,4), (6,4), (8,7)])
25692585
sage: tip.decomposition_to_triple()
25702586
(The Tamari interval of size 3 induced by relations [(1, 2), (3, 2)],
2571-
The Tamari interval of size 4 induced by relations [(2, 3), (4, 3)],
2572-
2)
2573-
sage: tip == TamariIntervalPosets.recomposition_from_triple(*tip.decomposition_to_triple())
2587+
The Tamari interval of size 4 induced by relations [(2, 3), (4, 3)],
2588+
2)
2589+
sage: tip == TamariIntervalPosets.recomposition_from_triple(
2590+
....: *tip.decomposition_to_triple())
25742591
True
25752592
25762593
TESTS::
@@ -2600,7 +2617,8 @@ def grafting_tree(self) -> LabelledBinaryTree:
26002617
26012618
EXAMPLES::
26022619
2603-
sage: tip = TamariIntervalPoset(8, [(1,2), (2,4), (3,4), (6,7), (3,2), (5,4), (6,4), (8,7)])
2620+
sage: tip = TamariIntervalPoset(8, [(1,2), (2,4), (3,4), (6,7),
2621+
....: (3,2), (5,4), (6,4), (8,7)])
26042622
sage: tip.grafting_tree()
26052623
2[1[0[., .], 0[., .]], 0[., 1[0[., .], 0[., .]]]]
26062624
sage: tip == TamariIntervalPosets.from_grafting_tree(tip.grafting_tree())
@@ -2906,7 +2924,7 @@ class options(GlobalOptions):
29062924
sage: TIP = TamariIntervalPosets
29072925
sage: TIP.options.latex_color_decreasing
29082926
red
2909-
sage: TIP.options.latex_color_decreasing='green'
2927+
sage: TIP.options.latex_color_decreasing = 'green'
29102928
sage: TIP.options.latex_color_decreasing
29112929
green
29122930
sage: TIP.options._reset()
@@ -3243,7 +3261,8 @@ def from_binary_trees(tree1, tree2) -> TIP:
32433261
sage: tree1 = BinaryTree([[],[[None,[]],[]]])
32443262
sage: tree2 = BinaryTree([None,[None,[None,[[],[]]]]])
32453263
sage: TamariIntervalPosets.from_binary_trees(tree1,tree2)
3246-
The Tamari interval of size 6 induced by relations [(4, 5), (6, 5), (5, 2), (4, 3), (3, 2)]
3264+
The Tamari interval of size 6 induced by relations
3265+
[(4, 5), (6, 5), (5, 2), (4, 3), (3, 2)]
32473266
32483267
sage: tree3 = BinaryTree([None,[None,[[],[None,[]]]]])
32493268
sage: TamariIntervalPosets.from_binary_trees(tree1,tree3)

src/sage/combinat/matrices/latin.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
#. some named latin squares (back circulant, forward circulant, abelian
4242
`2`-group);
4343
44-
#. functions is\_partial\_latin\_square and is\_latin\_square to test
45-
if a LatinSquare object satisfies the definition of a latin square
44+
#. methods :meth:`is_partial_latin_square` and :meth:`is_latin_square` to test
45+
if a :class:`LatinSquare` object satisfies the definition of a latin square
4646
or partial latin square, respectively;
4747
4848
#. tests for completion and unique completion (these use the C++
@@ -57,7 +57,7 @@
5757
5858
#. a few examples of `\tau_i` representations of bitrades constructed
5959
from the action of a group on itself by right multiplication,
60-
functions for converting to a pair of LatinSquare objects.
60+
functions for converting to a pair of :class:`LatinSquare` objects.
6161
6262
EXAMPLES::
6363

src/sage/combinat/necklace.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ def cardinality(self) -> Integer:
210210
211211
::
212212
213-
sage: comps = [[],[2,2],[3,2,7],[4,2],[0,4,2],[2,0,4]]+Compositions(4).list()
213+
sage: comps = [[],[2,2],[3,2,7],[4,2],[0,4,2],[2,0,4]] + Compositions(4).list()
214214
sage: ns = [Necklaces(comp) for comp in comps]
215215
sage: all(n.cardinality() == len(n.list()) for n in ns) # needs sage.libs.pari
216216
True

src/sage/combinat/partition.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5197,7 +5197,8 @@ def dimension(self, smaller=None, k=1):
51975197
Checks that the sum of squares of dimensions of characters of the
51985198
symmetric group is the order of the group::
51995199
5200-
sage: all(sum(mu.dimension()^2 for mu in Partitions(i))==factorial(i) for i in range(10))
5200+
sage: all(sum(mu.dimension()^2 for mu in Partitions(i)) == factorial(i)
5201+
....: for i in range(10))
52015202
True
52025203
52035204
A check coming from the theory of `k`-differentiable posets::
@@ -5716,14 +5717,14 @@ class Partitions(UniqueRepresentation, Parent):
57165717
Here are some more examples illustrating ``min_part``, ``max_part``,
57175718
and ``length``::
57185719
5719-
sage: Partitions(5,min_part=2)
5720+
sage: Partitions(5, min_part=2)
57205721
Partitions of the integer 5 satisfying constraints min_part=2
5721-
sage: Partitions(5,min_part=2).list()
5722+
sage: Partitions(5, min_part=2).list()
57225723
[[5], [3, 2]]
57235724
57245725
::
57255726
5726-
sage: Partitions(3,max_length=2).list()
5727+
sage: Partitions(3, max_length=2).list()
57275728
[[3], [2, 1]]
57285729
57295730
::
@@ -5836,7 +5837,7 @@ class Partitions(UniqueRepresentation, Parent):
58365837
...
58375838
ValueError: the size must be specified with any keyword argument
58385839
5839-
sage: Partitions(max_part = 3)
5840+
sage: Partitions(max_part=3)
58405841
3-Bounded Partitions
58415842
58425843
Check that :issue:`14145` has been fixed::

src/sage/combinat/partition_tuple.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ class of modules for the algebras, which are generalisations of the Specht
155155
* ** *
156156
* *
157157
*
158-
sage: lam=PartitionTuples(3)([[3,2],[],[1,1,1,1]]); lam
158+
sage: lam = PartitionTuples(3)([[3,2],[],[1,1,1,1]]); lam
159159
([3, 2], [], [1, 1, 1, 1])
160160
sage: lam.level()
161161
3
@@ -200,7 +200,7 @@ class of modules for the algebras, which are generalisations of the Specht
200200
201201
Every partition tuple behaves every much like a tuple of partitions::
202202
203-
sage: mu=PartitionTuple([[4,1],[],[2,2,1],[3]])
203+
sage: mu = PartitionTuple([[4,1],[],[2,2,1],[3]])
204204
sage: [ nu for nu in mu ]
205205
[[4, 1], [], [2, 2, 1], [3]]
206206
sage: Set([ type(nu) for nu in mu ])
@@ -228,9 +228,11 @@ class of modules for the algebras, which are generalisations of the Specht
228228
sage: len(mu)
229229
4
230230
sage: mu.cells()
231-
[(0, 0, 0), (0, 0, 1), (0, 0, 2), (0, 0, 3), (0, 1, 0), (2, 0, 0), (2, 0, 1), (2, 1, 0), (2, 1, 1), (2, 2, 0), (3, 0, 0), (3, 0, 1), (3, 0, 2)]
231+
[(0, 0, 0), (0, 0, 1), (0, 0, 2), (0, 0, 3), (0, 1, 0), (2, 0, 0), (2, 0, 1),
232+
(2, 1, 0), (2, 1, 1), (2, 2, 0), (3, 0, 0), (3, 0, 1), (3, 0, 2)]
232233
sage: mu.addable_cells()
233-
[(0, 0, 4), (0, 1, 1), (0, 2, 0), (1, 0, 0), (2, 0, 2), (2, 2, 1), (2, 3, 0), (3, 0, 3), (3, 1, 0)]
234+
[(0, 0, 4), (0, 1, 1), (0, 2, 0), (1, 0, 0), (2, 0, 2), (2, 2, 1),
235+
(2, 3, 0), (3, 0, 3), (3, 1, 0)]
234236
sage: mu.removable_cells()
235237
[(0, 0, 3), (0, 1, 0), (2, 1, 1), (2, 2, 0), (3, 0, 2)]
236238
@@ -2376,7 +2378,7 @@ def _repr_(self):
23762378
23772379
sage: PartitionTuples(4,2)
23782380
Partition tuples of level 4 and size 2
2379-
sage: PartitionTuples(size=2,level=4)
2381+
sage: PartitionTuples(size=2, level=4)
23802382
Partition tuples of level 4 and size 2
23812383
"""
23822384
return 'Partition tuples of level {} and size {}'.format(self._level, self._size)
@@ -3037,7 +3039,7 @@ def _repr_(self):
30373039
(2, 1, 4)-Regular partition tuples of level 3 and size 7
30383040
sage: PartitionTuples(4,2,3)
30393041
3-Regular partition tuples of level 4 and size 2
3040-
sage: PartitionTuples(size=2,level=4,regular=3)
3042+
sage: PartitionTuples(size=2, level=4, regular=3)
30413043
3-Regular partition tuples of level 4 and size 2
30423044
"""
30433045
if self._ell[1:] == self._ell[:-1]:

0 commit comments

Comments
 (0)