-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
check_sage_testsuite.py
48 lines (38 loc) · 1.53 KB
/
check_sage_testsuite.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from __future__ import print_function
"""
Check portions of the sage test suite, with default mip solver set to ours.
sage: M = MixedIntegerLinearProgram()
sage: M.get_backend()
<...sage_numerical_backends_cplex...>
"""
import sage_numerical_backends_cplex.cplex_backend as cplex_backend, sage.numerical.backends as backends, sys
sys.modules['sage.numerical.backends.cplex_backend'] = backends.cplex_backend = cplex_backend
from sage.numerical.backends.generic_backend import default_mip_solver
default_mip_solver('CPLEX')
from sage.doctest.control import DocTestController, DocTestDefaults
options = DocTestDefaults(nthreads=0, long=False, optional="sage,cplex", force_lib=True, abspath=True)
import os, sage.env, glob, sys
abs_file = os.path.abspath("check_sage_testsuite.py")
os.chdir(os.path.join(sage.env.SAGE_LIB, 'sage'))
files = ["coding",
"combinat/designs", "combinat/integer_vector.py", "combinat/posets/",
"game_theory/",
"geometry/polyhedron/base.py", "geometry/cone.py",
"graphs/",
"homology/simplicial_complex.py",
"knots/",
"matroids/",
"sat/"]
files += glob.glob("numerical/*.py") + glob.glob("numerical/*.pyx")
# First verify that we installed the default backend
DC = DocTestController(options, [abs_file])
err = DC.run()
if err != 0:
print("Error: Setting the default solver did not work", file=sys.stderr)
sys.exit(2)
# from $SAGE_SRC/bin/sage-runtests
DC = DocTestController(options, files)
err = DC.run()
if err != 0:
sys.exit(1)
sys.exit(0)