passagemath-repl 10.5.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- passagemath_repl-10.5.1.data/scripts/sage-cachegrind +25 -0
- passagemath_repl-10.5.1.data/scripts/sage-callgrind +16 -0
- passagemath_repl-10.5.1.data/scripts/sage-cleaner +230 -0
- passagemath_repl-10.5.1.data/scripts/sage-coverage +327 -0
- passagemath_repl-10.5.1.data/scripts/sage-eval +14 -0
- passagemath_repl-10.5.1.data/scripts/sage-fixdoctests +710 -0
- passagemath_repl-10.5.1.data/scripts/sage-inline-fortran +12 -0
- passagemath_repl-10.5.1.data/scripts/sage-ipynb2rst +50 -0
- passagemath_repl-10.5.1.data/scripts/sage-ipython +16 -0
- passagemath_repl-10.5.1.data/scripts/sage-massif +25 -0
- passagemath_repl-10.5.1.data/scripts/sage-notebook +267 -0
- passagemath_repl-10.5.1.data/scripts/sage-omega +25 -0
- passagemath_repl-10.5.1.data/scripts/sage-preparse +302 -0
- passagemath_repl-10.5.1.data/scripts/sage-run +27 -0
- passagemath_repl-10.5.1.data/scripts/sage-run-cython +10 -0
- passagemath_repl-10.5.1.data/scripts/sage-runtests +9 -0
- passagemath_repl-10.5.1.data/scripts/sage-startuptime.py +163 -0
- passagemath_repl-10.5.1.data/scripts/sage-valgrind +34 -0
- passagemath_repl-10.5.1.dist-info/METADATA +77 -0
- passagemath_repl-10.5.1.dist-info/RECORD +162 -0
- passagemath_repl-10.5.1.dist-info/WHEEL +5 -0
- passagemath_repl-10.5.1.dist-info/top_level.txt +1 -0
- sage/all__sagemath_repl.py +119 -0
- sage/doctest/__init__.py +4 -0
- sage/doctest/__main__.py +236 -0
- sage/doctest/all.py +4 -0
- sage/doctest/check_tolerance.py +261 -0
- sage/doctest/control.py +1727 -0
- sage/doctest/external.py +534 -0
- sage/doctest/fixtures.py +383 -0
- sage/doctest/forker.py +2665 -0
- sage/doctest/marked_output.py +102 -0
- sage/doctest/parsing.py +1708 -0
- sage/doctest/parsing_test.py +79 -0
- sage/doctest/reporting.py +733 -0
- sage/doctest/rif_tol.py +124 -0
- sage/doctest/sources.py +1657 -0
- sage/doctest/test.py +584 -0
- sage/doctest/tests/1second.rst +4 -0
- sage/doctest/tests/99seconds.rst +4 -0
- sage/doctest/tests/abort.rst +5 -0
- sage/doctest/tests/atexit.rst +7 -0
- sage/doctest/tests/fail_and_die.rst +6 -0
- sage/doctest/tests/initial.rst +15 -0
- sage/doctest/tests/interrupt.rst +7 -0
- sage/doctest/tests/interrupt_diehard.rst +14 -0
- sage/doctest/tests/keyboardinterrupt.rst +11 -0
- sage/doctest/tests/longtime.rst +5 -0
- sage/doctest/tests/nodoctest +5 -0
- sage/doctest/tests/random_seed.rst +4 -0
- sage/doctest/tests/show_skipped.rst +18 -0
- sage/doctest/tests/sig_on.rst +9 -0
- sage/doctest/tests/simple_failure.rst +8 -0
- sage/doctest/tests/sleep_and_raise.rst +106 -0
- sage/doctest/tests/tolerance.rst +31 -0
- sage/doctest/util.py +750 -0
- sage/interfaces/cleaner.py +48 -0
- sage/interfaces/quit.py +163 -0
- sage/misc/all__sagemath_repl.py +51 -0
- sage/misc/banner.py +235 -0
- sage/misc/benchmark.py +221 -0
- sage/misc/classgraph.py +134 -0
- sage/misc/copying.py +22 -0
- sage/misc/cython.py +694 -0
- sage/misc/dev_tools.py +745 -0
- sage/misc/edit_module.py +304 -0
- sage/misc/explain_pickle.py +3079 -0
- sage/misc/gperftools.py +361 -0
- sage/misc/inline_fortran.py +212 -0
- sage/misc/messaging.py +86 -0
- sage/misc/pager.py +21 -0
- sage/misc/profiler.py +179 -0
- sage/misc/python.py +70 -0
- sage/misc/remote_file.py +53 -0
- sage/misc/sage_eval.py +249 -0
- sage/misc/sage_input.py +3621 -0
- sage/misc/sagedoc.py +1742 -0
- sage/misc/sh.py +38 -0
- sage/misc/trace.py +90 -0
- sage/repl/__init__.py +16 -0
- sage/repl/all.py +15 -0
- sage/repl/attach.py +625 -0
- sage/repl/configuration.py +186 -0
- sage/repl/display/__init__.py +1 -0
- sage/repl/display/fancy_repr.py +354 -0
- sage/repl/display/formatter.py +318 -0
- sage/repl/display/jsmol_iframe.py +290 -0
- sage/repl/display/pretty_print.py +153 -0
- sage/repl/display/util.py +163 -0
- sage/repl/image.py +302 -0
- sage/repl/inputhook.py +91 -0
- sage/repl/interface_magic.py +298 -0
- sage/repl/interpreter.py +854 -0
- sage/repl/ipython_extension.py +593 -0
- sage/repl/ipython_kernel/__init__.py +1 -0
- sage/repl/ipython_kernel/__main__.py +4 -0
- sage/repl/ipython_kernel/all_jupyter.py +10 -0
- sage/repl/ipython_kernel/install.py +301 -0
- sage/repl/ipython_kernel/interact.py +278 -0
- sage/repl/ipython_kernel/kernel.py +217 -0
- sage/repl/ipython_kernel/widgets.py +466 -0
- sage/repl/ipython_kernel/widgets_sagenb.py +587 -0
- sage/repl/ipython_tests.py +163 -0
- sage/repl/load.py +326 -0
- sage/repl/preparse.py +2218 -0
- sage/repl/prompts.py +90 -0
- sage/repl/rich_output/__init__.py +4 -0
- sage/repl/rich_output/backend_base.py +648 -0
- sage/repl/rich_output/backend_doctest.py +316 -0
- sage/repl/rich_output/backend_emacs.py +151 -0
- sage/repl/rich_output/backend_ipython.py +596 -0
- sage/repl/rich_output/buffer.py +311 -0
- sage/repl/rich_output/display_manager.py +829 -0
- sage/repl/rich_output/example.avi +0 -0
- sage/repl/rich_output/example.canvas3d +1 -0
- sage/repl/rich_output/example.dvi +0 -0
- sage/repl/rich_output/example.flv +0 -0
- sage/repl/rich_output/example.gif +0 -0
- sage/repl/rich_output/example.jpg +0 -0
- sage/repl/rich_output/example.mkv +0 -0
- sage/repl/rich_output/example.mov +0 -0
- sage/repl/rich_output/example.mp4 +0 -0
- sage/repl/rich_output/example.ogv +0 -0
- sage/repl/rich_output/example.pdf +0 -0
- sage/repl/rich_output/example.png +0 -0
- sage/repl/rich_output/example.svg +54 -0
- sage/repl/rich_output/example.webm +0 -0
- sage/repl/rich_output/example.wmv +0 -0
- sage/repl/rich_output/example_jmol.spt.zip +0 -0
- sage/repl/rich_output/example_wavefront_scene.mtl +7 -0
- sage/repl/rich_output/example_wavefront_scene.obj +17 -0
- sage/repl/rich_output/output_basic.py +391 -0
- sage/repl/rich_output/output_browser.py +103 -0
- sage/repl/rich_output/output_catalog.py +54 -0
- sage/repl/rich_output/output_graphics.py +320 -0
- sage/repl/rich_output/output_graphics3d.py +345 -0
- sage/repl/rich_output/output_video.py +231 -0
- sage/repl/rich_output/preferences.py +432 -0
- sage/repl/rich_output/pretty_print.py +339 -0
- sage/repl/rich_output/test_backend.py +201 -0
- sage/repl/user_globals.py +214 -0
- sage/tests/all.py +0 -0
- sage/tests/all__sagemath_repl.py +3 -0
- sage/tests/article_heuberger_krenn_kropf_fsm-in-sage.py +630 -0
- sage/tests/arxiv_0812_2725.py +351 -0
- sage/tests/benchmark.py +1925 -0
- sage/tests/book_schilling_zabrocki_kschur_primer.py +795 -0
- sage/tests/book_stein_ent.py +651 -0
- sage/tests/book_stein_modform.py +558 -0
- sage/tests/cmdline.py +796 -0
- sage/tests/combinatorial_hopf_algebras.py +52 -0
- sage/tests/finite_poset.py +623 -0
- sage/tests/functools_partial_src.py +27 -0
- sage/tests/gosper-sum.py +218 -0
- sage/tests/lazy_imports.py +28 -0
- sage/tests/modular_group_cohomology.py +80 -0
- sage/tests/numpy.py +21 -0
- sage/tests/parigp.py +76 -0
- sage/tests/startup.py +27 -0
- sage/tests/symbolic-series.py +76 -0
- sage/tests/sympy.py +16 -0
- sage/tests/test_deprecation.py +31 -0
sage/doctest/external.py
ADDED
@@ -0,0 +1,534 @@
|
|
1
|
+
# sage_setup: distribution = sagemath-repl
|
2
|
+
"""
|
3
|
+
Detecting external software
|
4
|
+
|
5
|
+
This module makes up a list of external software that Sage interfaces. Availability
|
6
|
+
of each software is tested only when necessary. This is mainly used for the doctests
|
7
|
+
which require certain external software installed on the system.
|
8
|
+
|
9
|
+
Even though the functions in this module should also work when an external
|
10
|
+
software is not present, most doctests in this module are only tested if
|
11
|
+
testing of external software is explicitly enabled in order to avoid invoking
|
12
|
+
external software otherwise. See :issue:`28819` for details.
|
13
|
+
|
14
|
+
AUTHORS:
|
15
|
+
|
16
|
+
- Kwankyu Lee (2016-03-09) -- initial version, based on code by Robert Bradshaw and Nathann Cohen
|
17
|
+
"""
|
18
|
+
|
19
|
+
#*****************************************************************************
|
20
|
+
# Copyright (C) 2016 Kwankyu Lee <ekwankyu@gmail.com>
|
21
|
+
# 2018 Thierry Monteil
|
22
|
+
# 2018-2021 Sébastien Labbé
|
23
|
+
# 2019 Markus Wageringel
|
24
|
+
# 2020 John H. Palmieri
|
25
|
+
# 2021 Matthias Koeppe
|
26
|
+
#
|
27
|
+
# This program is free software: you can redistribute it and/or modify
|
28
|
+
# it under the terms of the GNU General Public License as published by
|
29
|
+
# the Free Software Foundation, either version 2 of the License, or
|
30
|
+
# (at your option) any later version.
|
31
|
+
# http://www.gnu.org/licenses/
|
32
|
+
#*****************************************************************************
|
33
|
+
|
34
|
+
import multiprocessing
|
35
|
+
import platform
|
36
|
+
|
37
|
+
# With OS X, Python 3.8 defaults to use 'spawn' instead of 'fork' in
|
38
|
+
# multiprocessing, and Sage doctesting doesn't work with 'spawn'. See
|
39
|
+
# trac #27754.
|
40
|
+
if platform.system() == 'Darwin':
|
41
|
+
multiprocessing.set_start_method('fork', force=True)
|
42
|
+
Array = multiprocessing.Array
|
43
|
+
|
44
|
+
# Functions in this module whose name is of the form 'has_xxx' tests if the
|
45
|
+
# software xxx is available to Sage.
|
46
|
+
prefix = 'has_'
|
47
|
+
|
48
|
+
def has_internet():
|
49
|
+
"""
|
50
|
+
Test if Internet is available.
|
51
|
+
|
52
|
+
Failure of connecting to the site "https://www.sagemath.org" within a second
|
53
|
+
is regarded as internet being not available.
|
54
|
+
|
55
|
+
EXAMPLES::
|
56
|
+
|
57
|
+
sage: from sage.doctest.external import has_internet
|
58
|
+
sage: has_internet() # random, optional -- internet
|
59
|
+
FeatureTestResult('internet', True)
|
60
|
+
"""
|
61
|
+
from sage.features.internet import Internet
|
62
|
+
return Internet().is_present()
|
63
|
+
|
64
|
+
def has_latex():
|
65
|
+
"""
|
66
|
+
Test if Latex is available.
|
67
|
+
|
68
|
+
EXAMPLES::
|
69
|
+
|
70
|
+
sage: from sage.doctest.external import has_latex
|
71
|
+
sage: has_latex() # optional - latex
|
72
|
+
FeatureTestResult('latex', True)
|
73
|
+
"""
|
74
|
+
from sage.features.latex import latex
|
75
|
+
return latex().is_present()
|
76
|
+
|
77
|
+
def has_xelatex():
|
78
|
+
"""
|
79
|
+
Test if xelatex is available.
|
80
|
+
|
81
|
+
EXAMPLES::
|
82
|
+
|
83
|
+
sage: from sage.doctest.external import has_xelatex
|
84
|
+
sage: has_xelatex() # optional - xelatex
|
85
|
+
FeatureTestResult('xelatex', True)
|
86
|
+
"""
|
87
|
+
from sage.features.latex import xelatex
|
88
|
+
return xelatex().is_present()
|
89
|
+
|
90
|
+
def has_pdflatex():
|
91
|
+
"""
|
92
|
+
Test if pdflatex is available.
|
93
|
+
|
94
|
+
EXAMPLES::
|
95
|
+
|
96
|
+
sage: from sage.doctest.external import has_pdflatex
|
97
|
+
sage: has_pdflatex() # optional - pdflatex
|
98
|
+
FeatureTestResult('pdflatex', True)
|
99
|
+
"""
|
100
|
+
from sage.features.latex import pdflatex
|
101
|
+
return pdflatex().is_present()
|
102
|
+
|
103
|
+
def has_lualatex():
|
104
|
+
"""
|
105
|
+
Test if lualatex is available.
|
106
|
+
|
107
|
+
EXAMPLES::
|
108
|
+
|
109
|
+
sage: from sage.doctest.external import has_lualatex
|
110
|
+
sage: has_lualatex() # optional - lualatex
|
111
|
+
FeatureTestResult('lualatex', True)
|
112
|
+
"""
|
113
|
+
from sage.features.latex import lualatex
|
114
|
+
return lualatex().is_present()
|
115
|
+
|
116
|
+
def has_magma():
|
117
|
+
"""
|
118
|
+
Test if Magma is available.
|
119
|
+
|
120
|
+
EXAMPLES::
|
121
|
+
|
122
|
+
sage: from sage.doctest.external import has_magma
|
123
|
+
sage: has_magma() # random, optional - magma
|
124
|
+
True
|
125
|
+
"""
|
126
|
+
from sage.features.interfaces import Magma
|
127
|
+
return Magma().is_present()
|
128
|
+
|
129
|
+
def has_matlab():
|
130
|
+
"""
|
131
|
+
Test if Matlab is available.
|
132
|
+
|
133
|
+
EXAMPLES::
|
134
|
+
|
135
|
+
sage: from sage.doctest.external import has_matlab
|
136
|
+
sage: has_matlab() # random, optional - matlab
|
137
|
+
True
|
138
|
+
"""
|
139
|
+
from sage.features.interfaces import Matlab
|
140
|
+
return Matlab().is_present()
|
141
|
+
|
142
|
+
def has_mathematica():
|
143
|
+
"""
|
144
|
+
Test if Mathematica is available.
|
145
|
+
|
146
|
+
EXAMPLES::
|
147
|
+
|
148
|
+
sage: from sage.doctest.external import has_mathematica
|
149
|
+
sage: has_mathematica() # random, optional - mathematica
|
150
|
+
True
|
151
|
+
"""
|
152
|
+
from sage.features.interfaces import Mathematica
|
153
|
+
return Mathematica().is_present()
|
154
|
+
|
155
|
+
def has_maple():
|
156
|
+
"""
|
157
|
+
Test if Maple is available.
|
158
|
+
|
159
|
+
EXAMPLES::
|
160
|
+
|
161
|
+
sage: from sage.doctest.external import has_maple
|
162
|
+
sage: has_maple() # random, optional - maple
|
163
|
+
True
|
164
|
+
"""
|
165
|
+
from sage.features.interfaces import Maple
|
166
|
+
return Maple().is_present()
|
167
|
+
|
168
|
+
def has_macaulay2():
|
169
|
+
"""
|
170
|
+
Test if Macaulay2 is available.
|
171
|
+
|
172
|
+
EXAMPLES::
|
173
|
+
|
174
|
+
sage: from sage.doctest.external import has_macaulay2
|
175
|
+
sage: has_macaulay2() # random, optional - macaulay2
|
176
|
+
True
|
177
|
+
"""
|
178
|
+
from sage.features.interfaces import Macaulay2
|
179
|
+
return Macaulay2().is_present()
|
180
|
+
|
181
|
+
def has_octave():
|
182
|
+
"""
|
183
|
+
Test if Octave is available.
|
184
|
+
|
185
|
+
EXAMPLES::
|
186
|
+
|
187
|
+
sage: from sage.doctest.external import has_octave
|
188
|
+
sage: has_octave() # random, optional - octave
|
189
|
+
True
|
190
|
+
"""
|
191
|
+
from sage.features.interfaces import Octave
|
192
|
+
return Octave().is_present()
|
193
|
+
|
194
|
+
def has_pandoc():
|
195
|
+
"""
|
196
|
+
Test if pandoc is available.
|
197
|
+
|
198
|
+
EXAMPLES::
|
199
|
+
|
200
|
+
sage: from sage.doctest.external import has_pandoc
|
201
|
+
sage: has_pandoc() # optional -- pandoc
|
202
|
+
FeatureTestResult('pandoc', True)
|
203
|
+
"""
|
204
|
+
from sage.features.pandoc import Pandoc
|
205
|
+
return Pandoc().is_present()
|
206
|
+
|
207
|
+
def has_scilab():
|
208
|
+
"""
|
209
|
+
Test if Scilab is available.
|
210
|
+
|
211
|
+
EXAMPLES::
|
212
|
+
|
213
|
+
sage: from sage.doctest.external import has_scilab
|
214
|
+
sage: has_scilab() # random, optional - scilab
|
215
|
+
True
|
216
|
+
"""
|
217
|
+
from sage.interfaces.scilab import scilab
|
218
|
+
try:
|
219
|
+
scilab('2+3')
|
220
|
+
return True
|
221
|
+
except Exception:
|
222
|
+
return False
|
223
|
+
|
224
|
+
def has_cplex():
|
225
|
+
"""
|
226
|
+
Test if CPLEX is available.
|
227
|
+
|
228
|
+
EXAMPLES::
|
229
|
+
|
230
|
+
sage: from sage.doctest.external import has_cplex
|
231
|
+
sage: has_cplex() # random, optional - CPLEX
|
232
|
+
FeatureTestResult('cplex', True)
|
233
|
+
"""
|
234
|
+
from sage.features.mip_backends import CPLEX
|
235
|
+
return CPLEX().is_present()
|
236
|
+
|
237
|
+
def has_gurobi():
|
238
|
+
"""
|
239
|
+
Test if Gurobi is available.
|
240
|
+
|
241
|
+
EXAMPLES::
|
242
|
+
|
243
|
+
sage: from sage.doctest.external import has_gurobi
|
244
|
+
sage: has_gurobi() # random, optional - Gurobi
|
245
|
+
FeatureTestResult('gurobi', True)
|
246
|
+
"""
|
247
|
+
from sage.features.mip_backends import Gurobi
|
248
|
+
return Gurobi().is_present()
|
249
|
+
|
250
|
+
def has_graphviz():
|
251
|
+
"""
|
252
|
+
Test if graphviz (dot, twopi, neato) are available.
|
253
|
+
|
254
|
+
EXAMPLES::
|
255
|
+
|
256
|
+
sage: from sage.doctest.external import has_graphviz
|
257
|
+
sage: has_graphviz() # optional -- graphviz
|
258
|
+
FeatureTestResult('graphviz', True)
|
259
|
+
"""
|
260
|
+
from sage.features.graphviz import Graphviz
|
261
|
+
return Graphviz().is_present()
|
262
|
+
|
263
|
+
def has_ffmpeg():
|
264
|
+
"""
|
265
|
+
Test if ffmpeg is available.
|
266
|
+
|
267
|
+
EXAMPLES::
|
268
|
+
|
269
|
+
sage: from sage.doctest.external import has_ffmpeg
|
270
|
+
sage: has_ffmpeg() # optional -- ffmpeg
|
271
|
+
FeatureTestResult('ffmpeg', True)
|
272
|
+
"""
|
273
|
+
from sage.features.ffmpeg import FFmpeg
|
274
|
+
return FFmpeg().is_present()
|
275
|
+
|
276
|
+
def has_imagemagick():
|
277
|
+
"""
|
278
|
+
Test if ImageMagick (command magick or convert) is available.
|
279
|
+
|
280
|
+
EXAMPLES::
|
281
|
+
|
282
|
+
sage: from sage.doctest.external import has_imagemagick
|
283
|
+
sage: has_imagemagick() # optional -- imagemagick
|
284
|
+
FeatureTestResult('imagemagick', True)
|
285
|
+
"""
|
286
|
+
from sage.features.imagemagick import ImageMagick
|
287
|
+
return ImageMagick().is_present()
|
288
|
+
|
289
|
+
def has_dvipng():
|
290
|
+
"""
|
291
|
+
Test if dvipng is available.
|
292
|
+
|
293
|
+
EXAMPLES::
|
294
|
+
|
295
|
+
sage: from sage.doctest.external import has_dvipng
|
296
|
+
sage: has_dvipng() # optional -- dvipng
|
297
|
+
FeatureTestResult('dvipng', True)
|
298
|
+
"""
|
299
|
+
from sage.features.dvipng import dvipng
|
300
|
+
return dvipng().is_present()
|
301
|
+
|
302
|
+
def has_pdf2svg():
|
303
|
+
"""
|
304
|
+
Test if pdf2svg is available.
|
305
|
+
|
306
|
+
EXAMPLES::
|
307
|
+
|
308
|
+
sage: from sage.doctest.external import has_pdf2svg
|
309
|
+
sage: has_pdf2svg() # optional -- pdf2svg
|
310
|
+
FeatureTestResult('pdf2svg', True)
|
311
|
+
"""
|
312
|
+
from sage.features.pdf2svg import pdf2svg
|
313
|
+
return pdf2svg().is_present()
|
314
|
+
|
315
|
+
def has_rubiks():
|
316
|
+
"""
|
317
|
+
Test if the rubiks package (``cu2``, ``cubex``, ``dikcube``,
|
318
|
+
``mcube``, ``optimal``, and ``size222``) is available.
|
319
|
+
|
320
|
+
EXAMPLES::
|
321
|
+
|
322
|
+
sage: from sage.doctest.external import has_rubiks
|
323
|
+
sage: has_rubiks() # optional -- rubiks
|
324
|
+
FeatureTestResult('rubiks', True)
|
325
|
+
"""
|
326
|
+
from sage.features.rubiks import Rubiks
|
327
|
+
return Rubiks().is_present()
|
328
|
+
|
329
|
+
def has_4ti2():
|
330
|
+
"""
|
331
|
+
Test if the 4ti2 package is available.
|
332
|
+
|
333
|
+
EXAMPLES::
|
334
|
+
|
335
|
+
sage: from sage.doctest.external import has_4ti2
|
336
|
+
sage: has_4ti2() # optional -- 4ti2
|
337
|
+
FeatureTestResult('4ti2', True)
|
338
|
+
"""
|
339
|
+
from sage.features.four_ti_2 import FourTi2
|
340
|
+
return FourTi2().is_present()
|
341
|
+
|
342
|
+
def external_features():
|
343
|
+
r"""
|
344
|
+
Generate the features that are only to be tested if ``--optional=external`` is used.
|
345
|
+
|
346
|
+
EXAMPLES::
|
347
|
+
|
348
|
+
sage: from sage.doctest.external import external_features
|
349
|
+
sage: next(external_features())
|
350
|
+
Feature('internet')
|
351
|
+
"""
|
352
|
+
from sage.features.internet import Internet
|
353
|
+
yield Internet()
|
354
|
+
import sage.features.latex
|
355
|
+
yield from sage.features.latex.all_features()
|
356
|
+
import sage.features.ffmpeg
|
357
|
+
yield from sage.features.ffmpeg.all_features()
|
358
|
+
import sage.features.interfaces
|
359
|
+
for feature in sage.features.interfaces.all_features():
|
360
|
+
if feature.name != 'mathics':
|
361
|
+
yield feature
|
362
|
+
from sage.features.mip_backends import CPLEX, Gurobi
|
363
|
+
yield CPLEX()
|
364
|
+
yield Gurobi()
|
365
|
+
|
366
|
+
def external_software() -> list[str]:
|
367
|
+
"""
|
368
|
+
Return the alphabetical list of external software supported by this module.
|
369
|
+
|
370
|
+
EXAMPLES::
|
371
|
+
|
372
|
+
sage: from sage.doctest.external import external_software
|
373
|
+
sage: sorted(external_software) == external_software
|
374
|
+
True
|
375
|
+
"""
|
376
|
+
return sorted(f.name for f in external_features())
|
377
|
+
|
378
|
+
|
379
|
+
external_software = external_software()
|
380
|
+
|
381
|
+
|
382
|
+
class AvailableSoftware:
|
383
|
+
"""
|
384
|
+
This class keeps the set of available software whose availability is detected lazily
|
385
|
+
from the list of external software.
|
386
|
+
|
387
|
+
EXAMPLES::
|
388
|
+
|
389
|
+
sage: from sage.doctest.external import external_software, available_software
|
390
|
+
sage: external_software
|
391
|
+
['cplex',
|
392
|
+
'dvips',
|
393
|
+
'ffmpeg',
|
394
|
+
'gurobi',
|
395
|
+
'internet',
|
396
|
+
'latex',
|
397
|
+
'latex_package_tkz_graph',
|
398
|
+
'lualatex',
|
399
|
+
'macaulay2',
|
400
|
+
'magma',
|
401
|
+
'maple',
|
402
|
+
'mathematica',
|
403
|
+
'matlab',
|
404
|
+
'octave',
|
405
|
+
'pdflatex',
|
406
|
+
'scilab',
|
407
|
+
'xelatex']
|
408
|
+
sage: 'internet' in available_software # random, optional - internet
|
409
|
+
True
|
410
|
+
sage: available_software.issuperset(set(['internet','latex'])) # random, optional - internet latex
|
411
|
+
True
|
412
|
+
"""
|
413
|
+
def __init__(self):
|
414
|
+
"""
|
415
|
+
Initialization.
|
416
|
+
|
417
|
+
EXAMPLES::
|
418
|
+
|
419
|
+
sage: from sage.doctest.external import AvailableSoftware
|
420
|
+
sage: S = AvailableSoftware()
|
421
|
+
sage: S.seen() # random
|
422
|
+
[]
|
423
|
+
"""
|
424
|
+
self._allow_external = True
|
425
|
+
# For multiprocessing of doctests, the data self._seen should be
|
426
|
+
# shared among subprocesses. Thus we use Array class from the
|
427
|
+
# multiprocessing module.
|
428
|
+
from sage.features.all import all_features
|
429
|
+
self._external_features = set(external_features())
|
430
|
+
features = set(self._external_features)
|
431
|
+
features.update(all_features())
|
432
|
+
self._features = sorted(features, key=lambda feature: feature.name)
|
433
|
+
self._indices = {feature.name: idx for idx, feature in enumerate(self._features)}
|
434
|
+
self._seen = Array('i', len(self._features)) # initialized to zeroes
|
435
|
+
self._hidden = Array('i', len(self._features)) # initialized to zeroes
|
436
|
+
|
437
|
+
def __contains__(self, item):
|
438
|
+
"""
|
439
|
+
Return ``True`` if ``item`` is available on the system.
|
440
|
+
|
441
|
+
EXAMPLES::
|
442
|
+
|
443
|
+
sage: from sage.doctest.external import available_software
|
444
|
+
sage: 'internet' in available_software # random, optional - internet
|
445
|
+
True
|
446
|
+
"""
|
447
|
+
try:
|
448
|
+
idx = self._indices[item]
|
449
|
+
except KeyError:
|
450
|
+
return False
|
451
|
+
feature = self._features[idx]
|
452
|
+
if feature.is_hidden():
|
453
|
+
if not self._hidden[idx]:
|
454
|
+
self._hidden[idx] = 1
|
455
|
+
available = False # a hidden feature is considered to be not available
|
456
|
+
else:
|
457
|
+
if not self._allow_external and feature in self._external_features:
|
458
|
+
# an external feature is considered to be not available
|
459
|
+
# if this is not allowed
|
460
|
+
available = False
|
461
|
+
elif feature.is_present():
|
462
|
+
available = True
|
463
|
+
else:
|
464
|
+
available = False
|
465
|
+
if available:
|
466
|
+
if not self._seen[idx]:
|
467
|
+
self._seen[idx] = 1
|
468
|
+
return True
|
469
|
+
else:
|
470
|
+
return False
|
471
|
+
|
472
|
+
def issuperset(self, other):
|
473
|
+
"""
|
474
|
+
Return ``True`` if ``other`` is a subset of ``self``.
|
475
|
+
|
476
|
+
EXAMPLES::
|
477
|
+
|
478
|
+
sage: from sage.doctest.external import available_software
|
479
|
+
sage: available_software.issuperset(set(['internet','latex','magma'])) # random, optional - internet latex magma
|
480
|
+
True
|
481
|
+
"""
|
482
|
+
for item in other:
|
483
|
+
if item not in self:
|
484
|
+
return False
|
485
|
+
return True
|
486
|
+
|
487
|
+
def detectable(self):
|
488
|
+
"""
|
489
|
+
Return the list of names of those features for which testing their presence is allowed.
|
490
|
+
"""
|
491
|
+
return [feature.name
|
492
|
+
for feature, seen in zip(self._features, self._seen)
|
493
|
+
if seen >= 0 and (self._allow_external or feature not in self._external_features)]
|
494
|
+
|
495
|
+
def seen(self):
|
496
|
+
"""
|
497
|
+
Return the list of detected external software.
|
498
|
+
|
499
|
+
EXAMPLES::
|
500
|
+
|
501
|
+
sage: from sage.doctest.external import available_software
|
502
|
+
sage: available_software.seen() # random
|
503
|
+
['internet', 'latex', 'magma']
|
504
|
+
"""
|
505
|
+
return [feature.name
|
506
|
+
for feature, seen in zip(self._features, self._seen)
|
507
|
+
if seen > 0]
|
508
|
+
|
509
|
+
def hidden(self):
|
510
|
+
"""
|
511
|
+
Return the list of detected hidden external software.
|
512
|
+
|
513
|
+
EXAMPLES::
|
514
|
+
|
515
|
+
sage: # needs conway_polynomials database_cremona_mini_ellcurve database_ellcurves database_graphs
|
516
|
+
sage: from sage.doctest.external import available_software
|
517
|
+
sage: from sage.features.databases import all_features
|
518
|
+
sage: for f in all_features():
|
519
|
+
....: f.hide()
|
520
|
+
....: if f._spkg_type() == 'standard':
|
521
|
+
....: test = f.name in available_software
|
522
|
+
....: f.unhide()
|
523
|
+
sage: sorted(available_software.hidden())
|
524
|
+
[...'conway_polynomials',...
|
525
|
+
'database_cremona_mini_ellcurve',...
|
526
|
+
'database_ellcurves',...
|
527
|
+
'database_graphs'...]
|
528
|
+
"""
|
529
|
+
return [feature.name
|
530
|
+
for feature, hidden in zip(self._features, self._hidden)
|
531
|
+
if hidden > 0]
|
532
|
+
|
533
|
+
|
534
|
+
available_software = AvailableSoftware()
|