passagemath-repl 10.4.62__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.4.62.data/scripts/sage-cachegrind +25 -0
- passagemath_repl-10.4.62.data/scripts/sage-callgrind +16 -0
- passagemath_repl-10.4.62.data/scripts/sage-cleaner +230 -0
- passagemath_repl-10.4.62.data/scripts/sage-coverage +327 -0
- passagemath_repl-10.4.62.data/scripts/sage-eval +14 -0
- passagemath_repl-10.4.62.data/scripts/sage-fixdoctests +708 -0
- passagemath_repl-10.4.62.data/scripts/sage-inline-fortran +12 -0
- passagemath_repl-10.4.62.data/scripts/sage-ipynb2rst +50 -0
- passagemath_repl-10.4.62.data/scripts/sage-ipython +16 -0
- passagemath_repl-10.4.62.data/scripts/sage-massif +25 -0
- passagemath_repl-10.4.62.data/scripts/sage-notebook +267 -0
- passagemath_repl-10.4.62.data/scripts/sage-omega +25 -0
- passagemath_repl-10.4.62.data/scripts/sage-preparse +302 -0
- passagemath_repl-10.4.62.data/scripts/sage-run +27 -0
- passagemath_repl-10.4.62.data/scripts/sage-run-cython +10 -0
- passagemath_repl-10.4.62.data/scripts/sage-runtests +9 -0
- passagemath_repl-10.4.62.data/scripts/sage-startuptime.py +163 -0
- passagemath_repl-10.4.62.data/scripts/sage-valgrind +34 -0
- passagemath_repl-10.4.62.dist-info/METADATA +77 -0
- passagemath_repl-10.4.62.dist-info/RECORD +162 -0
- passagemath_repl-10.4.62.dist-info/WHEEL +5 -0
- passagemath_repl-10.4.62.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 +131 -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 +246 -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/__init__.py +1 -0
- sage/tests/all.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 +1923 -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 +790 -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/misc/sh.py
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# sage_setup: distribution = sagemath-repl
|
2
|
+
"Evaluating shell scripts"
|
3
|
+
|
4
|
+
import os
|
5
|
+
|
6
|
+
|
7
|
+
class Sh:
|
8
|
+
r"""
|
9
|
+
Evaluates a shell script and returns the output.
|
10
|
+
|
11
|
+
To use this from the notebook type ``sh`` at the beginning of
|
12
|
+
the input cell. The working directory is then the (usually
|
13
|
+
temporary) directory where the Sage worksheet process is
|
14
|
+
executing.
|
15
|
+
"""
|
16
|
+
def eval(self, code, globals=None, locals=None):
|
17
|
+
r"""
|
18
|
+
This is difficult to test because the output goes to the
|
19
|
+
screen rather than being captured by the doctest program, so
|
20
|
+
the following really only tests that the command doesn't bomb,
|
21
|
+
not that it gives the right output::
|
22
|
+
|
23
|
+
sage: sh.eval('''echo "Hello there"\nif [ $? -eq 0 ]; then\necho "good"\nfi''') # random output
|
24
|
+
"""
|
25
|
+
# Print out the current absolute path, which is where the code
|
26
|
+
# will be evaluated. Evidently, users find this comforting,
|
27
|
+
# though I personally find it to be a bit much (William Stein).
|
28
|
+
print(os.path.abspath('.'))
|
29
|
+
# Evaluate the input code block. Fortunately, os.system works
|
30
|
+
# fine with multiline input (in contrast to subprocess.Popen).
|
31
|
+
os.system(str(code))
|
32
|
+
# Return '' so nothing extra (for example an unsightly None)
|
33
|
+
# gets printed when doing %sh in the notebook.
|
34
|
+
return ''
|
35
|
+
|
36
|
+
|
37
|
+
# Create the sh object, so that %sh mode works in the notebook.
|
38
|
+
sh = Sh()
|
sage/misc/trace.py
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
# sage_setup: distribution = sagemath-repl
|
2
|
+
"""
|
3
|
+
Interactively tracing execution of a command
|
4
|
+
"""
|
5
|
+
|
6
|
+
|
7
|
+
def trace(code, preparse=True):
|
8
|
+
r"""
|
9
|
+
Evaluate Sage code using the interactive tracer and return the
|
10
|
+
result. The string ``code`` must be a valid expression
|
11
|
+
enclosed in quotes (no assignments - the result of the expression
|
12
|
+
is returned). In the Sage notebook this just raises a
|
13
|
+
NotImplementedException.
|
14
|
+
|
15
|
+
INPUT:
|
16
|
+
|
17
|
+
- ``code`` -- string
|
18
|
+
|
19
|
+
- ``preparse`` -- boolean (default: ``True``); if ``True``, run
|
20
|
+
expression through the Sage preparser
|
21
|
+
|
22
|
+
REMARKS: This function is extremely powerful! For example, if you
|
23
|
+
want to step through each line of execution of, e.g.,
|
24
|
+
``factor(100)``, type
|
25
|
+
|
26
|
+
::
|
27
|
+
|
28
|
+
sage: from sage.misc.trace import trace
|
29
|
+
sage: trace("factor(100)") # not tested
|
30
|
+
|
31
|
+
then at the (Pdb) prompt type ``s`` (or ``step``), then press :kbd:`Return`
|
32
|
+
over and over to step through every line of Python that is called
|
33
|
+
in the course of the above computation. Type ``?`` at any time for
|
34
|
+
help on how to use the debugger (e.g., ``l`` lists 11 lines around
|
35
|
+
the current line; ``bt`` gives a back trace, etc.).
|
36
|
+
|
37
|
+
Setting a break point: If you have some code in a file and would
|
38
|
+
like to drop into the debugger at a given point, put the following
|
39
|
+
code at that point in the file:
|
40
|
+
|
41
|
+
``import pdb; pdb.set_trace()``
|
42
|
+
|
43
|
+
For an article on how to use the Python debugger, see
|
44
|
+
http://www.onlamp.com/pub/a/python/2005/09/01/debugger.html
|
45
|
+
|
46
|
+
TESTS:
|
47
|
+
|
48
|
+
For tests we disable garbage collection, see :issue:`21258` ::
|
49
|
+
|
50
|
+
sage: import gc
|
51
|
+
sage: gc.disable()
|
52
|
+
|
53
|
+
The only real way to test this is via pexpect spawning a
|
54
|
+
sage subprocess that uses IPython::
|
55
|
+
|
56
|
+
sage: # needs pexpect sage.all
|
57
|
+
sage: import pexpect
|
58
|
+
sage: s = pexpect.spawn('sage')
|
59
|
+
sage: _ = s.sendline("from sage.misc.trace import trace; trace('print(factor(10))'); print(3+97)")
|
60
|
+
sage: _ = s.expect('ipdb>', timeout=90)
|
61
|
+
sage: _ = s.sendline("s"); _ = s.sendline("c")
|
62
|
+
sage: _ = s.expect('100', timeout=90)
|
63
|
+
|
64
|
+
Seeing the ipdb prompt and the 2 \* 5 in the output below is a
|
65
|
+
strong indication that the trace command worked correctly::
|
66
|
+
|
67
|
+
sage: print(s.before[s.before.find(b'--'):].decode()) # needs pexpect sage.all
|
68
|
+
--...
|
69
|
+
...ipdb> c
|
70
|
+
...2 * 5...
|
71
|
+
|
72
|
+
Re-enable garbage collection::
|
73
|
+
|
74
|
+
sage: gc.enable()
|
75
|
+
"""
|
76
|
+
from IPython.core.debugger import Pdb
|
77
|
+
pdb = Pdb()
|
78
|
+
|
79
|
+
try:
|
80
|
+
ipython = get_ipython()
|
81
|
+
except NameError:
|
82
|
+
raise NotImplementedError("the trace command can only be run from the Sage command-line")
|
83
|
+
|
84
|
+
from sage.repl.preparse import preparse
|
85
|
+
code = preparse(code)
|
86
|
+
return pdb.run(code, ipython.user_ns)
|
87
|
+
|
88
|
+
# this could also be useful; it drops
|
89
|
+
# us into a debugger in an except block:
|
90
|
+
# import pdb; pdb.post_mortem(sys.exc_info()[2])
|
sage/repl/__init__.py
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# sage_setup: distribution = sagemath-repl
|
2
|
+
# IPython calls this when "%load_ext sage.repl" is used.
|
3
|
+
# The Sage application loads it when starting up.
|
4
|
+
def load_ipython_extension(*args):
|
5
|
+
import sage.repl.ipython_extension
|
6
|
+
sage.repl.ipython_extension.load_ipython_extension(*args)
|
7
|
+
|
8
|
+
|
9
|
+
# The above used to be in sage.__init__, allowing users to use "%load_ext sage".
|
10
|
+
# But we are clearing out the __init__.py file as a preparation for
|
11
|
+
# making sage a native namespace package.
|
12
|
+
#
|
13
|
+
# So we make "%load_ext sage" work by monkey-patching the function
|
14
|
+
# into the sage package upon importing sage.repl.
|
15
|
+
import sage
|
16
|
+
sage.load_ipython_extension = load_ipython_extension
|
sage/repl/all.py
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# sage_setup: distribution = sagemath-repl
|
2
|
+
from sage.misc.lazy_import import lazy_import
|
3
|
+
|
4
|
+
from sage.repl.preparse import preparse, implicit_multiplication
|
5
|
+
|
6
|
+
lazy_import('sage.repl.interpreter', 'preparser')
|
7
|
+
|
8
|
+
lazy_import('sage.repl.attach', [
|
9
|
+
'attach', 'detach', 'attached_files', 'load_attach_path',
|
10
|
+
'reset_load_attach_path', 'load_attach_mode'])
|
11
|
+
|
12
|
+
from sage.repl.rich_output.display_manager import get_display_manager
|
13
|
+
|
14
|
+
from sage.repl.rich_output.pretty_print import pretty_print, show
|
15
|
+
del lazy_import
|