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.
Files changed (162) hide show
  1. passagemath_repl-10.5.1.data/scripts/sage-cachegrind +25 -0
  2. passagemath_repl-10.5.1.data/scripts/sage-callgrind +16 -0
  3. passagemath_repl-10.5.1.data/scripts/sage-cleaner +230 -0
  4. passagemath_repl-10.5.1.data/scripts/sage-coverage +327 -0
  5. passagemath_repl-10.5.1.data/scripts/sage-eval +14 -0
  6. passagemath_repl-10.5.1.data/scripts/sage-fixdoctests +710 -0
  7. passagemath_repl-10.5.1.data/scripts/sage-inline-fortran +12 -0
  8. passagemath_repl-10.5.1.data/scripts/sage-ipynb2rst +50 -0
  9. passagemath_repl-10.5.1.data/scripts/sage-ipython +16 -0
  10. passagemath_repl-10.5.1.data/scripts/sage-massif +25 -0
  11. passagemath_repl-10.5.1.data/scripts/sage-notebook +267 -0
  12. passagemath_repl-10.5.1.data/scripts/sage-omega +25 -0
  13. passagemath_repl-10.5.1.data/scripts/sage-preparse +302 -0
  14. passagemath_repl-10.5.1.data/scripts/sage-run +27 -0
  15. passagemath_repl-10.5.1.data/scripts/sage-run-cython +10 -0
  16. passagemath_repl-10.5.1.data/scripts/sage-runtests +9 -0
  17. passagemath_repl-10.5.1.data/scripts/sage-startuptime.py +163 -0
  18. passagemath_repl-10.5.1.data/scripts/sage-valgrind +34 -0
  19. passagemath_repl-10.5.1.dist-info/METADATA +77 -0
  20. passagemath_repl-10.5.1.dist-info/RECORD +162 -0
  21. passagemath_repl-10.5.1.dist-info/WHEEL +5 -0
  22. passagemath_repl-10.5.1.dist-info/top_level.txt +1 -0
  23. sage/all__sagemath_repl.py +119 -0
  24. sage/doctest/__init__.py +4 -0
  25. sage/doctest/__main__.py +236 -0
  26. sage/doctest/all.py +4 -0
  27. sage/doctest/check_tolerance.py +261 -0
  28. sage/doctest/control.py +1727 -0
  29. sage/doctest/external.py +534 -0
  30. sage/doctest/fixtures.py +383 -0
  31. sage/doctest/forker.py +2665 -0
  32. sage/doctest/marked_output.py +102 -0
  33. sage/doctest/parsing.py +1708 -0
  34. sage/doctest/parsing_test.py +79 -0
  35. sage/doctest/reporting.py +733 -0
  36. sage/doctest/rif_tol.py +124 -0
  37. sage/doctest/sources.py +1657 -0
  38. sage/doctest/test.py +584 -0
  39. sage/doctest/tests/1second.rst +4 -0
  40. sage/doctest/tests/99seconds.rst +4 -0
  41. sage/doctest/tests/abort.rst +5 -0
  42. sage/doctest/tests/atexit.rst +7 -0
  43. sage/doctest/tests/fail_and_die.rst +6 -0
  44. sage/doctest/tests/initial.rst +15 -0
  45. sage/doctest/tests/interrupt.rst +7 -0
  46. sage/doctest/tests/interrupt_diehard.rst +14 -0
  47. sage/doctest/tests/keyboardinterrupt.rst +11 -0
  48. sage/doctest/tests/longtime.rst +5 -0
  49. sage/doctest/tests/nodoctest +5 -0
  50. sage/doctest/tests/random_seed.rst +4 -0
  51. sage/doctest/tests/show_skipped.rst +18 -0
  52. sage/doctest/tests/sig_on.rst +9 -0
  53. sage/doctest/tests/simple_failure.rst +8 -0
  54. sage/doctest/tests/sleep_and_raise.rst +106 -0
  55. sage/doctest/tests/tolerance.rst +31 -0
  56. sage/doctest/util.py +750 -0
  57. sage/interfaces/cleaner.py +48 -0
  58. sage/interfaces/quit.py +163 -0
  59. sage/misc/all__sagemath_repl.py +51 -0
  60. sage/misc/banner.py +235 -0
  61. sage/misc/benchmark.py +221 -0
  62. sage/misc/classgraph.py +134 -0
  63. sage/misc/copying.py +22 -0
  64. sage/misc/cython.py +694 -0
  65. sage/misc/dev_tools.py +745 -0
  66. sage/misc/edit_module.py +304 -0
  67. sage/misc/explain_pickle.py +3079 -0
  68. sage/misc/gperftools.py +361 -0
  69. sage/misc/inline_fortran.py +212 -0
  70. sage/misc/messaging.py +86 -0
  71. sage/misc/pager.py +21 -0
  72. sage/misc/profiler.py +179 -0
  73. sage/misc/python.py +70 -0
  74. sage/misc/remote_file.py +53 -0
  75. sage/misc/sage_eval.py +249 -0
  76. sage/misc/sage_input.py +3621 -0
  77. sage/misc/sagedoc.py +1742 -0
  78. sage/misc/sh.py +38 -0
  79. sage/misc/trace.py +90 -0
  80. sage/repl/__init__.py +16 -0
  81. sage/repl/all.py +15 -0
  82. sage/repl/attach.py +625 -0
  83. sage/repl/configuration.py +186 -0
  84. sage/repl/display/__init__.py +1 -0
  85. sage/repl/display/fancy_repr.py +354 -0
  86. sage/repl/display/formatter.py +318 -0
  87. sage/repl/display/jsmol_iframe.py +290 -0
  88. sage/repl/display/pretty_print.py +153 -0
  89. sage/repl/display/util.py +163 -0
  90. sage/repl/image.py +302 -0
  91. sage/repl/inputhook.py +91 -0
  92. sage/repl/interface_magic.py +298 -0
  93. sage/repl/interpreter.py +854 -0
  94. sage/repl/ipython_extension.py +593 -0
  95. sage/repl/ipython_kernel/__init__.py +1 -0
  96. sage/repl/ipython_kernel/__main__.py +4 -0
  97. sage/repl/ipython_kernel/all_jupyter.py +10 -0
  98. sage/repl/ipython_kernel/install.py +301 -0
  99. sage/repl/ipython_kernel/interact.py +278 -0
  100. sage/repl/ipython_kernel/kernel.py +217 -0
  101. sage/repl/ipython_kernel/widgets.py +466 -0
  102. sage/repl/ipython_kernel/widgets_sagenb.py +587 -0
  103. sage/repl/ipython_tests.py +163 -0
  104. sage/repl/load.py +326 -0
  105. sage/repl/preparse.py +2218 -0
  106. sage/repl/prompts.py +90 -0
  107. sage/repl/rich_output/__init__.py +4 -0
  108. sage/repl/rich_output/backend_base.py +648 -0
  109. sage/repl/rich_output/backend_doctest.py +316 -0
  110. sage/repl/rich_output/backend_emacs.py +151 -0
  111. sage/repl/rich_output/backend_ipython.py +596 -0
  112. sage/repl/rich_output/buffer.py +311 -0
  113. sage/repl/rich_output/display_manager.py +829 -0
  114. sage/repl/rich_output/example.avi +0 -0
  115. sage/repl/rich_output/example.canvas3d +1 -0
  116. sage/repl/rich_output/example.dvi +0 -0
  117. sage/repl/rich_output/example.flv +0 -0
  118. sage/repl/rich_output/example.gif +0 -0
  119. sage/repl/rich_output/example.jpg +0 -0
  120. sage/repl/rich_output/example.mkv +0 -0
  121. sage/repl/rich_output/example.mov +0 -0
  122. sage/repl/rich_output/example.mp4 +0 -0
  123. sage/repl/rich_output/example.ogv +0 -0
  124. sage/repl/rich_output/example.pdf +0 -0
  125. sage/repl/rich_output/example.png +0 -0
  126. sage/repl/rich_output/example.svg +54 -0
  127. sage/repl/rich_output/example.webm +0 -0
  128. sage/repl/rich_output/example.wmv +0 -0
  129. sage/repl/rich_output/example_jmol.spt.zip +0 -0
  130. sage/repl/rich_output/example_wavefront_scene.mtl +7 -0
  131. sage/repl/rich_output/example_wavefront_scene.obj +17 -0
  132. sage/repl/rich_output/output_basic.py +391 -0
  133. sage/repl/rich_output/output_browser.py +103 -0
  134. sage/repl/rich_output/output_catalog.py +54 -0
  135. sage/repl/rich_output/output_graphics.py +320 -0
  136. sage/repl/rich_output/output_graphics3d.py +345 -0
  137. sage/repl/rich_output/output_video.py +231 -0
  138. sage/repl/rich_output/preferences.py +432 -0
  139. sage/repl/rich_output/pretty_print.py +339 -0
  140. sage/repl/rich_output/test_backend.py +201 -0
  141. sage/repl/user_globals.py +214 -0
  142. sage/tests/all.py +0 -0
  143. sage/tests/all__sagemath_repl.py +3 -0
  144. sage/tests/article_heuberger_krenn_kropf_fsm-in-sage.py +630 -0
  145. sage/tests/arxiv_0812_2725.py +351 -0
  146. sage/tests/benchmark.py +1925 -0
  147. sage/tests/book_schilling_zabrocki_kschur_primer.py +795 -0
  148. sage/tests/book_stein_ent.py +651 -0
  149. sage/tests/book_stein_modform.py +558 -0
  150. sage/tests/cmdline.py +796 -0
  151. sage/tests/combinatorial_hopf_algebras.py +52 -0
  152. sage/tests/finite_poset.py +623 -0
  153. sage/tests/functools_partial_src.py +27 -0
  154. sage/tests/gosper-sum.py +218 -0
  155. sage/tests/lazy_imports.py +28 -0
  156. sage/tests/modular_group_cohomology.py +80 -0
  157. sage/tests/numpy.py +21 -0
  158. sage/tests/parigp.py +76 -0
  159. sage/tests/startup.py +27 -0
  160. sage/tests/symbolic-series.py +76 -0
  161. sage/tests/sympy.py +16 -0
  162. sage/tests/test_deprecation.py +31 -0
