Opened 4 months ago

Closed 4 months ago

#27948 closed enhancement (fixed)

py3: fix doctests with optional package plantri

Reported by: dcoudert Owned by:
Priority: major Milestone: sage-8.9
Component: graph theory Keywords: py3, graph
Cc: Merged in:
Authors: David Coudert Reviewers: Vincent Klein
Report Upstream: N/A Work issues:
Branch: 719e943 (Commits) Commit: 719e943a4c1594b2ac68f026046466fa89e16bdb
Dependencies: Stopgaps:

Description

Multiple doctests are failing with plantri and py3.

Change History (7)

comment:1 Changed 4 months ago by dcoudert

  • Branch set to public/graphs/27948_plantri
  • Commit set to 719e943a4c1594b2ac68f026046466fa89e16bdb

New commits:

719e943trac #27948: fix doctests failing due to str versus bytes

comment:2 Changed 4 months ago by dcoudert

  • Status changed from new to needs_review

with this first commit, we fix doctests like

File "src/sage/graphs/graph_generators.py", line 1425, in sage.graphs.graph_generators.GraphGenerators.?
Failed example:
    len(list(gen))  # optional plantri
Exception raised:
    Traceback (most recent call last):
      File "/Users/dcoudert/sage3/sage/local/lib/python3.7/site-packages/sage/doctest/forker.py", line 681, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/Users/dcoudert/sage3/sage/local/lib/python3.7/site-packages/sage/doctest/forker.py", line 1105, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.graphs.graph_generators.GraphGenerators.?[1]>", line 1, in <module>
        len(list(gen))  # optional plantri
      File "/Users/dcoudert/sage3/sage/local/lib/python3.7/site-packages/sage/graphs/graph_generators.py", line 1538, in planar_graphs
        Plantri().require()
      File "/Users/dcoudert/sage3/sage/local/lib/python3.7/site-packages/sage/features/__init__.py", line 156, in require
        presence = self.is_present()
      File "sage/misc/cachefunc.pyx", line 2312, in sage.misc.cachefunc.CachedMethodCallerNoArgs.__call__ (build/cythonized/sage/misc/cachefunc.c:12705)
        self.cache = f(self._instance)
      File "/Users/dcoudert/sage3/sage/local/lib/python3.7/site-packages/sage/features/__init__.py", line 129, in is_present
        res = self._is_present()
      File "/Users/dcoudert/sage3/sage/local/lib/python3.7/site-packages/sage/features/__init__.py", line 353, in _is_present
        return self.is_functional()
      File "/Users/dcoudert/sage3/sage/local/lib/python3.7/site-packages/sage/features/graph_generators.py", line 53, in is_functional
        if lines.find(expected) == -1:
    TypeError: argument should be integer or bytes-like object, not 'str'

comment:3 Changed 4 months ago by dcoudert

The 2 remaining failing doctests require more investigation...

sage -t --long src/sage/graphs/graph_generators.py
**********************************************************************
File "src/sage/graphs/graph_generators.py", line 1641, in sage.graphs.graph_generators.GraphGenerators.?
Failed example:
    for i in range(12, 23):                                             # optional plantri
        L = len(list(graphs.triangulations(i, minimum_connectivity=5))) # optional plantri
        print("{}   {:3d}".format(i,L))                                 # optional plantri
Exception raised:
    Traceback (most recent call last):
      File "/Users/dcoudert/sage3/sage/local/lib/python3.7/site-packages/sage/doctest/forker.py", line 681, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/Users/dcoudert/sage3/sage/local/lib/python3.7/site-packages/sage/doctest/forker.py", line 1105, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.graphs.graph_generators.GraphGenerators.?[7]>", line 2, in <module>
        L = len(list(graphs.triangulations(i, minimum_connectivity=Integer(5)))) # optional plantri
      File "/Users/dcoudert/sage3/sage/local/lib/python3.7/site-packages/sage/graphs/graph_generators.py", line 1746, in triangulations
        for G in graphs._read_planar_code(sp.stdout):
      File "/Users/dcoudert/sage3/sage/local/lib/python3.7/site-packages/sage/graphs/graph_generators.py", line 1150, in _read_planar_code
        G.set_embedding(embed_g)
      File "/Users/dcoudert/sage3/sage/local/lib/python3.7/site-packages/sage/graphs/generic_graph.py", line 2444, in set_embedding
        self._check_embedding_validity(embedding, boolean=False)
      File "/Users/dcoudert/sage3/sage/local/lib/python3.7/site-packages/sage/graphs/generic_graph.py", line 2551, in _check_embedding_validity
        raise ValueError("{} and {} are not neighbors but {} is in the list associated with {}".format(u, v, u, v))
    ValueError: 10 and 6 are not neighbors but 10 is in the list associated with 6
**********************************************************************
File "src/sage/graphs/graph_generators.py", line 1673, in sage.graphs.graph_generators.GraphGenerators.?
Failed example:
    [len(g) for g in graphs.triangulations(9, minimum_degree=4, minimum_connectivity=3, dual=True)]  # optional plantri
Exception raised:
    Traceback (most recent call last):
      File "/Users/dcoudert/sage3/sage/local/lib/python3.7/site-packages/sage/doctest/forker.py", line 681, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/Users/dcoudert/sage3/sage/local/lib/python3.7/site-packages/sage/doctest/forker.py", line 1105, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.graphs.graph_generators.GraphGenerators.?[11]>", line 1, in <module>
        [len(g) for g in graphs.triangulations(Integer(9), minimum_degree=Integer(4), minimum_connectivity=Integer(3), dual=True)]  # optional plantri
      File "<doctest sage.graphs.graph_generators.GraphGenerators.?[11]>", line 1, in <listcomp>
        [len(g) for g in graphs.triangulations(Integer(9), minimum_degree=Integer(4), minimum_connectivity=Integer(3), dual=True)]  # optional plantri
      File "/Users/dcoudert/sage3/sage/local/lib/python3.7/site-packages/sage/graphs/graph_generators.py", line 1746, in triangulations
        for G in graphs._read_planar_code(sp.stdout):
      File "/Users/dcoudert/sage3/sage/local/lib/python3.7/site-packages/sage/graphs/graph_generators.py", line 1150, in _read_planar_code
        G.set_embedding(embed_g)
      File "/Users/dcoudert/sage3/sage/local/lib/python3.7/site-packages/sage/graphs/generic_graph.py", line 2444, in set_embedding
        self._check_embedding_validity(embedding, boolean=False)
      File "/Users/dcoudert/sage3/sage/local/lib/python3.7/site-packages/sage/graphs/generic_graph.py", line 2551, in _check_embedding_validity
        raise ValueError("{} and {} are not neighbors but {} is in the list associated with {}".format(u, v, u, v))
    ValueError: 10 and 9 are not neighbors but 10 is in the list associated with 9

comment:4 Changed 4 months ago by embray

  • Milestone changed from sage-8.8 to sage-8.9

Moving tickets from the Sage 8.8 milestone that have been actively worked on in the last six months to the next release milestone (optimistically).

comment:5 Changed 4 months ago by vklein

  • Reviewers set to Vincent Klein
  • Status changed from needs_review to positive_review

Looks good to me. I have opened #28108 for the two remaining doctests failures.

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

comment:6 Changed 4 months ago by dcoudert

Thank you.

comment:7 Changed 4 months ago by vbraun

  • Branch changed from public/graphs/27948_plantri to 719e943a4c1594b2ac68f026046466fa89e16bdb
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.