From b304a64953a9342bfabd32de238a25d57700d6d2 Mon Sep 17 00:00:00 2001 From: dcoudert Date: Fri, 11 Aug 2023 19:44:39 +0200 Subject: [PATCH 1/2] fix doctest warnings in sage.graphs --- src/sage/graphs/base/static_sparse_graph.pyx | 7 ++++--- .../graphs/generators/distance_regular.pyx | 4 ++-- src/sage/graphs/generators/families.py | 4 ++-- src/sage/graphs/graph_decompositions/tdlib.pyx | 18 ++++++++++-------- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/sage/graphs/base/static_sparse_graph.pyx b/src/sage/graphs/base/static_sparse_graph.pyx index 6fd78510c94..b5462299058 100644 --- a/src/sage/graphs/base/static_sparse_graph.pyx +++ b/src/sage/graphs/base/static_sparse_graph.pyx @@ -1032,15 +1032,16 @@ def spectral_radius(G, prec=1e-10): A larger example:: + sage: # needs sage.modules sage: G = DiGraph() sage: G.add_edges((i,i+1) for i in range(200)) sage: G.add_edge(200,0) sage: G.add_edge(1,0) sage: e_min, e_max = spectral_radius(G, 0.00001) - sage: p = G.adjacency_matrix(sparse=True).charpoly() # needs sage.modules - sage: p # needs sage.modules + sage: p = G.adjacency_matrix(sparse=True).charpoly() + sage: p x^201 - x^199 - 1 - sage: r = p.roots(AA, multiplicities=False)[0] # needs sage.modules + sage: r = p.roots(AA, multiplicities=False)[0] sage: e_min < r < e_max True diff --git a/src/sage/graphs/generators/distance_regular.pyx b/src/sage/graphs/generators/distance_regular.pyx index 15bd3594185..a09403abd31 100644 --- a/src/sage/graphs/generators/distance_regular.pyx +++ b/src/sage/graphs/generators/distance_regular.pyx @@ -1755,8 +1755,8 @@ def _line_graph_generalised_polygon(H): EXAMPLES:: sage: # needs sage.libs.gap - sage: from sage.graphs.generators.distance_regular import \ - ....: _line_graph_generalised_polygon + sage: from sage.graphs.generators.distance_regular import ( + ....: _line_graph_generalised_polygon) sage: G = graphs.GeneralisedHexagonGraph(1, 8) sage: H = _line_graph_generalised_polygon(G) sage: H.is_distance_regular(True) diff --git a/src/sage/graphs/generators/families.py b/src/sage/graphs/generators/families.py index 3ef2c3a5556..734ec58592b 100644 --- a/src/sage/graphs/generators/families.py +++ b/src/sage/graphs/generators/families.py @@ -3940,9 +3940,9 @@ def MathonPseudocyclicStronglyRegularGraph(t, G=None, L=None): sage: # needs sage.modules sage.rings.finite_rings sage: G.relabel(range(9)) sage: G3x3 = graphs.MathonPseudocyclicStronglyRegularGraph(2, G=G, L=L) # needs sage.groups sage.libs.gap - sage: G3x3.is_strongly_regular(parameters=True) + sage: G3x3.is_strongly_regular(parameters=True) # needs sage.groups sage.libs.gap (441, 220, 109, 110) - sage: G3x3.automorphism_group(algorithm="bliss").order() # optional - bliss + sage: G3x3.automorphism_group(algorithm="bliss").order() # optional - bliss # needs sage.groups sage.libs.gap 27 sage: G9 = graphs.MathonPseudocyclicStronglyRegularGraph(2) sage: G9.is_strongly_regular(parameters=True) diff --git a/src/sage/graphs/graph_decompositions/tdlib.pyx b/src/sage/graphs/graph_decompositions/tdlib.pyx index a673b44d1ee..ad3ded3e876 100644 --- a/src/sage/graphs/graph_decompositions/tdlib.pyx +++ b/src/sage/graphs/graph_decompositions/tdlib.pyx @@ -125,10 +125,11 @@ def treedecomposition_exact(G, lb=-1): EXAMPLES:: - sage: import sage.graphs.graph_decompositions.tdlib as tdlib # optional - tdlib - sage: G = graphs.HouseGraph() # optional - tdlib - sage: T = tdlib.treedecomposition_exact(G) # optional - tdlib - sage: T.show(vertex_size=2000) # optional - tdlib + sage: # optional - tdlib + sage: import sage.graphs.graph_decompositions.tdlib as tdlib + sage: G = graphs.HouseGraph() + sage: T = tdlib.treedecomposition_exact(G) + sage: T.show(vertex_size=2000) TESTS:: @@ -176,10 +177,11 @@ def get_width(T): EXAMPLES:: - sage: import sage.graphs.graph_decompositions.tdlib as tdlib # optional - tdlib - sage: G = graphs.PetersenGraph() # optional - tdlib - sage: T = tdlib.treedecomposition_exact(G) # optional - tdlib - sage: tdlib.get_width(T) # optional - tdlib + sage: # optional - tdlib + sage: import sage.graphs.graph_decompositions.tdlib as tdlib + sage: G = graphs.PetersenGraph() + sage: T = tdlib.treedecomposition_exact(G) + sage: tdlib.get_width(T) 4 """ return (max(len(x) for x in T) - 1) if T else -1 From 0670be082e2d4493fcb503b1f18e7e7d12486015 Mon Sep 17 00:00:00 2001 From: dcoudert Date: Fri, 11 Aug 2023 22:16:34 +0200 Subject: [PATCH 2/2] use block level tag --- src/sage/graphs/generators/families.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sage/graphs/generators/families.py b/src/sage/graphs/generators/families.py index 734ec58592b..a5916a13b5c 100644 --- a/src/sage/graphs/generators/families.py +++ b/src/sage/graphs/generators/families.py @@ -3937,12 +3937,12 @@ def MathonPseudocyclicStronglyRegularGraph(t, G=None, L=None): [-4 -3 -2 2 3 4 -1 0 1] [-2 -4 -3 4 2 3 1 -1 0] - sage: # needs sage.modules sage.rings.finite_rings + sage: # needs sage.modules sage.rings.finite_rings sage.groups sage.libs.gap sage: G.relabel(range(9)) - sage: G3x3 = graphs.MathonPseudocyclicStronglyRegularGraph(2, G=G, L=L) # needs sage.groups sage.libs.gap - sage: G3x3.is_strongly_regular(parameters=True) # needs sage.groups sage.libs.gap + sage: G3x3 = graphs.MathonPseudocyclicStronglyRegularGraph(2, G=G, L=L) + sage: G3x3.is_strongly_regular(parameters=True) (441, 220, 109, 110) - sage: G3x3.automorphism_group(algorithm="bliss").order() # optional - bliss # needs sage.groups sage.libs.gap + sage: G3x3.automorphism_group(algorithm="bliss").order() # optional - bliss 27 sage: G9 = graphs.MathonPseudocyclicStronglyRegularGraph(2) sage: G9.is_strongly_regular(parameters=True)