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.
Files changed (162) hide show
  1. passagemath_repl-10.4.62.data/scripts/sage-cachegrind +25 -0
  2. passagemath_repl-10.4.62.data/scripts/sage-callgrind +16 -0
  3. passagemath_repl-10.4.62.data/scripts/sage-cleaner +230 -0
  4. passagemath_repl-10.4.62.data/scripts/sage-coverage +327 -0
  5. passagemath_repl-10.4.62.data/scripts/sage-eval +14 -0
  6. passagemath_repl-10.4.62.data/scripts/sage-fixdoctests +708 -0
  7. passagemath_repl-10.4.62.data/scripts/sage-inline-fortran +12 -0
  8. passagemath_repl-10.4.62.data/scripts/sage-ipynb2rst +50 -0
  9. passagemath_repl-10.4.62.data/scripts/sage-ipython +16 -0
  10. passagemath_repl-10.4.62.data/scripts/sage-massif +25 -0
  11. passagemath_repl-10.4.62.data/scripts/sage-notebook +267 -0
  12. passagemath_repl-10.4.62.data/scripts/sage-omega +25 -0
  13. passagemath_repl-10.4.62.data/scripts/sage-preparse +302 -0
  14. passagemath_repl-10.4.62.data/scripts/sage-run +27 -0
  15. passagemath_repl-10.4.62.data/scripts/sage-run-cython +10 -0
  16. passagemath_repl-10.4.62.data/scripts/sage-runtests +9 -0
  17. passagemath_repl-10.4.62.data/scripts/sage-startuptime.py +163 -0
  18. passagemath_repl-10.4.62.data/scripts/sage-valgrind +34 -0
  19. passagemath_repl-10.4.62.dist-info/METADATA +77 -0
  20. passagemath_repl-10.4.62.dist-info/RECORD +162 -0
  21. passagemath_repl-10.4.62.dist-info/WHEEL +5 -0
  22. passagemath_repl-10.4.62.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 +131 -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 +246 -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/__init__.py +1 -0
  143. sage/tests/all.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 +1923 -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 +790 -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
