Opened 4 years ago

Closed 4 years ago

#27151 closed enhancement (fixed)

py3: fix doctests in vertex_separation.pyx

Reported by: David Coudert Owned by:
Priority: major Milestone: sage-8.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, GitHub, GitLab) Commit: 206f49653a806520e465c8102c7b5e848f592a92
Dependencies: Stopgaps:

Status badges


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
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 4 years ago by David Coudert

Branch: u/dcoudert/27151_vertex_separation
Commit: 7fa6d9ff4356440ef28b844d84fe2e49b61e132a
Status: newneeds_review

The 10 failing doctests in py3 should be fixed with this ticket and #27027.

New commits:

7fa6d9ftrac #27151: fix doctests in vertex_separation

comment:2 Changed 4 years ago by vklein

Reviewers: 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.

Last edited 4 years ago by vklein (previous) (diff)

comment:3 Changed 4 years ago by git

Commit: 7fa6d9ff4356440ef28b844d84fe2e49b61e132a206f49653a806520e465c8102c7b5e848f592a92

Branch pushed to git repo; I updated commit sha1. New commits:

206f496trac #27151: implement reviewer's comments

comment:4 Changed 4 years ago by David Coudert

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 4 years ago by vklein

Status: needs_reviewpositive_review

Ok this looks fine.

comment:6 Changed 4 years ago by Volker Braun

Branch: u/dcoudert/27151_vertex_separation206f49653a806520e465c8102c7b5e848f592a92
Resolution: fixed
Status: positive_reviewclosed
Note: See TracTickets for help on using tickets.