Opened 13 months ago
Closed 13 months ago
#27151 closed enhancement (fixed)
py3: fix doctests in vertex_separation.pyx
Reported by:  dcoudert  Owned by:  

Priority:  major  Milestone:  sage8.7 
Component:  graph theory  Keywords:  py3, graph 
Cc:  Merged in:  
Authors:  David Coudert  Reviewers:  Vincent Klein 
Report Upstream:  N/A  Work issues:  
Branch:  206f496 (Commits)  Commit:  206f49653a806520e465c8102c7b5e848f592a92 
Dependencies:  Stopgaps: 
Description
Several failing doctests were caused by the impossibility to sort of list of Set
(already in Python2).
sage: from sage.graphs.graph_decompositions.vertex_separation import vertex_separation, linear_ordering_to_path_decomposition sage: g = graphs.PathGraph(5) sage: pw, L = vertex_separation(g, algorithm="BAB"); pw 1 sage: h = linear_ordering_to_path_decomposition(g, L) sage: sorted(h) [{0, 1}, {3, 4}, {2, 3}, {1, 2}]
Since path decomposition is a graph whose vertices are Set
, we get different results in py2 and py3.
=> we mark doctests as # py2
and # py3
.
Some doctests were due to a max(None, <number>)
. With a proper initialization of the cut_off
variable, we don't have this issue anymore.
Another doctest is fixed in #27027.
Change History (6)
comment:1 Changed 13 months ago by
 Branch set to u/dcoudert/27151_vertex_separation
 Commit set to 7fa6d9ff4356440ef28b844d84fe2e49b61e132a
 Status changed from new to needs_review
comment:2 Changed 13 months ago by
 Reviewers set to Vincent Klein
Hi !
I don't think all the # py2
# py3
are necessary.
For example for your two first modifications doing that :
sage: sorted(h.vertices(), key=str) [{0, 1}, {1, 2}, {2, 3}, {3, 4}] sage: sage: sorted(h.edges(labels=None), key=str) [({0, 1}, {1, 2}), ({1, 2}, {2, 3}), ({2, 3}, {3, 4})]
give the same results in both py2 and py3.
comment:3 Changed 13 months ago by
 Commit changed from 7fa6d9ff4356440ef28b844d84fe2e49b61e132a to 206f49653a806520e465c8102c7b5e848f592a92
Branch pushed to git repo; I updated commit sha1. New commits:
206f496  trac #27151: implement reviewer's comments

comment:4 followup: ↓ 5 Changed 13 months ago by
Very good idea. Thanks. I have changed 3 doctests. One pair of py2/py3 tags remains as I don't know how to avoid it.
comment:5 in reply to: ↑ 4 Changed 13 months ago by
 Status changed from needs_review to positive_review
Ok this looks fine.
comment:6 Changed 13 months ago by
 Branch changed from u/dcoudert/27151_vertex_separation to 206f49653a806520e465c8102c7b5e848f592a92
 Resolution set to fixed
 Status changed from positive_review to closed
The 10 failing doctests in py3 should be fixed with this ticket and #27027.
New commits:
trac #27151: fix doctests in vertex_separation