Binary file
@@ -0,0 +1 @@
1
+ [{"vertices":[{"x":1,"y":1,"z":1},{"x":-1,"y":1,"z":1},{"x":-1,"y":-1,"z":1},{"x":1,"y":-1,"z":1}],"faces":[[0,1,2,3]],"color":"008000"},{"vertices":[{"x":1,"y":1,"z":1},{"x":-1,"y":1,"z":1},{"x":-1,"y":1,"z":-1},{"x":1,"y":1,"z":-1}],"faces":[[0,1,2,3]],"color":"008000"},{"vertices":[{"x":1,"y":1,"z":1},{"x":1,"y":-1,"z":1},{"x":1,"y":-1,"z":-1},{"x":1,"y":1,"z":-1}],"faces":[[0,1,2,3]],"color":"008000"},{"vertices":[{"x":-1,"y":1,"z":1},{"x":-1,"y":-1,"z":1},{"x":-1,"y":-1,"z":-1},{"x":-1,"y":1,"z":-1}],"faces":[[0,1,2,3]],"color":"008000"},{"vertices":[{"x":1,"y":1,"z":-1},{"x":-1,"y":1,"z":-1},{"x":-1,"y":-1,"z":-1},{"x":1,"y":-1,"z":-1}],"faces":[[0,1,2,3]],"color":"008000"},{"vertices":[{"x":1,"y":-1,"z":1},{"x":-1,"y":-1,"z":1},{"x":-1,"y":-1,"z":-1},{"x":1,"y":-1,"z":-1}],"faces":[[0,1,2,3]],"color":"008000"}]
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,54 @@
1
+ <?xml version="1.0" encoding="utf-8" standalone="no"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
3
+ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
+ <!-- Created with matplotlib (http://matplotlib.org/) -->
5
+ <svg height="420pt" version="1.1" viewBox="0 0 420 420" width="420pt" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
6
+ <defs>
7
+ <style type="text/css">
8
+ *{stroke-linecap:butt;stroke-linejoin:round;}
9
+ </style>
10
+ </defs>
11
+ <g id="figure_1">
12
+ <g id="patch_1">
13
+ <path d="
14
+ M0 420.48
15
+ L420.48 420.48
16
+ L420.48 0
17
+ L0 0
18
+ z
19
+ " style="fill:#ffffff;"/>
20
+ </g>
21
+ <g id="axes_1">
22
+ <g id="patch_2">
23
+ <path d="
24
+ M7.2 413.28
25
+ L413.28 413.28
26
+ L413.28 7.2
27
+ L7.2 7.2
28
+ z
29
+ " style="fill:#ffffff;"/>
30
+ </g>
31
+ <g id="matplotlib.axis_1"/>
32
+ <g id="matplotlib.axis_2"/>
33
+ <g id="patch_3">
34
+ <path clip-path="url(#p85c0e9ffdb)" d="
35
+ M210.24 405.471
36
+ C262.016 405.471 311.678 384.9 348.289 348.289
37
+ C384.9 311.678 405.471 262.016 405.471 210.24
38
+ C405.471 158.464 384.9 108.802 348.289 72.191
39
+ C311.678 35.58 262.016 15.0092 210.24 15.0092
40
+ C158.464 15.0092 108.802 35.58 72.191 72.191
41
+ C35.58 108.802 15.0092 158.464 15.0092 210.24
42
+ C15.0092 262.016 35.58 311.678 72.191 348.289
43
+ C108.802 384.9 158.464 405.471 210.24 405.471
44
+ z
45
+ " style="fill:none;stroke:#0000ff;"/>
46
+ </g>
47
+ </g>
48
+ </g>
49
+ <defs>
50
+ <clipPath id="p85c0e9ffdb">
51
+ <rect height="406.08" width="406.08" x="7.2" y="7.2"/>
52
+ </clipPath>
53
+ </defs>
54
+ </svg>
Binary file
Binary file
@@ -0,0 +1,7 @@
1
+ newmtl texture177
2
+ Ka 0.2 0.2 0.5
3
+ Kd 0.4 0.4 1.0
4
+ Ks 0.0 0.0 0.0
5
+ illum 1
6
+ Ns 1
7
+ d 1
@@ -0,0 +1,17 @@
1
+ mtllib scene.mtl
2
+ g obj_1
3
+ usemtl texture177
4
+ v 0.5 0.5 0.5
5
+ v -0.5 0.5 0.5
6
+ v -0.5 -0.5 0.5
7
+ v 0.5 -0.5 0.5
8
+ v 0.5 0.5 -0.5
9
+ v -0.5 0.5 -0.5
10
+ v 0.5 -0.5 -0.5
11
+ v -0.5 -0.5 -0.5
12
+ f 1 2 3 4
13
+ f 1 5 6 2
14
+ f 1 4 7 5
15
+ f 6 5 7 8
16
+ f 7 4 3 8
17
+ f 3 2 6 8
@@ -0,0 +1,391 @@
1
+ # sage_setup: distribution = sagemath-repl
2
+ r"""
3
+ Basic Output Types
4
+
5
+ The Sage rich representation system requires a special container class
6
+ to hold the data for each type of rich output. They all inherit from
7
+ :class:`OutputBase`, though a more typical example is
8
+ :class:`OutputPlainText`. Some output classes consist of more than one
9
+ data buffer, for example jmol or certain animation formats. The output
10
+ class is independent of user preferences and of the display
11
+ backend.
12
+
13
+ The display backends can define derived classes to attach
14
+ backend-specific display functionality to, for example how to launch a
15
+ viewer. But they must not change how the output container is
16
+ created. To enforce this, the Sage ``_rich_repr_`` magic method will
17
+ only ever see the output class defined here. The display manager will
18
+ promote it to a backend-specific subclass if necessary prior to
19
+ displaying it.
20
+
21
+ To create new types of output, you must create your own subclass of
22
+ :class:`OutputBase` and register it in
23
+ :mod:`sage.repl.rich_output.output_catalog`.
24
+
25
+ .. warning::
26
+
27
+ All rich output data in subclasses of :class:`OutputBase` must be
28
+ contained in :class:`~sage.repl.rich_output.buffer.OutputBuffer`
29
+ instances. You must never reference any files on the local file
30
+ system, as there is no guarantee that the notebook server and the
31
+ worker process are on the same computer. Or even share a common
32
+ file system.
33
+ """
34
+
35
+ #*****************************************************************************
36
+ # Copyright (C) 2015 Volker Braun <vbraun.name@gmail.com>
37
+ #
38
+ # Distributed under the terms of the GNU General Public License (GPL)
39
+ # as published by the Free Software Foundation; either version 2 of
40
+ # the License, or (at your option) any later version.
41
+ # http://www.gnu.org/licenses/
42
+ #*****************************************************************************
43
+
44
+
45
+ from sage.structure.sage_object import SageObject
46
+ from sage.repl.rich_output.buffer import OutputBuffer
47
+
48
+
49
+ class OutputBase(SageObject):
50
+ """
51
+ Base class for all rich output containers.
52
+ """
53
+
54
+ def _repr_(self):
55
+ """
56
+ Return a string representation.
57
+
58
+ OUTPUT: string
59
+
60
+ EXAMPLES::
61
+
62
+ sage: from sage.repl.rich_output.output_basic import OutputBase
63
+ sage: output_base = OutputBase()
64
+ sage: output_base._repr_()
65
+ 'OutputBase container'
66
+ """
67
+ return '{0} container'.format(self.__class__.__name__)
68
+
69
+ @classmethod
70
+ def example(cls):
71
+ """
72
+ Construct a sample instance.
73
+
74
+ This static method is meant for doctests, so they can easily
75
+ construct an example.
76
+
77
+ OUTPUT: an instance of the :class:`OutputBase` subclass
78
+
79
+ EXAMPLES::
80
+
81
+ sage: from sage.repl.rich_output.output_basic import OutputBase
82
+ sage: OutputBase.example()
83
+ Traceback (most recent call last):
84
+ ...
85
+ NotImplementedError: derived classes must implement this class method
86
+ """
87
+ raise NotImplementedError('derived classes must implement this class method')
88
+
89
+
90
+ class OutputPlainText(OutputBase):
91
+
92
+ def __init__(self, plain_text):
93
+ """
94
+ Plain Text Output.
95
+
96
+ INPUT:
97
+
98
+ - ``plain_text`` --
99
+ :class:`~sage.repl.rich_output.buffer.OutputBuffer`. Alternatively,
100
+ a bytes (string in Python 2.x) or string (unicode in Python
101
+ 2.x) can be passed directly which will then be converted
102
+ into an
103
+ :class:`~sage.repl.rich_output.buffer.OutputBuffer`. The
104
+ plain text output.
105
+
106
+ This should always be exactly the same as the (non-rich)
107
+ output from the ``_repr_`` method. Every backend object must
108
+ support plain text output as fallback.
109
+
110
+ EXAMPLES::
111
+
112
+ sage: from sage.repl.rich_output.output_catalog import OutputPlainText
113
+ sage: OutputPlainText('foo')
114
+ OutputPlainText container
115
+ """
116
+ self.text = OutputBuffer(plain_text)
117
+
118
+ @classmethod
119
+ def example(cls):
120
+ """
121
+ Construct a sample plain text output container.
122
+
123
+ This static method is meant for doctests, so they can easily
124
+ construct an example.
125
+
126
+ OUTPUT: an instance of :class:`OutputPlainText`
127
+
128
+ EXAMPLES::
129
+
130
+ sage: from sage.repl.rich_output.output_catalog import OutputPlainText
131
+ sage: OutputPlainText.example()
132
+ OutputPlainText container
133
+ sage: OutputPlainText.example().text.get_str()
134
+ 'Example plain text output'
135
+ """
136
+ return cls('Example plain text output')
137
+
138
+ def print_to_stdout(self):
139
+ """
140
+ Write the data to stdout.
141
+
142
+ This is just a convenience method to help with debugging.
143
+
144
+ EXAMPLES::
145
+
146
+ sage: from sage.repl.rich_output.output_catalog import OutputPlainText
147
+ sage: plain_text = OutputPlainText.example()
148
+ sage: plain_text.print_to_stdout()
149
+ Example plain text output
150
+ """
151
+ print(self.text.get_str())
152
+
153
+
154
+ class OutputAsciiArt(OutputBase):
155
+
156
+ def __init__(self, ascii_art):
157
+ """
158
+ ASCII Art Output.
159
+
160
+ INPUT:
161
+
162
+ - ``ascii_art`` --
163
+ :class:`~sage.repl.rich_output.buffer.OutputBuffer`. Alternatively,
164
+ a string (bytes) can be passed directly which will then be
165
+ converted into an
166
+ :class:`~sage.repl.rich_output.buffer.OutputBuffer`. Ascii
167
+ art rendered into a string.
168
+
169
+ EXAMPLES::
170
+
171
+ sage: from sage.repl.rich_output.output_catalog import OutputAsciiArt
172
+ sage: OutputAsciiArt(':-}')
173
+ OutputAsciiArt container
174
+ """
175
+ self.ascii_art = OutputBuffer(ascii_art)
176
+
177
+ @classmethod
178
+ def example(cls):
179
+ r"""
180
+ Construct a sample ascii art output container.
181
+
182
+ This static method is meant for doctests, so they can easily
183
+ construct an example.
184
+
185
+ OUTPUT: an instance of :class:`OutputAsciiArt`
186
+
187
+ EXAMPLES::
188
+
189
+ sage: from sage.repl.rich_output.output_catalog import OutputAsciiArt
190
+ sage: OutputAsciiArt.example()
191
+ OutputAsciiArt container
192
+ sage: OutputAsciiArt.example().ascii_art.get_str()
193
+ '[ * * * * ]\n[ ** ** * * * * * * ]\n[ ***, * , * , **, ** , *, * , * , * ]'
194
+ """
195
+ return cls('[ * * * * ]\n'
196
+ '[ ** ** * * * * * * ]\n'
197
+ '[ ***, * , * , **, ** , *, * , * , * ]')
198
+
199
+ def print_to_stdout(self):
200
+ """
201
+ Write the data to stdout.
202
+
203
+ This is just a convenience method to help with debugging.
204
+
205
+ EXAMPLES::
206
+
207
+ sage: from sage.repl.rich_output.output_catalog import OutputAsciiArt
208
+ sage: ascii_art = OutputAsciiArt.example()
209
+ sage: ascii_art.print_to_stdout()
210
+ [ * * * * ]
211
+ [ ** ** * * * * * * ]
212
+ [ ***, * , * , **, ** , *, * , * , * ]
213
+ """
214
+ print(self.ascii_art.get_str())
215
+
216
+
217
+ class OutputUnicodeArt(OutputBase):
218
+
219
+ def __init__(self, unicode_art):
220
+ """
221
+ Unicode Art Output.
222
+
223
+ Similar to :class:`OutputAsciiArt` but using the entire
224
+ unicode range.
225
+
226
+ INPUT:
227
+
228
+ - ``unicode_art`` --
229
+ :class:`~sage.repl.rich_output.buffer.OutputBuffer`. Alternatively,
230
+ a string (unicode in Python 2.x) can be passed directly
231
+ which will then be converted into an
232
+ :class:`~sage.repl.rich_output.buffer.OutputBuffer`. Unicode
233
+ art rendered into a string.
234
+
235
+ EXAMPLES::
236
+
237
+ sage: from sage.repl.rich_output.output_catalog import OutputUnicodeArt
238
+ sage: OutputUnicodeArt(u':-}')
239
+ OutputUnicodeArt container
240
+ """
241
+ # Internally, all buffers store bytes. Unicode is always utf-8
242
+ # encoded.
243
+ if not isinstance(unicode_art, bytes):
244
+ unicode_art = unicode_art.encode('utf-8')
245
+ self.unicode_art = OutputBuffer(unicode_art)
246
+
247
+ @classmethod
248
+ def example(cls):
249
+ r"""
250
+ Construct a sample unicode art output container.
251
+
252
+ This static method is meant for doctests, so they can easily
253
+ construct an example.
254
+
255
+ OUTPUT: an instance of :class:`OutputUnicodeArt`
256
+
257
+ EXAMPLES::
258
+
259
+ sage: from sage.repl.rich_output.output_catalog import OutputUnicodeArt
260
+ sage: OutputUnicodeArt.example()
261
+ OutputUnicodeArt container
262
+ sage: print(OutputUnicodeArt.example().unicode_art.get_unicode())
263
+ ⎛-11 0 1⎞
264
+ ⎜ 3 -1 0⎟
265
+ ⎝ -1 -1 0⎠
266
+ """
267
+ return cls('⎛-11 0 1⎞\n'
268
+ '⎜ 3 -1 0⎟\n'
269
+ '⎝ -1 -1 0⎠')
270
+
271
+ def print_to_stdout(self):
272
+ """
273
+ Write the data to stdout.
274
+
275
+ This is just a convenience method to help with debugging.
276
+
277
+ EXAMPLES::
278
+
279
+ sage: from sage.repl.rich_output.output_catalog import OutputUnicodeArt
280
+ sage: unicode_art = OutputUnicodeArt.example()
281
+ sage: unicode_art.print_to_stdout()
282
+ ⎛-11 0 1⎞
283
+ ⎜ 3 -1 0⎟
284
+ ⎝ -1 -1 0⎠
285
+ """
286
+ print(self.unicode_art.get_unicode())
287
+
288
+
289
+ class OutputLatex(OutputBase):
290
+
291
+ def __init__(self, latex):
292
+ """
293
+ LaTeX Output.
294
+
295
+ .. NOTE::
296
+
297
+ The LaTeX commands will only use a subset of LaTeX that
298
+ can be displayed by MathJax.
299
+
300
+ INPUT:
301
+
302
+ - ``latex`` --
303
+ :class:`~sage.repl.rich_output.buffer.OutputBuffer`. Alternatively,
304
+ a string (bytes) can be passed directly which will then be
305
+ converted into an
306
+ :class:`~sage.repl.rich_output.buffer.OutputBuffer`. String
307
+ containing the latex equation code. Excludes the surrounding
308
+ dollar signs / LaTeX equation environment.
309
+
310
+ EXAMPLES::
311
+
312
+ sage: from sage.repl.rich_output.output_catalog import OutputLatex
313
+ sage: OutputLatex(latex(sqrt(x))) # needs sage.symbolic
314
+ OutputLatex container
315
+ """
316
+ self.latex = OutputBuffer(latex)
317
+
318
+ def display_equation(self):
319
+ r"""
320
+ Return the LaTeX code for a display equation.
321
+
322
+ OUTPUT: string
323
+
324
+ EXAMPLES::
325
+
326
+ sage: from sage.repl.rich_output.output_catalog import OutputLatex
327
+ sage: rich_output = OutputLatex('1')
328
+ sage: rich_output.latex
329
+ buffer containing 1 bytes
330
+ sage: rich_output.latex.get_str()
331
+ '1'
332
+ sage: rich_output.display_equation()
333
+ '\\begin{equation}\n1\n\\end{equation}'
334
+ """
335
+ return '\n'.join([r'\begin{equation}', self.latex.get_str(),
336
+ r'\end{equation}'])
337
+
338
+ def inline_equation(self):
339
+ r"""
340
+ Return the LaTeX code for an inline equation.
341
+
342
+ OUTPUT: string
343
+
344
+ EXAMPLES::
345
+
346
+ sage: from sage.repl.rich_output.output_catalog import OutputLatex
347
+ sage: rich_output = OutputLatex('1')
348
+ sage: rich_output.latex
349
+ buffer containing 1 bytes
350
+ sage: rich_output.latex.get_str()
351
+ '1'
352
+ sage: rich_output.inline_equation()
353
+ '\\begin{math}\n1\n\\end{math}'
354
+ """
355
+ return '\n'.join([r'\begin{math}', self.latex.get_str(), r'\end{math}'])
356
+
357
+ @classmethod
358
+ def example(cls):
359
+ r"""
360
+ Construct a sample LaTeX output container.
361
+
362
+ This static method is meant for doctests, so they can easily
363
+ construct an example.
364
+
365
+ OUTPUT: an instance of :class:`OutputLatex`
366
+
367
+ EXAMPLES::
368
+
369
+ sage: from sage.repl.rich_output.output_catalog import OutputLatex
370
+ sage: OutputLatex.example()
371
+ OutputLatex container
372
+ sage: OutputLatex.example().latex.get_str()
373
+ '\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\int \\sin\\left(x\\right)\\,{d x}'
374
+ """
375
+ return cls(r'\newcommand{\Bold}[1]{\mathbf{#1}}'
376
+ r'\int \sin\left(x\right)\,{d x}')
377
+
378
+ def print_to_stdout(self):
379
+ r"""
380
+ Write the data to stdout.
381
+
382
+ This is just a convenience method to help with debugging.
383
+
384
+ EXAMPLES::
385
+
386
+ sage: from sage.repl.rich_output.output_catalog import OutputLatex
387
+ sage: rich_output = OutputLatex.example()
388
+ sage: rich_output.print_to_stdout()
389
+ \newcommand{\Bold}[1]{\mathbf{#1}}\int \sin\left(x\right)\,{d x}
390
+ """
391
+ print(self.latex.get_str())
@@ -0,0 +1,103 @@
1
+ # sage_setup: distribution = sagemath-repl
2
+ r"""
3
+ Rich Output for the Browser
4
+ """
5
+
6
+ import re
7
+
8
+ from sage.repl.rich_output.output_basic import OutputBase
9
+ from sage.repl.rich_output.buffer import OutputBuffer
10
+
11
+ # regex to match "<html>\[...\]</html>" or "<html>\(...\)</html>"
12
+ latex_re = re.compile(r'<html>(?P<mathstart>\\\[|\\\()(?P<latex>.*)(?P<mathend>\\\]|\\\))</html>',
13
+ flags=re.DOTALL)
14
+
15
+
16
+ class OutputHtml(OutputBase):
17
+
18
+ def __init__(self, html):
19
+ """
20
+ HTML Output.
21
+
22
+ INPUT:
23
+
24
+ - ``html`` --
25
+ :class:`~sage.repl.rich_output.buffer.OutputBuffer`. Alternatively, a
26
+ string (bytes) can be passed directly which will then be converted
27
+ into an :class:`~sage.repl.rich_output.buffer.OutputBuffer`. String
28
+ containing the html fragment code. Excludes the surrounding
29
+ ``<body>`` and ``<html>`` tag.
30
+
31
+ EXAMPLES::
32
+
33
+ sage: from sage.repl.rich_output.output_catalog import OutputHtml
34
+ sage: OutputHtml('<div>Foo<b>B</b>ar</div>')
35
+ OutputHtml container
36
+ """
37
+ self.html = OutputBuffer(html)
38
+
39
+ # if the html is a simple wrapper of latex for mathjax rendering, then
40
+ # the latex string is saved for possible latex output such as Jupyter's
41
+ # pdf export of a notebook
42
+ m = latex_re.match(html)
43
+ if m:
44
+ mathjax_string = m.group('latex')
45
+ latex_string = mathjax_string.replace('&lt;', '<')
46
+ if m.group('mathstart') == r'\[' and m.group('mathend') == r'\]':
47
+ self.latex = OutputBuffer('$$' + latex_string + '$$')
48
+ else:
49
+ self.latex = OutputBuffer('$' + latex_string + '$')
50
+ else:
51
+ self.latex = None
52
+
53
+ @classmethod
54
+ def example(cls):
55
+ r"""
56
+ Construct a sample Html output container.
57
+
58
+ This static method is meant for doctests, so they can easily
59
+ construct an example.
60
+
61
+ OUTPUT: an instance of :class:`OutputHtml`
62
+
63
+ EXAMPLES::
64
+
65
+ sage: from sage.repl.rich_output.output_catalog import OutputHtml
66
+ sage: OutputHtml.example()
67
+ OutputHtml container
68
+ sage: OutputHtml.example().html.get_str()
69
+ '<div>Hello World!</div>'
70
+ """
71
+ return cls('<div>Hello World!</div>')
72
+
73
+ def print_to_stdout(self):
74
+ r"""
75
+ Write the data to stdout.
76
+
77
+ This is just a convenience method to help with debugging.
78
+
79
+ EXAMPLES::
80
+
81
+ sage: from sage.repl.rich_output.output_catalog import OutputHtml
82
+ sage: rich_output = OutputHtml.example()
83
+ sage: rich_output.print_to_stdout()
84
+ <div>Hello World!</div>
85
+ """
86
+ print(self.html.get_unicode())
87
+
88
+ def with_html_tag(self):
89
+ r"""
90
+ Return the HTML code surrounded by ``<html>`` tag.
91
+
92
+ This is just a convenience method.
93
+
94
+ EXAMPLES::
95
+
96
+ sage: from sage.repl.rich_output.output_catalog import OutputHtml
97
+ sage: rich_output = OutputHtml.example()
98
+ sage: rich_output.print_to_stdout()
99
+ <div>Hello World!</div>
100
+ sage: rich_output.with_html_tag()
101
+ '<html><div>Hello World!</div></html>'
102
+ """
103
+ return '<html>{0}</html>'.format(self.html.get_unicode())
@@ -0,0 +1,54 @@
1
+ # sage_setup: distribution = sagemath-repl
2
+ r"""
3
+ Catalog of all available output container types.
4
+
5
+ If you define another output type then you must add it to the imports here.
6
+ """
7
+
8
+ #*****************************************************************************
9
+ # Copyright (C) 2015 Volker Braun <vbraun.name@gmail.com>
10
+ #
11
+ # Distributed under the terms of the GNU General Public License (GPL)
12
+ # as published by the Free Software Foundation; either version 2 of
13
+ # the License, or (at your option) any later version.
14
+ # http://www.gnu.org/licenses/
15
+ #*****************************************************************************
16
+
17
+
18
+ from .output_basic import (
19
+ OutputPlainText,
20
+ OutputAsciiArt,
21
+ OutputUnicodeArt,
22
+ OutputLatex,
23
+ )
24
+
25
+ from .output_browser import (
26
+ OutputHtml,
27
+ )
28
+
29
+ from .output_graphics import (
30
+ OutputImagePng,
31
+ OutputImageGif,
32
+ OutputImageJpg,
33
+ OutputImageSvg,
34
+ OutputImagePdf,
35
+ OutputImageDvi,
36
+ )
37
+
38
+ from .output_graphics3d import (
39
+ OutputSceneJmol,
40
+ OutputSceneWavefront,
41
+ OutputSceneCanvas3d,
42
+ OutputSceneThreejs,
43
+ )
44
+
45
+ from .output_video import (
46
+ OutputVideoOgg,
47
+ OutputVideoWebM,
48
+ OutputVideoMp4,
49
+ OutputVideoFlash,
50
+ OutputVideoMatroska,
51
+ OutputVideoAvi,
52
+ OutputVideoWmv,
53
+ OutputVideoQuicktime,
54
+ )