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,383 @@
1
+ # sage_setup: distribution = sagemath-repl
2
+ r"""
3
+ Fixtures to help testing functionality
4
+
5
+ Utilities which modify or replace code to help with doctesting functionality.
6
+ Wrappers, proxies and mockups are typical examples of fixtures.
7
+
8
+ AUTHORS:
9
+
10
+ - Martin von Gagern (2014-12-15): AttributeAccessTracerProxy and trace_method
11
+ - Martin von Gagern (2015-01-02): Factor out TracerHelper and reproducible_repr
12
+
13
+ EXAMPLES:
14
+
15
+ You can use :func:`trace_method` to see how a method
16
+ communicates with its surroundings::
17
+
18
+ sage: class Foo():
19
+ ....: def f(self):
20
+ ....: self.y = self.g(self.x)
21
+ ....: def g(self, arg):
22
+ ....: return arg + 1
23
+ ....:
24
+ sage: foo = Foo()
25
+ sage: foo.x = 3
26
+ sage: from sage.doctest.fixtures import trace_method
27
+ sage: trace_method(foo, "f")
28
+ sage: foo.f()
29
+ enter f()
30
+ read x = 3
31
+ call g(3) -> 4
32
+ write y = 4
33
+ exit f -> None
34
+ """
35
+
36
+ #*****************************************************************************
37
+ # Copyright (C) 2014-2015 Martin von Gagern <Martin.vGagern@gmx.net>
38
+ #
39
+ # This program is free software: you can redistribute it and/or modify
40
+ # it under the terms of the GNU General Public License as published by
41
+ # the Free Software Foundation, either version 2 of the License, or
42
+ # (at your option) any later version.
43
+ # http://www.gnu.org/licenses/
44
+ #*****************************************************************************
45
+
46
+ from functools import wraps
47
+
48
+
49
+ def reproducible_repr(val):
50
+ r"""
51
+ String representation of an object in a reproducible way.
52
+
53
+ This tries to ensure that the returned string does not depend on
54
+ factors outside the control of the doctest.
55
+ One example is the order of elements in a hash-based structure.
56
+ For most objects, this is simply the ``repr`` of the object.
57
+
58
+ All types for which special handling had been implemented are
59
+ covered by the examples below. If a doctest requires special
60
+ handling for additional types, this function may be extended
61
+ appropriately. It is an error if an argument to this function has
62
+ a non-reproducible ``repr`` implementation and is not explicitly
63
+ mentioned in an example case below.
64
+
65
+ INPUT:
66
+
67
+ - ``val`` -- an object to be represented
68
+
69
+ OUTPUT:
70
+
71
+ A string representation of that object, similar to what ``repr``
72
+ returns but for certain cases with more guarantees to ensure
73
+ exactly the same result for semantically equivalent objects.
74
+
75
+ EXAMPLES::
76
+
77
+ sage: from sage.doctest.fixtures import reproducible_repr
78
+ sage: print(reproducible_repr(set(["a", "c", "b", "d"])))
79
+ set(['a', 'b', 'c', 'd'])
80
+ sage: print(reproducible_repr(frozenset(["a", "c", "b", "d"])))
81
+ frozenset(['a', 'b', 'c', 'd'])
82
+ sage: print(reproducible_repr([1, frozenset("cab"), set("bar"), 0]))
83
+ [1, frozenset(['a', 'b', 'c']), set(['a', 'b', 'r']), 0]
84
+ sage: print(reproducible_repr({3.0: "three", "2": "two", 1: "one"})) # needs sage.rings.real_mpfr
85
+ {'2': 'two', 1: 'one', 3.00000000000000: 'three'}
86
+ sage: print(reproducible_repr("foo\nbar")) # demonstrate default case
87
+ 'foo\nbar'
88
+ """
89
+
90
+ def sorted_pairs(iterable, pairs=False):
91
+ # We don't know whether container data structures will have
92
+ # homogeneous types, and if not, whether comparisons will work
93
+ # in a sane way. For this reason, we sort by representation first.
94
+ res = sorted((reproducible_repr(item), item) for item in iterable)
95
+ if not pairs:
96
+ res = [r for r, i in res]
97
+ return res
98
+
99
+ if isinstance(val, frozenset):
100
+ itms = sorted_pairs(val)
101
+ return "frozenset([{}])".format(", ".join(itms))
102
+ if isinstance(val, set):
103
+ itms = sorted_pairs(val)
104
+ return "set([{}])".format(", ".join(itms))
105
+ if isinstance(val, dict):
106
+ keys = sorted_pairs(val.keys(), True)
107
+ itms = ["{}: {}".format(r, reproducible_repr(val[k])) for r, k in keys]
108
+ return ("{{{}}}".format(", ".join(itms)))
109
+ if isinstance(val, list):
110
+ itms = map(reproducible_repr, val)
111
+ return ("[{}]".format(", ".join(itms)))
112
+ return repr(val)
113
+
114
+
115
+ class AttributeAccessTracerHelper:
116
+
117
+ def __init__(self, delegate, prefix=" ", reads=True):
118
+ r"""
119
+ Helper to print proxied access to attributes.
120
+
121
+ This class does the actual printing of access traces
122
+ for objects proxied by :class:`AttributeAccessTracerProxy`.
123
+ The fact that it's not a proxy at the same time
124
+ helps avoiding complicated attribute access syntax.
125
+
126
+ INPUT:
127
+
128
+ - ``delegate`` -- the actual object to be proxied
129
+
130
+ - ``prefix`` -- (default: ``" "``) string to prepend to each printed output
131
+
132
+ - ``reads`` -- (default: ``True``) whether to trace read access as well
133
+
134
+ EXAMPLES::
135
+
136
+ sage: class Foo():
137
+ ....: def f(self, *args):
138
+ ....: return self.x*self.x
139
+ ....:
140
+ sage: foo = Foo()
141
+ sage: from sage.doctest.fixtures import AttributeAccessTracerHelper
142
+ sage: pat = AttributeAccessTracerHelper(foo)
143
+ sage: pat.set("x", 2)
144
+ write x = 2
145
+ sage: pat.get("x")
146
+ read x = 2
147
+ 2
148
+ sage: pat.get("f")(3)
149
+ call f(3) -> 4
150
+ 4
151
+ """
152
+ self.delegate = delegate
153
+ self.prefix = prefix
154
+ self.reads = reads
155
+
156
+ def get(self, name):
157
+ r"""
158
+ Read an attribute from the wrapped delegate object.
159
+
160
+ If that value is a method (i.e. a callable object which is not
161
+ contained in the dictionary of the object itself but instead
162
+ inherited from some class) then it is replaced by a wrapper
163
+ function to report arguments and return value.
164
+ Otherwise an attribute read access is reported.
165
+
166
+ EXAMPLES::
167
+
168
+ sage: class Foo():
169
+ ....: def f(self, *args):
170
+ ....: return self.x*self.x
171
+ ....:
172
+ sage: foo = Foo()
173
+ sage: foo.x = 2
174
+ sage: from sage.doctest.fixtures import AttributeAccessTracerHelper
175
+ sage: pat = AttributeAccessTracerHelper(foo)
176
+ sage: pat.get("x")
177
+ read x = 2
178
+ 2
179
+ sage: pat.get("f")(3)
180
+ call f(3) -> 4
181
+ 4
182
+ """
183
+ val = getattr(self.delegate, name)
184
+ if callable(val) and name not in self.delegate.__dict__:
185
+ @wraps(val)
186
+ def wrapper(*args, **kwds):
187
+ arglst = [reproducible_repr(arg) for arg in args]
188
+ arglst.extend("{}={}".format(k, reproducible_repr(v))
189
+ for k, v in sorted(kwds.items()))
190
+ res = val(*args, **kwds)
191
+ print("{}call {}({}) -> {}"
192
+ .format(self.prefix, name, ", ".join(arglst),
193
+ reproducible_repr(res)))
194
+ return res
195
+ return wrapper
196
+ else:
197
+ if self.reads:
198
+ print("{}read {} = {}".format(self.prefix, name,
199
+ reproducible_repr(val)))
200
+ return val
201
+
202
+ def set(self, name, val):
203
+ r"""
204
+ Write an attribute to the wrapped delegate object.
205
+
206
+ The name and new value are also reported in the output.
207
+
208
+ EXAMPLES::
209
+
210
+ sage: class Foo():
211
+ ....: pass
212
+ ....:
213
+ sage: foo = Foo()
214
+ sage: from sage.doctest.fixtures import AttributeAccessTracerHelper
215
+ sage: pat = AttributeAccessTracerHelper(foo)
216
+ sage: pat.set("x", 2)
217
+ write x = 2
218
+ sage: foo.x
219
+ 2
220
+ """
221
+ print("{}write {} = {}".format(self.prefix, name,
222
+ reproducible_repr(val)))
223
+ setattr(self.delegate, name, val)
224
+
225
+
226
+ class AttributeAccessTracerProxy:
227
+
228
+ def __init__(self, delegate, **kwds):
229
+ r"""
230
+ Proxy object which prints all attribute and method access to an object.
231
+
232
+ The implementation is kept lean since all access to attributes of
233
+ the proxy itself requires complicated syntax.
234
+ For this reason, the actual handling of attribute access
235
+ is delegated to a :class:`AttributeAccessTracerHelper`.
236
+
237
+ INPUT:
238
+
239
+ - ``delegate`` -- the actual object to be proxied
240
+
241
+ - ``prefix`` -- (default: ``" "``)
242
+ string to prepend to each printed output
243
+
244
+ - ``reads`` -- (default: ``True``)
245
+ whether to trace read access as well
246
+
247
+ EXAMPLES::
248
+
249
+ sage: class Foo():
250
+ ....: def f(self, *args):
251
+ ....: return self.x*self.x
252
+ ....:
253
+ sage: foo = Foo()
254
+ sage: from sage.doctest.fixtures import AttributeAccessTracerProxy
255
+ sage: pat = AttributeAccessTracerProxy(foo)
256
+ sage: pat.x = 2
257
+ write x = 2
258
+ sage: pat.x
259
+ read x = 2
260
+ 2
261
+ sage: pat.f(3)
262
+ call f(3) -> 4
263
+ 4
264
+
265
+ .. automethod:: __getattribute__
266
+ .. automethod:: __setattr__
267
+ """
268
+ helper = AttributeAccessTracerHelper(delegate, **kwds)
269
+ object.__setattr__(self, "helper", helper)
270
+
271
+ def __getattribute__(self, name):
272
+ r"""
273
+ Read an attribute from the wrapped delegate object.
274
+
275
+ If that value is a method (i.e. a callable object which is not
276
+ contained in the dictionary of the object itself but instead
277
+ inherited from some class) then it is replaced by a wrapper
278
+ function to report arguments and return value.
279
+ Otherwise an attribute read access is reported.
280
+
281
+ EXAMPLES::
282
+
283
+ sage: class Foo():
284
+ ....: def f(self, *args):
285
+ ....: return self.x*self.x
286
+ ....:
287
+ sage: foo = Foo()
288
+ sage: foo.x = 2
289
+ sage: from sage.doctest.fixtures import AttributeAccessTracerProxy
290
+ sage: pat = AttributeAccessTracerProxy(foo)
291
+ sage: pat.x
292
+ read x = 2
293
+ 2
294
+ sage: pat.f(3)
295
+ call f(3) -> 4
296
+ 4
297
+ """
298
+ helper = object.__getattribute__(self, "helper")
299
+ return helper.get(name)
300
+
301
+ def __setattr__(self, name, val):
302
+ r"""
303
+ Write an attribute to the wrapped delegate object.
304
+
305
+ The name and new value are also reported in the output.
306
+
307
+ EXAMPLES::
308
+
309
+ sage: class Foo():
310
+ ....: pass
311
+ ....:
312
+ sage: foo = Foo()
313
+ sage: from sage.doctest.fixtures import AttributeAccessTracerProxy
314
+ sage: pat = AttributeAccessTracerProxy(foo)
315
+ sage: pat.x = 2
316
+ write x = 2
317
+ sage: foo.x
318
+ 2
319
+ """
320
+ helper = object.__getattribute__(self, "helper")
321
+ return helper.set(name, val)
322
+
323
+
324
+ def trace_method(obj, meth, **kwds):
325
+ r"""
326
+ Trace the doings of a given method.
327
+ It prints method entry with arguments,
328
+ access to members and other methods during method execution
329
+ as well as method exit with return value.
330
+
331
+ INPUT:
332
+
333
+ - ``obj`` -- the object containing the method
334
+
335
+ - ``meth`` -- the name of the method to be traced
336
+
337
+ - ``prefix`` -- (default: ``" "``)
338
+ string to prepend to each printed output
339
+
340
+ - ``reads`` -- (default: ``True``)
341
+ whether to trace read access as well
342
+
343
+ EXAMPLES::
344
+
345
+ sage: class Foo():
346
+ ....: def f(self, arg=None):
347
+ ....: self.y = self.g(self.x)
348
+ ....: if arg: return arg*arg
349
+ ....: def g(self, arg):
350
+ ....: return arg + 1
351
+ ....:
352
+ sage: foo = Foo()
353
+ sage: foo.x = 3
354
+ sage: from sage.doctest.fixtures import trace_method
355
+ sage: trace_method(foo, "f")
356
+ sage: foo.f()
357
+ enter f()
358
+ read x = 3
359
+ call g(3) -> 4
360
+ write y = 4
361
+ exit f -> None
362
+ sage: foo.f(3)
363
+ enter f(3)
364
+ read x = 3
365
+ call g(3) -> 4
366
+ write y = 4
367
+ exit f -> 9
368
+ 9
369
+ """
370
+ from sage.cpython.getattr import raw_getattr
371
+ f = raw_getattr(obj, meth)
372
+ t = AttributeAccessTracerProxy(obj, **kwds)
373
+
374
+ @wraps(f)
375
+ def g(*args, **kwds):
376
+ arglst = [reproducible_repr(arg) for arg in args]
377
+ arglst.extend("{}={}".format(k, reproducible_repr(v))
378
+ for k, v in sorted(kwds.items()))
379
+ print("enter {}({})".format(meth, ", ".join(arglst)))
380
+ res = f(t, *args, **kwds)
381
+ print("exit {} -> {}".format(meth, reproducible_repr(res)))
382
+ return res
383
+ setattr(obj, meth, g)