@@ -0,0 +1,304 @@
1
+ # sage_setup: distribution = sagemath-repl
2
+ """
3
+ Edit the source code of Sage interactively
4
+
5
+ AUTHORS:
6
+
7
+ - Nils Bruin
8
+ - William Stein -- touch up for inclusion in Sage.
9
+ - Simon King: Make it usable on extension classes that do not have
10
+ a docstring; include this module into the reference manual and
11
+ fix some syntax errors in the doc strings.
12
+
13
+ This module provides a routine to open the source file of a python
14
+ object in an editor of your choice, if the source file can be figured
15
+ out. For files that appear to be from the sage library, the path name
16
+ gets modified to the corresponding file in the current branch, i.e.,
17
+ the file that gets copied into the library upon 'sage -br'.
18
+
19
+ The editor to be run, and the way it should be called to open the
20
+ requested file at the right line number, can be supplied via a
21
+ template. For a limited number of editors, templates are already known
22
+ to the system. In those cases it suffices to give the editor name.
23
+
24
+ In fact, if the environment variable :envvar:`EDITOR` is set to a known editor,
25
+ then the system will use that if no template has been set explicitly.
26
+ """
27
+ # ****************************************************************************
28
+ # Copyright (C) 2007 Nils Bruin <nbruin@sfu.ca> and
29
+ # William Stein <wstein@math.ucsd.edu>
30
+ #
31
+ # This program is free software: you can redistribute it and/or modify
32
+ # it under the terms of the GNU General Public License as published by
33
+ # the Free Software Foundation, either version 2 of the License, or
34
+ # (at your option) any later version.
35
+ # https://www.gnu.org/licenses/
36
+ # ****************************************************************************
37
+
38
+ import sage.misc.sageinspect
39
+ import os
40
+ import re
41
+
42
+ from string import Template
43
+
44
+ # by default we do not have an edit template
45
+ edit_template = None
46
+
47
+ # we can set some defaults, however. Add your own if you like.
48
+
49
+ template_defaults = {
50
+ 'vi': Template('vi -c ${line} ${file}'),
51
+ 'vim': Template('vim -c ${line} ${file}'),
52
+ 'emacs': Template('emacs ${opts} +${line} ${file}'),
53
+ 'nedit-nc': Template('nedit-nc -line ${line} ${file}'),
54
+ 'nedit-client': Template('nedit-client -line ${line} ${file}'),
55
+ 'ncl': Template('ncl -line ${line} ${file}'),
56
+ 'gedit': Template('gedit +${line} ${file} &'),
57
+ 'kate': Template('kate -u --line +${line} ${file} &')}
58
+
59
+
60
+ def file_and_line(obj):
61
+ r"""
62
+ Look up source file and line number of ``obj``.
63
+
64
+ If the file lies in the Sage library, the path name of the
65
+ corresponding file in the current branch (i.e., the file that gets
66
+ copied into the Sage library upon running 'sage -br'). Note that
67
+ the first line of a file is considered to be 1 rather than 0
68
+ because most editors think that this is the case.
69
+
70
+ AUTHORS:
71
+
72
+ - Nils Bruin (2007-10-03)
73
+ - Simon King (2011-05): Use :mod:`~sage.misc.sageinspect` to get the file
74
+ and the line.
75
+
76
+ EXAMPLES::
77
+
78
+ sage: import sage.misc.edit_module as edit_module
79
+ sage: edit_module.file_and_line(sage.cpython)
80
+ ('...sage/cpython/__init__.py', 0)
81
+
82
+ The following tests against a bug that was fixed in :issue:`11298`::
83
+
84
+ sage: edit_module.file_and_line(x) # needs sage.symbolic
85
+ ('...sage/symbolic/expression...pyx', ...)
86
+ """
87
+ # d = inspect.getdoc(obj)
88
+ # ret = sage.misc.sageinspect._extract_embedded_position(d);
89
+ # if ret is not None:
90
+ # (_, filename, lineno) = ret
91
+ # else:
92
+ # filename = inspect.getsourcefile(obj)
93
+ # _,lineno = inspect.findsource(obj)
94
+
95
+ #
96
+ # for sage files, the registered source file is the result of the
97
+ # preparsing these files end in ".py" and have "*autogenerated*"
98
+ # on the second line for those files, we replace the extension by
99
+ # ".sage" and we subtract 3 from the line number to compensate
100
+ # for the 3 lines that were prefixed in the preparsing process
101
+ #
102
+ from sage.misc.sageinspect import sage_getfile, sage_getsourcelines
103
+ filename = sage_getfile(obj)
104
+ lineno = sage_getsourcelines(obj)[1] - 1
105
+ if filename.endswith('.py'):
106
+ infile = open(filename)
107
+ infile.readline()
108
+ if infile.readline().find("*autogenerated*") >= 0:
109
+ filename = filename[:-3] + '.sage'
110
+ lineno -= 3
111
+
112
+ runpathpattern = '^' + sage.env.SAGE_LIB
113
+ develbranch = sage.env.SAGE_SRC
114
+ filename = re.sub(runpathpattern, develbranch, filename)
115
+
116
+ return filename, lineno + 1
117
+
118
+
119
+ def template_fields(template):
120
+ r"""
121
+ Given a String.Template object, returns the fields.
122
+
123
+ AUTHOR:
124
+
125
+ Nils Bruin (2007-10-22)
126
+
127
+ EXAMPLES::
128
+
129
+ sage: from sage.misc.edit_module import template_fields
130
+ sage: from string import Template
131
+ sage: t = Template("Template ${one} with ${two} and ${three}")
132
+ sage: sorted(template_fields(t))
133
+ ['one', 'three', 'two']
134
+ """
135
+ dict = {}
136
+ dummy = None
137
+ while not dummy:
138
+ try:
139
+ dummy = template.substitute(dict)
140
+ except KeyError as inst:
141
+ dict[inst.args[0]] = None
142
+ return list(dict)
143
+
144
+ # The routine set_edit_template should only do some consistency
145
+ # checks on template_string It should not do any magic. This routine
146
+ # should give the user full control over what is going on.
147
+
148
+
149
+ def set_edit_template(template_string):
150
+ r"""
151
+ Set the default edit template string.
152
+
153
+ It should reference ``${file}`` and ``${line}``. This routine normally
154
+ needs to be called prior to using 'edit'. However, if the editor
155
+ set in the shell variable :envvar:`EDITOR` is known, then the system will
156
+ substitute an appropriate template for you. See
157
+ edit_module.template_defaults for the recognised templates.
158
+
159
+ AUTHOR:
160
+
161
+ Nils Bruin (2007-10-03)
162
+
163
+ EXAMPLES::
164
+
165
+ sage: from sage.misc.edit_module import set_edit_template
166
+ sage: set_edit_template("echo EDIT ${file}:${line}")
167
+ sage: edit(sage) # not tested
168
+ EDIT /usr/local/sage/src/sage/__init__.py:1
169
+ """
170
+ global edit_template
171
+
172
+ if not isinstance(template_string, Template):
173
+ template_string = Template(template_string)
174
+ fields = set(template_fields(template_string))
175
+ if not (fields <= {'file', 'line'} and ('file' in fields)):
176
+ raise ValueError("Only ${file} and ${line} are allowed as template variables, and ${file} must occur.")
177
+ edit_template = template_string
178
+
179
+ # The routine set_editor is for convenience and hence is allowed to
180
+ # apply magic. Given an editor name and possibly some options, it
181
+ # should try to set an editor_template that is as appropriate as
182
+ # possible for the situation. If it's necessary to query the
183
+ # environment for 'DISPLAY' to figure out if certain editors should
184
+ # be run in the background, this is where the magic should go.
185
+
186
+
187
+ def set_editor(editor_name, opts=''):
188
+ r"""
189
+ Set the editor to be used by the edit command by basic editor name.
190
+
191
+ Currently, the system only knows appropriate call strings for a
192
+ limited number of editors. If you want to use another editor, you
193
+ should set the whole edit template via :func:`set_edit_template`.
194
+
195
+ AUTHOR:
196
+
197
+ Nils Bruin (2007-10-05)
198
+
199
+ EXAMPLES::
200
+
201
+ sage: from sage.misc.edit_module import set_editor
202
+ sage: set_editor('vi')
203
+ sage: sage.misc.edit_module.edit_template.template
204
+ 'vi -c ${line} ${file}'
205
+ """
206
+ if editor_name in sage.misc.edit_module.template_defaults:
207
+ set_edit_template(Template(template_defaults[editor_name].safe_substitute(opts=opts)))
208
+ else:
209
+ raise ValueError("editor_name not known. Try set_edit_template(<template_string>) instead.")
210
+
211
+
212
+ def edit(obj, editor=None, bg=None):
213
+ r"""nodetex
214
+ Open source code of ``obj`` in editor of your choice.
215
+
216
+ INPUT:
217
+
218
+ - editor -- string (default: ``None``); if given, use specified editor.
219
+ Choice is stored for next time.
220
+
221
+ AUTHOR:
222
+
223
+ Nils Bruin (2007-10-03)
224
+
225
+ EXAMPLES:
226
+
227
+ This is a typical example of how to use this routine::
228
+
229
+ # make some object obj
230
+ sage: edit(obj) # not tested
231
+
232
+ Now for more details and customization::
233
+
234
+ sage: import sage.misc.edit_module as m
235
+ sage: m.set_edit_template("vi -c ${line} ${file}")
236
+
237
+ In fact, since ``vi`` is a well-known editor, you could also just use::
238
+
239
+ sage: m.set_editor("vi")
240
+
241
+ To illustrate::
242
+
243
+ sage: m.edit_template.template
244
+ 'vi -c ${line} ${file}'
245
+
246
+ And if your environment variable :envvar:`EDITOR` is set to a recognised
247
+ editor, you would not have to set anything.
248
+
249
+ To edit the source of an object, just type something like::
250
+
251
+ sage: edit(edit) # not tested
252
+ """
253
+ global edit_template
254
+
255
+ if editor:
256
+ set_editor(editor)
257
+ elif not edit_template:
258
+ try:
259
+ ED = os.environ['EDITOR']
260
+ EDITOR = ED.split()
261
+ base = EDITOR[0]
262
+ opts = ' '.join(EDITOR[1:]) # for future use
263
+ set_editor(base, opts=opts)
264
+ except (ValueError, KeyError, IndexError):
265
+ raise ValueError("Use set_edit_template(<template_string>) to set a default")
266
+
267
+ if not edit_template:
268
+ raise ValueError("Use set_edit_template(<template_string>) to set a default")
269
+
270
+ filename, lineno = file_and_line(obj)
271
+ cmd = edit_template.substitute(line=lineno, file=filename)
272
+
273
+ if bg is True and cmd[-1] != '&':
274
+ cmd = cmd + '&'
275
+ if bg is False and cmd[-1] == '&':
276
+ cmd = cmd[:-1]
277
+
278
+ os.system(cmd)
279
+
280
+
281
+ def edit_devel(self, filename, linenum):
282
+ """
283
+ This function is for internal use and is called by IPython when you use
284
+ the IPython commands ``%edit`` or ``%ed``.
285
+
286
+ This hook calls the default implementation, but changes the filename for
287
+ files that appear to be from the sage library: if the filename begins with
288
+ 'SAGE_LOCAL/lib/python.../site-packages', it replaces this by
289
+ 'SAGE_ROOT/src'.
290
+
291
+ EXAMPLES::
292
+
293
+ sage: %edit gcd # indirect doctest, not tested
294
+ sage: %ed gcd # indirect doctest, not tested
295
+
296
+ The above should open your favorite editor (as stored in the environment
297
+ variable :envvar:`EDITOR`) with the file in which gcd is defined, and when your
298
+ editor supports it, also at the line in which gcd is defined.
299
+ """
300
+ import IPython.core.hooks
301
+ runpathpattern = '^' + sage.env.SAGE_LIB
302
+ develbranch = sage.env.SAGE_SRC
303
+ filename = re.sub(runpathpattern, develbranch, filename)
304
+ IPython.core.hooks.editor(self, filename, linenum)