Skip to content

Commit 11751dc

Browse files
author
Release Manager
committed
gh-36040: Fix failing doctest in sage/graphs/bliss.pyx Since 10.1.beta9, a doctest is failing in `sage/graphs/bliss.pyx` due to some changes in `sage/groups/perm_gps/permgroup.py`. One of them is that method `.gens()` now returns a tuple and no longer a list. ```py sage: # optional - bliss sage: from sage.graphs.bliss import automorphism_group sage: alpha = "abcdefghijklmnopqrstuvwxyz" sage: G = Graph() sage: G.add_edges((alpha[i],alpha[j],"A") for i in range(0, 2) for j in range(14,20)) sage: G.add_edges((alpha[i],alpha[j],"B") for i in range(2, 5) for j in range(14,20)) sage: G.add_edges((alpha[i],alpha[j],"C") for i in range(5, 9) for j in range(14,20)) sage: G.add_edges((alpha[i],alpha[j],"D") for i in range(9,14) for j in range(14,20)) sage: A = automorphism_group(G) sage: print(A.gens()) ``` ```py Failed example: print(A.gens()) Expected: [('r','t'), ('s','r'), ('p','s'), ('q','p'), ('o','q'), ('l','n'), ('m','l'), ('j','m'), ('k','j'), ('i','h'), ('f','i'), ('g','f'), ('e','d'), ('c','e'), ('a','b')] Got: (('m','n'), ('l','m'), ('k','l'), ('j','k'), ('h','i'), ('g','h'), ('f','g'), ('d','e'), ('c','d'), ('s','t'), ('r','s'), ('q','r'), ('p','q'), ('o','p'), ('a','b')) ``` ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> <!-- Feel free to remove irrelevant items. --> - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [ ] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - #12345: short description why this is a dependency - #34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: #36040 Reported by: David Coudert Reviewer(s): Frédéric Chapoton
2 parents a023470 + ae7a1ce commit 11751dc

File tree

1 file changed

+35
-34
lines changed

1 file changed

+35
-34
lines changed

src/sage/graphs/bliss.pyx

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ cdef extern from "bliss_cpp/bliss_find_automorphisms.h":
6767

