Skip to content

Commit a2c691c

Browse files
author
Matthias Koeppe
committed
sage.combinat: Add # optional
1 parent 1ca4a47 commit a2c691c

File tree

3 files changed

+81
-77
lines changed

3 files changed

+81
-77
lines changed

src/sage/combinat/designs/difference_family.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,9 +1485,10 @@ def relative_difference_set_from_homomorphism(q, N, d, check=True, return_group=
14851485
EXAMPLES::
14861486
14871487
sage: from sage.combinat.designs.difference_family import relative_difference_set_from_homomorphism
1488-
sage: relative_difference_set_from_homomorphism(7, 2, 3) #random
1488+
sage: relative_difference_set_from_homomorphism(7, 2, 3) # random, optional - sage.modules sage.rings.finite_rings
14891489
[(0), (3), (4), (2), (13), (7), (14)]
1490-
sage: relative_difference_set_from_homomorphism(9, 2, 4, check=False, return_group=True) #random
1490+
sage: relative_difference_set_from_homomorphism(9, 2, 4, check=False, # random, optional - sage.modules sage.rings.finite_rings
1491+
....: return_group=True)
14911492
(Additive abelian group isomorphic to Z/80,
14921493
[(0), (4), (6), (13), (7), (12), (15), (8), (9)])
14931494
sage: relative_difference_set_from_homomorphism(9, 2, 5) # optional - sage.modules sage.rings.finite_rings

src/sage/combinat/designs/incidence_structures.py

Lines changed: 77 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,15 @@ def __init__(self, points=None, blocks=None, incidence_matrix=None,
160160
We avoid to convert to integers when the points are not (but compare
161161
equal to integers because of coercion)::
162162
163-
sage: V = GF(5)
164-
sage: e0,e1,e2,e3,e4 = V
165-
sage: [e0,e1,e2,e3,e4] == list(range(5)) # coercion makes them equal
163+
sage: V = GF(5) # optional - sage.rings.finite_rings
164+
sage: e0,e1,e2,e3,e4 = V # optional - sage.rings.finite_rings
165+
sage: [e0,e1,e2,e3,e4] == list(range(5)) # coercion makes them equal # optional - sage.rings.finite_rings
166166
True
167-
sage: blocks = [[e0,e1,e2],[e0,e1],[e2,e4]]
168-
sage: I = IncidenceStructure(V, blocks)
169-
sage: type(I.ground_set()[0])
167+
sage: blocks = [[e0,e1,e2],[e0,e1],[e2,e4]] # optional - sage.rings.finite_rings
168+
sage: I = IncidenceStructure(V, blocks) # optional - sage.rings.finite_rings
169+
sage: type(I.ground_set()[0]) # optional - sage.rings.finite_rings
170170
<class 'sage.rings.finite_rings.integer_mod.IntegerMod_int'>
171-
sage: type(I.blocks()[0][0])
171+
sage: type(I.blocks()[0][0]) # optional - sage.rings.finite_rings
172172
<class 'sage.rings.finite_rings.integer_mod.IntegerMod_int'>
173173
174174
TESTS::
@@ -282,9 +282,9 @@ def __eq__(self, other):
282282
283283
sage: blocks = [[0,1,2],[0,3,4],[0,5,6],[1,3,5],[1,4,6],[2,3,6],[2,4,5]]
284284
sage: BD1 = IncidenceStructure(7, blocks)
285-
sage: M = BD1.incidence_matrix()
286-
sage: BD2 = IncidenceStructure(incidence_matrix=M)
287-
sage: BD1 == BD2
285+
sage: M = BD1.incidence_matrix() # optional - sage.modules
286+
sage: BD2 = IncidenceStructure(incidence_matrix=M) # optional - sage.modules
287+
sage: BD1 == BD2 # optional - sage.modules
288288
True
289289
290290
sage: e1 = frozenset([0,1])
@@ -326,9 +326,9 @@ def __ne__(self, other):
326326
EXAMPLES::
327327
328328
sage: BD1 = IncidenceStructure(7, [[0,1,2],[0,3,4],[0,5,6],[1,3,5],[1,4,6],[2,3,6],[2,4,5]])
329-
sage: M = BD1.incidence_matrix()
330-
sage: BD2 = IncidenceStructure(incidence_matrix=M)
331-
sage: BD1 != BD2
329+
sage: M = BD1.incidence_matrix() # optional - sage.modules
330+
sage: BD2 = IncidenceStructure(incidence_matrix=M) # optional - sage.modules
331+
sage: BD1 != BD2 # optional - sage.modules
332332
False
333333
"""
334334
return not self == other
@@ -363,10 +363,10 @@ def __contains__(self, block):
363363
True
364364
sage: ["Am", "I", "finally", "done ?"] in IS
365365
False
366-
sage: IS = designs.ProjectiveGeometryDesign(3, 1, GF(2), point_coordinates=False)
367-
sage: [3,8,7] in IS
366+
sage: IS = designs.ProjectiveGeometryDesign(3, 1, GF(2), point_coordinates=False) # optional - sage.rings.finite_rings
367+
sage: [3,8,7] in IS # optional - sage.rings.finite_rings
368368
True
369-
sage: [3,8,9] in IS
369+
sage: [3,8,9] in IS # optional - sage.rings.finite_rings
370370
False
371371
"""
372372
try:
@@ -1119,10 +1119,11 @@ def incidence_matrix(self):
11191119
11201120
EXAMPLES::
11211121
1122-
sage: BD = IncidenceStructure(7, [[0,1,2],[0,3,4],[0,5,6],[1,3,5],[1,4,6],[2,3,6],[2,4,5]])
1122+
sage: BD = IncidenceStructure(7, [[0,1,2],[0,3,4],[0,5,6],[1,3,5],
1123+
....: [1,4,6],[2,3,6],[2,4,5]])
11231124
sage: BD.block_sizes()
11241125
[3, 3, 3, 3, 3, 3, 3]
1125-
sage: BD.incidence_matrix()
1126+
sage: BD.incidence_matrix() # optional - sage.modules
11261127
[1 1 1 0 0 0 0]
11271128
[1 0 0 1 1 0 0]
11281129
[1 0 0 0 0 1 1]
@@ -1132,7 +1133,7 @@ def incidence_matrix(self):
11321133
[0 0 1 0 1 1 0]
11331134
11341135
sage: I = IncidenceStructure('abc', ('ab','abc','ac','c'))
1135-
sage: I.incidence_matrix()
1136+
sage: I.incidence_matrix() # optional - sage.modules
11361137
[1 1 1 0]
11371138
[1 1 0 0]
11381139
[0 1 1 1]
@@ -1157,26 +1158,28 @@ def incidence_graph(self,labels=False):
11571158
- ``labels`` (boolean) -- whether to return a graph whose vertices are
11581159
integers, or labelled elements.
11591160
1160-
- ``labels is False`` (default) -- in this case the first vertices
1161-
of the graphs are the elements of :meth:`ground_set`, and appear
1162-
in the same order. Similarly, the following vertices represent the
1163-
elements of :meth:`blocks`, and appear in the same order.
1161+
- ``labels is False`` (default) -- in this case the first vertices
1162+
of the graphs are the elements of :meth:`ground_set`, and appear
1163+
in the same order. Similarly, the following vertices represent the
1164+
elements of :meth:`blocks`, and appear in the same order.
11641165
1165-
- ``labels is True``, the points keep their original labels, and the
1166-
blocks are :func:`Set <Set>` objects.
1166+
- ``labels is True``, the points keep their original labels, and the
1167+
blocks are :func:`Set <Set>` objects.
11671168
1168-
Note that the labelled incidence graph can be incorrect when
1169-
blocks are repeated, and on some (rare) occasions when the
1170-
elements of :meth:`ground_set` mix :func:`Set` and non-:func:`Set
1171-
<Set>` objects.
1169+
Note that the labelled incidence graph can be incorrect when
1170+
blocks are repeated, and on some (rare) occasions when the
1171+
elements of :meth:`ground_set` mix :func:`Set` and non-:func:`Set
1172+
<Set>` objects.
11721173
11731174
EXAMPLES::
11741175
1175-
sage: BD = IncidenceStructure(7, [[0,1,2],[0,3,4],[0,5,6],[1,3,5],[1,4,6],[2,3,6],[2,4,5]])
1176+
sage: BD = IncidenceStructure(7, [[0,1,2],[0,3,4],[0,5,6],[1,3,5],
1177+
....: [1,4,6],[2,3,6],[2,4,5]])
11761178
sage: BD.incidence_graph()
11771179
Bipartite graph on 14 vertices
1178-
sage: A = BD.incidence_matrix()
1179-
sage: Graph(block_matrix([[A*0,A],[A.transpose(),A*0]])) == BD.incidence_graph()
1180+
sage: A = BD.incidence_matrix() # optional - sage.modules
1181+
sage: Graph(block_matrix([[A*0, A], # optional - sage.modules
1182+
....: [A.transpose(),A*0]])) == BD.incidence_graph()
11801183
True
11811184
11821185
TESTS:
@@ -1499,10 +1502,10 @@ def is_t_design(self, t=None, v=None, k=None, l=None, return_parameters=False):
14991502
sage: BD.is_t_design(0,6,3,7) or BD.is_t_design(0,7,4,7) or BD.is_t_design(0,7,3,8)
15001503
False
15011504
1502-
sage: BD = designs.AffineGeometryDesign(3, 1, GF(2))
1503-
sage: BD.is_t_design(1)
1505+
sage: BD = designs.AffineGeometryDesign(3, 1, GF(2)) # optional - sage.rings.finite_rings
1506+
sage: BD.is_t_design(1) # optional - sage.rings.finite_rings
15041507
True
1505-
sage: BD.is_t_design(2)
1508+
sage: BD.is_t_design(2) # optional - sage.rings.finite_rings
15061509
True
15071510
15081511
Steiner triple and quadruple systems are other names for `2-(v,3,1)` and
@@ -1568,11 +1571,11 @@ def is_t_design(self, t=None, v=None, k=None, l=None, return_parameters=False):
15681571
[(8, 4, 7)]
15691572
sage: [(v,k,l) for v in R for k in R for l in R if S4_8.is_t_design(0,v,k,l)]
15701573
[(8, 4, 14)]
1571-
sage: A = designs.AffineGeometryDesign(3, 1, GF(2))
1572-
sage: A.is_t_design(return_parameters=True)
1574+
sage: A = designs.AffineGeometryDesign(3, 1, GF(2)) # optional - sage.rings.finite_rings
1575+
sage: A.is_t_design(return_parameters=True) # optional - sage.rings.finite_rings
15731576
(True, (2, 8, 2, 1))
1574-
sage: A = designs.AffineGeometryDesign(4, 2, GF(2))
1575-
sage: A.is_t_design(return_parameters=True)
1577+
sage: A = designs.AffineGeometryDesign(4, 2, GF(2)) # optional - sage.rings.finite_rings
1578+
sage: A.is_t_design(return_parameters=True) # optional - sage.rings.finite_rings
15761579
(True, (3, 16, 4, 1))
15771580
sage: I = IncidenceStructure(2, [])
15781581
sage: I.is_t_design(return_parameters=True)
@@ -1712,9 +1715,10 @@ def is_generalized_quadrangle(self, verbose=False, parameters=False):
17121715
False
17131716
17141717
sage: G = graphs.CycleGraph(5)
1715-
sage: B = list(G.subgraph_search_iterator(graphs.PathGraph(3), return_graphs=False))
1716-
sage: H = IncidenceStructure(B)
1717-
sage: H.is_generalized_quadrangle(verbose=True)
1718+
sage: B = list(G.subgraph_search_iterator(graphs.PathGraph(3), # optional - sage.modules
1719+
....: return_graphs=False))
1720+
sage: H = IncidenceStructure(B) # optional - sage.modules
1721+
sage: H.is_generalized_quadrangle(verbose=True) # optional - sage.modules
17181722
Two blocks intersect on >1 points.
17191723
False
17201724
@@ -1770,25 +1774,23 @@ def dual(self, algorithm=None):
17701774
The dual of a projective plane is a projective plane::
17711775
17721776
sage: PP = designs.DesarguesianProjectivePlaneDesign(4)
1773-
sage: PP.dual().is_t_design(return_parameters=True)
1777+
sage: PP.dual().is_t_design(return_parameters=True) # optional - sage.modules
17741778
(True, (2, 21, 5, 1))
17751779
17761780
TESTS::
17771781
1778-
sage: D = IncidenceStructure(4, [[0,2],[1,2,3],[2,3]])
1779-
sage: D
1782+
sage: D = IncidenceStructure(4, [[0,2],[1,2,3],[2,3]]); D
17801783
Incidence structure with 4 points and 3 blocks
1781-
sage: D.dual()
1784+
sage: D.dual() # optional - sage.modules
17821785
Incidence structure with 3 points and 4 blocks
1783-
sage: print(D.dual(algorithm="gap")) # optional - gap_packages
1786+
sage: print(D.dual(algorithm="gap")) # optional - gap_packages
17841787
Incidence structure with 3 points and 4 blocks
17851788
sage: blocks = [[0,1,2],[0,3,4],[0,5,6],[1,3,5],[1,4,6],[2,3,6],[2,4,5]]
1786-
sage: BD = IncidenceStructure(7, blocks, name="FanoPlane")
1787-
sage: BD
1789+
sage: BD = IncidenceStructure(7, blocks, name="FanoPlane"); BD
17881790
Incidence structure with 7 points and 7 blocks
1789-
sage: print(BD.dual(algorithm="gap")) # optional - gap_packages
1791+
sage: print(BD.dual(algorithm="gap")) # optional - gap_packages
17901792
Incidence structure with 7 points and 7 blocks
1791-
sage: BD.dual()
1793+
sage: BD.dual() # optional - sage.modules
17921794
Incidence structure with 7 points and 7 blocks
17931795
17941796
REFERENCE:
@@ -1817,28 +1819,28 @@ def automorphism_group(self):
18171819
18181820
sage: P = designs.DesarguesianProjectivePlaneDesign(2); P
18191821
(7,3,1)-Balanced Incomplete Block Design
1820-
sage: G = P.automorphism_group()
1821-
sage: G.is_isomorphic(PGL(3,2))
1822+
sage: G = P.automorphism_group() # optional - sage.groups
1823+
sage: G.is_isomorphic(PGL(3,2)) # optional - sage.groups
18221824
True
1823-
sage: G
1825+
sage: G # optional - sage.groups
18241826
Permutation Group with generators [...]
1825-
sage: G.cardinality()
1827+
sage: G.cardinality() # optional - sage.groups
18261828
168
18271829
18281830
A non self-dual example::
18291831
18301832
sage: IS = IncidenceStructure(list(range(4)), [[0,1,2,3],[1,2,3]])
1831-
sage: IS.automorphism_group().cardinality()
1833+
sage: IS.automorphism_group().cardinality() # optional - sage.groups
18321834
6
1833-
sage: IS.dual().automorphism_group().cardinality()
1835+
sage: IS.dual().automorphism_group().cardinality() # optional - sage.groups sage.modules
18341836
1
18351837
18361838
Examples with non-integer points::
18371839
18381840
sage: I = IncidenceStructure('abc', ('ab','ac','bc'))
1839-
sage: I.automorphism_group()
1841+
sage: I.automorphism_group() # optional - sage.groups
18401842
Permutation Group with generators [('b','c'), ('a','b')]
1841-
sage: IncidenceStructure([[(1,2),(3,4)]]).automorphism_group()
1843+
sage: IncidenceStructure([[(1,2),(3,4)]]).automorphism_group() # optional - sage.groups
18421844
Permutation Group with generators [((1,2),(3,4))]
18431845
"""
18441846
from sage.graphs.graph import Graph
@@ -1907,20 +1909,20 @@ def is_resolvable(self, certificate=False, solver=None, verbose=0, check=True,
19071909
sage: TD.is_resolvable()
19081910
True
19091911
1910-
sage: AG = designs.AffineGeometryDesign(3,1,GF(2))
1911-
sage: AG.is_resolvable()
1912+
sage: AG = designs.AffineGeometryDesign(3,1,GF(2)) # optional - sage.rings.finite_rings
1913+
sage: AG.is_resolvable() # optional - sage.rings.finite_rings
19121914
True
19131915
19141916
Their classes::
19151917
1916-
sage: b,cls = TD.is_resolvable(True)
1918+
sage: b, cls = TD.is_resolvable(True)
19171919
sage: b
19181920
True
19191921
sage: cls # random
19201922
[[[0, 3], [1, 2]], [[1, 3], [0, 2]]]
19211923
1922-
sage: b,cls = AG.is_resolvable(True)
1923-
sage: b
1924+
sage: b, cls = AG.is_resolvable(True) # optional - sage.rings.finite_rings
1925+
sage: b # optional - sage.rings.finite_rings
19241926
True
19251927
sage: cls # random
19261928
[[[6, 7], [4, 5], [0, 1], [2, 3]],
@@ -1941,9 +1943,9 @@ def is_resolvable(self, certificate=False, solver=None, verbose=0, check=True,
19411943
19421944
TESTS::
19431945
1944-
sage: _,cls1 = AG.is_resolvable(certificate=True)
1945-
sage: _,cls2 = AG.is_resolvable(certificate=True)
1946-
sage: cls1 is cls2
1946+
sage: _, cls1 = AG.is_resolvable(certificate=True) # optional - sage.rings.finite_rings
1947+
sage: _, cls2 = AG.is_resolvable(certificate=True) # optional - sage.rings.finite_rings
1948+
sage: cls1 is cls2 # optional - sage.rings.finite_rings
19471949
False
19481950
"""
19491951
if self._classes is None:
@@ -2152,8 +2154,8 @@ def _spring_layout(self):
21522154
21532155
sage: H = Hypergraph([{1,2,3},{2,3,4},{3,4,5},{4,5,6}]); H
21542156
Incidence structure with 6 points and 4 blocks
2155-
sage: L = H._spring_layout()
2156-
sage: L # random
2157+
sage: L = H._spring_layout() # optional - sage.plot
2158+
sage: L # random # optional - sage.plot
21572159
{1: (0.238, -0.926),
21582160
2: (0.672, -0.518),
21592161
3: (0.449, -0.225),
@@ -2164,9 +2166,9 @@ def _spring_layout(self):
21642166
{2, 3, 4}: (0.727, -0.173),
21652167
{4, 5, 6}: (0.838, 0.617),
21662168
{1, 2, 3}: (0.393, -0.617)}
2167-
sage: all(v in L for v in H.ground_set())
2169+
sage: all(v in L for v in H.ground_set()) # optional - sage.plot
21682170
True
2169-
sage: all(v in L for v in map(Set,H.blocks()))
2171+
sage: all(v in L for v in map(Set, H.blocks())) # optional - sage.plot
21702172
True
21712173
"""
21722174
from sage.graphs.graph import Graph
@@ -2196,9 +2198,10 @@ def _latex_(self):
21962198
21972199
sage: g = graphs.Grid2dGraph(5,5)
21982200
sage: C4 = graphs.CycleGraph(4)
2199-
sage: sets = Set(map(Set,list(g.subgraph_search_iterator(C4, return_graphs=False))))
2200-
sage: H = Hypergraph(sets)
2201-
sage: view(H) # not tested
2201+
sage: sets = Set(map(Set, g.subgraph_search_iterator(C4, # optional - sage.modules
2202+
....: return_graphs=False)))
2203+
sage: H = Hypergraph(sets) # optional - sage.modules
2204+
sage: view(H) # not tested # optional - sage.modules sage.plot
22022205
22032206
TESTS::
22042207

src/sage/combinat/designs/latin_squares.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# -*- coding: utf-8 -*-
1+
# sage.doctest: optional - sage.modules
22
r"""
33
Mutually Orthogonal Latin Squares (MOLS)
44

0 commit comments

Comments
 (0)