Opened 3 years ago
Closed 3 years ago
#28371 closed defect (fixed)
py3: errors with optional package CSDP
Reported by: | dcoudert | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | sage-8.9 |
Component: | graph theory | Keywords: | |
Cc: | dimpase, vklein | Merged in: | |
Authors: | David Coudert | Reviewers: | Vincent Klein |
Report Upstream: | N/A | Work issues: | |
Branch: | 27a9342 (Commits, GitHub, GitLab) | Commit: | 27a934225f761f72a90a18e3a91628133cf839b6 |
Dependencies: | Stopgaps: |
Description
Using --optional=benzene,bliss,build,csdp,dochtml,dot2tex,gfortran,igraph,mpir,plantri,python2,python_igraph,sage,tdlib Doctesting 1 file. sage -t --long src/sage/graphs/lovasz_theta.py ********************************************************************** File "src/sage/graphs/lovasz_theta.py", line 50, in sage.graphs.lovasz_theta.lovasz_theta Failed example: C.lovasz_theta() # optional csdp 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.lovasz_theta.lovasz_theta[1]>", line 1, in <module> C.lovasz_theta() # optional csdp File "/Users/dcoudert/sage3/sage/local/lib/python3.7/site-packages/sage/graphs/lovasz_theta.py", line 70, in lovasz_theta CSDP().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 2311, in sage.misc.cachefunc.CachedMethodCallerNoArgs.__call__ (build/cythonized/sage/misc/cachefunc.c:12712) 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/csdp.py", line 47, in is_functional tf.write("2\n1\n1 1") TypeError: a bytes-like object is required, not 'str' ********************************************************************** File "src/sage/graphs/lovasz_theta.py", line 52, in sage.graphs.lovasz_theta.lovasz_theta Failed example: graphs.CycleGraph(5).lovasz_theta() # optional csdp 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.lovasz_theta.lovasz_theta[2]>", line 1, in <module> graphs.CycleGraph(Integer(5)).lovasz_theta() # optional csdp File "/Users/dcoudert/sage3/sage/local/lib/python3.7/site-packages/sage/graphs/lovasz_theta.py", line 70, in lovasz_theta CSDP().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 2311, in sage.misc.cachefunc.CachedMethodCallerNoArgs.__call__ (build/cythonized/sage/misc/cachefunc.c:12712) 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/csdp.py", line 47, in is_functional tf.write("2\n1\n1 1") TypeError: a bytes-like object is required, not 'str' ********************************************************************** 1 item had failures: 2 of 6 in sage.graphs.lovasz_theta.lovasz_theta [5 tests, 2 failures, 0.49 s] ---------------------------------------------------------------------- sage -t --long src/sage/graphs/lovasz_theta.py # 2 doctests failed ----------------------------------------------------------------------
sage -t --long src/sage/features/csdp.py ********************************************************************** File "src/sage/features/csdp.py", line 21, in sage.features.csdp.CSDP Failed example: CSDP().is_present() # optional: csdp 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.features.csdp.CSDP[1]>", line 1, in <module> CSDP().is_present() # optional: csdp File "sage/misc/cachefunc.pyx", line 2311, in sage.misc.cachefunc.CachedMethodCallerNoArgs.__call__ (build/cythonized/sage/misc/cachefunc.c:12712) 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/csdp.py", line 47, in is_functional tf.write("2\n1\n1 1") TypeError: a bytes-like object is required, not 'str' ********************************************************************** File "src/sage/features/csdp.py", line 41, in sage.features.csdp.CSDP.is_functional Failed example: CSDP().is_functional() # optional: csdp 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.features.csdp.CSDP.is_functional[1]>", line 1, in <module> CSDP().is_functional() # optional: csdp File "/Users/dcoudert/sage3/sage/local/lib/python3.7/site-packages/sage/features/csdp.py", line 47, in is_functional tf.write("2\n1\n1 1") TypeError: a bytes-like object is required, not 'str' ********************************************************************** 2 items had failures: 1 of 3 in sage.features.csdp.CSDP 1 of 3 in sage.features.csdp.CSDP.is_functional [6 tests, 2 failures, 0.02 s] ---------------------------------------------------------------------- sage -t --long src/sage/features/csdp.py # 2 doctests failed
Change History (11)
comment:1 Changed 3 years ago by
comment:2 Changed 3 years ago by
- Branch set to public/graphs/28371_csdp
- Cc vklein added
- Commit set to 8faca3c729ba49d4236dd8b80c85738b01dfd4e6
- Status changed from new to needs_review
comment:3 Changed 3 years ago by
The current fix is not compatible with python2.
f-strings only appears with python3.6.
sage -t --long src/sage/graphs/lovasz_theta.py Traceback (most recent call last): File "/home/vklein/odk/sage/src/bin/sage-runtests", line 177, in <module> from sage.doctest.control import DocTestController File "/home/vklein/odk/sage/local/lib/python2.7/site-packages/sage/doctest/control.py", line 33, in <module> from .sources import FileDocTestSource, DictAsObject File "/home/vklein/odk/sage/local/lib/python2.7/site-packages/sage/doctest/sources.py", line 33, in <module> from .parsing import SageDocTestParser File "/home/vklein/odk/sage/local/lib/python2.7/site-packages/sage/doctest/parsing.py", line 66, in <module> from sage.all import RealIntervalField File "/home/vklein/odk/sage/local/lib/python2.7/site-packages/sage/all.py", line 103, in <module> from sage.modular.all import * File "/home/vklein/odk/sage/local/lib/python2.7/site-packages/sage/modular/all.py", line 54, in <module> from .btquotients.all import * File "/home/vklein/odk/sage/local/lib/python2.7/site-packages/sage/modular/btquotients/all.py", line 2, in <module> from .btquotient import BruhatTitsQuotient File "/home/vklein/odk/sage/local/lib/python2.7/site-packages/sage/modular/btquotients/btquotient.py", line 51, in <module> from sage.graphs.all import Graph File "/home/vklein/odk/sage/local/lib/python2.7/site-packages/sage/graphs/all.py", line 8, in <module> from .graph_database import GraphDatabase, GenericGraphQuery, GraphQuery File "/home/vklein/odk/sage/local/lib/python2.7/site-packages/sage/graphs/graph_database.py", line 48, in <module> from . import graph File "/home/vklein/odk/sage/local/lib/python2.7/site-packages/sage/graphs/graph.py", line 425, in <module> class Graph(GenericGraph): File "/home/vklein/odk/sage/local/lib/python2.7/site-packages/sage/graphs/graph.py", line 8650, in Graph from sage.graphs.lovasz_theta import lovasz_theta File "/home/vklein/odk/sage/local/lib/python2.7/site-packages/sage/graphs/lovasz_theta.py", line 75 tf.write(f"{n}\n{g.number_of_edges()}\n".encode()) ^ SyntaxError: invalid syntax
comment:4 Changed 3 years ago by
- Commit changed from 8faca3c729ba49d4236dd8b80c85738b01dfd4e6 to 04ff9b4a6025165390e2b5f82a36546bffea4a40
Branch pushed to git repo; I updated commit sha1. New commits:
04ff9b4 | trac #28371: compatibility with Python 2
|
comment:5 Changed 3 years ago by
Sorry, fixed.
comment:6 Changed 3 years ago by
I have another slight (non blocking) concern with result = lines.decode().strip().split('\n')[-1]
and python2.
With this code in python2 result
is in unicode and the other string used .split('\n')
and re.match("^The Lovasz Theta Number is (.*)$", result)
are in bytes.
It works as it is but i think it would be cleaner to use bytes_to_str
from sage.cpython.string
instead of decode
.
That way result
will be of type str
in both py2 and py3.
comment:7 Changed 3 years ago by
- Commit changed from 04ff9b4a6025165390e2b5f82a36546bffea4a40 to 27a934225f761f72a90a18e3a91628133cf839b6
Branch pushed to git repo; I updated commit sha1. New commits:
27a9342 | trac #28371: use bytes_to_str instead of .decode() in features/csdp.py
|
comment:8 Changed 3 years ago by
It is ok like that?
comment:9 Changed 3 years ago by
- Reviewers set to Vincent Klein
- Status changed from needs_review to positive_review
Yes ! Thanks !
comment:10 Changed 3 years ago by
Thank you. These were the last known Py3 failing doctests in the graph module ;)
comment:11 Changed 3 years ago by
- Branch changed from public/graphs/28371_csdp to 27a934225f761f72a90a18e3a91628133cf839b6
- Resolution set to fixed
- Status changed from positive_review to closed
So far I'm unable to fix the issues.