6868
cdef int encoding_numbits(int n):
6969
r"""
70-
Return the number of bits needed to encode the ``n`` numbers from ``1`` to ``n``. In
71-
other words, the last bit set in ``n``.
70+
Return the number of bits needed to encode the `n` numbers from `1` to
71+
`n`. In other words, the last bit set in `n`.
7272
"""
7373
if n <= 0:
7474
return 0
@@ -480,9 +480,9 @@ cpdef canonical_form(G, partition=None, return_graph=False, use_edge_labels=True
480480
sage: # needs sage.modules
481481
sage: g1 = Graph([(0, 1, matrix(ZZ, 2)), (0, 2, RDF.pi()), (1, 2, 'a')])
482482
sage: g2 = Graph([(1, 2, matrix(ZZ, 2)), (2, 0, RDF.pi()), (0, 1, 'a')])
483-
sage: g1can = canonical_form(g1, use_edge_labels=True) # optional - bliss
484-
sage: g2can = canonical_form(g2, use_edge_labels=True) # optional - bliss
485-
sage: g1can == g2can # optional - bliss
483+
sage: g1can = canonical_form(g1, use_edge_labels=True) # optional - bliss
484+
sage: g2can = canonical_form(g2, use_edge_labels=True) # optional - bliss
485+
sage: g1can == g2can # optional - bliss
486486
True
487487
488488
Check that :trac:`32395` is fixed::
@@ -666,12 +666,12 @@ cpdef automorphism_group(G, partition=None, use_edge_labels=True):
666666
667667
- ``G`` -- a Sage graph
668668
669-
- ``partition`` -- ``list``(default: ``None``); a partition of the vertices
669+
- ``partition`` -- ``list`` (default: ``None``); a partition of the vertices
670670
of ``G`` into color classes. Defaults to ``None``, which is equivalent to
671671
a partition of size 1.
672672
673-
- ``use_edge_labels`` -- boolean (default: ``True``); whether to consider edge
674-
labels
673+
- ``use_edge_labels`` -- boolean (default: ``True``); whether to consider
674+
edge labels
675675
676676
EXAMPLES::
677677
@@ -687,9 +687,9 @@ cpdef automorphism_group(G, partition=None, use_edge_labels=True):
687687
sage: automorphism_group(D).cardinality()
688688
2
689689
690-
Observe that the order 12 is given by permuting the first three vertices, or the last two
691-
in the case of a graph, while only the latter two are possible in the case of a directed
692-
graph.
690+
Observe that the order 12 is given by permuting the first three vertices, or
691+
the last two in the case of a graph, while only the latter two are possible
692+
in the case of a directed graph.
693693
694694
Partitioning the vertices into classes::
695695
@@ -701,24 +701,23 @@ cpdef automorphism_group(G, partition=None, use_edge_labels=True):
701701
2
702702
sage: automorphism_group(G,partition=[[0],[1,2],[3,4]]).cardinality()
703703
4
704-
705-
sage: automorphism_group(G,partition=[[1,2],[0,3],[4]]).cardinality() # optional - bliss
704+
sage: automorphism_group(G,partition=[[1,2],[0,3],[4]]).cardinality()
706705
2
707706
708707
Partitioning the edges into classes::
709708
710-
sage: G = Graph(graphs.CompleteMultipartiteGraph([8, 2]), sparse=True) # optional - bliss
711-
sage: for i,j in G.edges(labels=False, sort=False): # optional - bliss
709+
sage: # optional - bliss
710+
sage: G = Graph(graphs.CompleteMultipartiteGraph([8, 2]), sparse=True)
711+
sage: for i,j in G.edges(labels=False, sort=False):
712712
....: if 0 <= i < 3:
713713
....: G.set_edge_label(i, j, "A")
714714
....: if 3 <= i < 6:
715715
....: G.set_edge_label(i, j, "B")
716716
....: if 6 <= i < 8:
717717
....: G.set_edge_label(i, j, "C")
718-
719-
sage: factor(automorphism_group(G).cardinality()) # optional - bliss
718+
sage: factor(automorphism_group(G).cardinality())
720719
2^4 * 3^2
721-
sage: automorphism_group(G,[[0],[1],[2,3],[4,5],[6,7],[8],[9]]).cardinality() # optional - bliss
720+
sage: automorphism_group(G,[[0],[1],[2,3],[4,5],[6,7],[8],[9]]).cardinality()
722721
4
723722
724723
TESTS::
@@ -735,9 +734,9 @@ cpdef automorphism_group(G, partition=None, use_edge_labels=True):
735734
sage: automorphism_group(G, partition=p).is_isomorphic(A)
736735
True
737736
738-
sage: G = graphs.CompleteMultipartiteGraph([5,7,11])
737+
sage: G = graphs.CompleteMultipartiteGraph([5, 7, 11])
739738
sage: B = automorphism_group(G) # optional - bliss
740-
sage: B.cardinality() == prod(factorial(n) for n in [5,7,11]) # optional - bliss
739+
sage: B.cardinality() == prod(factorial(n) for n in [5, 7, 11]) # optional - bliss
741740
True
742741
743742
sage: # optional - bliss
@@ -749,11 +748,14 @@ cpdef automorphism_group(G, partition=None, use_edge_labels=True):
749748
....: G.set_edge_label(i, j, "B")
750749
....: if 6 <= i < 8:
751750
....: G.set_edge_label(i, j, "C")
752-
sage: automorphism_group(G).cardinality() == prod( factorial(n) for n in [3,3,2,8,8,5,2] )
751+
sage: card = automorphism_group(G).cardinality()
752+
sage: card == prod(factorial(n) for n in [3, 3, 2, 8, 8, 5, 2])
753753
True
754-
sage: automorphism_group(G, use_edge_labels=False).cardinality() == prod( factorial(n) for n in [8,8,8,5,3] )
754+
sage: card = automorphism_group(G, use_edge_labels=False).cardinality()
755+
sage: card == prod(factorial(n) for n in [8, 8, 8, 5, 3])
755756
True
756-
sage: automorphism_group(G,[[0 .. 7],[8 .. 11],[12 .. 28]]).cardinality() == prod( factorial(n) for n in [3,3,2,4,4,8,5] )
757+
sage: card = automorphism_group(G, [[0 .. 7], [8 .. 11] ,[12 .. 28]]).cardinality()
758+
sage: card == prod(factorial(n) for n in [3, 3, 2, 4, 4, 8, 5])
757759
True
758760
759761
sage: # optional - bliss
@@ -764,35 +766,34 @@ cpdef automorphism_group(G, partition=None, use_edge_labels=True):
764766
sage: G.add_edges((i,j,"D") for i in range(9,14) for j in range(14,20))
765767
sage: A = automorphism_group(G)
766768
sage: print(A.gens()) # random
767-
[(9,13), (18,19), (17,18), (16,17), (15,16), (14,15), (12,9), (11,12),
768-
(10,11), (7,8), (6,7), (5,6), (3,4), (2,3), (0,1)]
769+
((12,13), (11,12), (10,11), (9,10), (7,8), (6,7), (5,6), (3,4),
770+
(2,3), (1,0), (18,19), (17,18), (16,17), (15,16), (14,15))
769771
sage: A.cardinality() == prod(factorial(n) for n in [2,3,4,5,6])
770772
True
771773
772-
sage: alpha = "abcdefghijklmnopqrstuvwxyz"
773-
774774
sage: # optional - bliss
775775
sage: G = Graph()
776+
sage: alpha = "abcdefghijklmnopqrstuvwxyz"
776777
sage: G.add_edges((alpha[i],alpha[j],"A") for i in range(0, 2) for j in range(14,20))
777778
sage: G.add_edges((alpha[i],alpha[j],"B") for i in range(2, 5) for j in range(14,20))
778779
sage: G.add_edges((alpha[i],alpha[j],"C") for i in range(5, 9) for j in range(14,20))
779780
sage: G.add_edges((alpha[i],alpha[j],"D") for i in range(9,14) for j in range(14,20))
780781
sage: A = automorphism_group(G)
781782
sage: print(A.gens())
782-
[('r','t'), ('s','r'), ('p','s'), ('q','p'), ('o','q'), ('l','n'),
783-
('m','l'), ('j','m'), ('k','j'), ('i','h'), ('f','i'), ('g','f'),
784-
('e','d'), ('c','e'), ('a','b')]
785-
sage: A.cardinality() == prod(factorial(n) for n in [2,3,4,5,6])
783+
(('m','n'), ('l','m'), ('k','l'), ('j','k'), ('h','i'),
784+
('g','h'), ('f','g'), ('d','e'), ('c','d'), ('s','t'),
785+
('r','s'), ('q','r'), ('p','q'), ('o','p'), ('a','b'))
786+
sage: A.cardinality() == prod(factorial(n) for n in [2, 3, 4, 5, 6])
786787
True
787788
788789
sage: # optional - bliss
789790
sage: gg = graphs.CompleteGraph(5)
790791
sage: gg.allow_loops(True)
791-
sage: gg.add_edge(0,0)
792-
sage: gg.add_edge(1,1)
792+
sage: gg.add_edge(0, 0)
793+
sage: gg.add_edge(1, 1)
793794
sage: automorphism_group(gg).cardinality()
794795
12
795-
sage: automorphism_group(gg,[[0],[1,2,3,4]]).cardinality()
796+
sage: automorphism_group(gg, [[0], [1, 2, 3, 4]]).cardinality()
796797
6
797798
"""
798799
# We need this to convert the numbers from <unsigned int> to

0 commit comments

Comments
 (0)