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,351 @@
1
+ # sage_setup: distribution = sagemath-repl
2
+ # sage.doctest: needs sage.combinat
3
+ r"""
4
+ Sage code for computing k-distant crossing numbers.
5
+
6
+ This code accompanies the article :arxiv:`0812.2725`. It is being
7
+ submitted because of a suggestion from
8
+ http://groups.google.com/group/sage-support/msg/3ea7ed2eeab0824a.
9
+
10
+ Right now, this code only computes k-dcrossings. If you are only
11
+ interested in the distribution, this is good enough because the extended
12
+ Kasraoui-Zeng involution tells us the distribution of k-dcrossings and
13
+ k-dnestings is symmetric. It would be nice, though, to have a function
14
+ which actually performed that involution.
15
+
16
+ AUTHORS:
17
+
18
+ - Dan Drake (2008-12-15): initial version.
19
+
20
+ EXAMPLES:
21
+
22
+ The example given in the paper. Note that in this format, we omit fixed
23
+ points since they cannot create any sort of crossing. ::
24
+
25
+ sage: from sage.tests.arxiv_0812_2725 import *
26
+ sage: dcrossing([(1,5), (2,4), (4,9), (6,12), (7,10), (10,11)])
27
+ 3
28
+ """
29
+ #*****************************************************************************
30
+ # Copyright (C) 2008 Dan Drake <ddrake@member.ams.org>
31
+ #
32
+ # This program is free software: you can redistribute it and/or modify
33
+ # it under the terms of the GNU General Public License as published by
34
+ # the Free Software Foundation, either version 2 of the License, or (at
35
+ # your option) any later version.
36
+ #
37
+ # See https://www.gnu.org/licenses/.
38
+ #*****************************************************************************
39
+ from sage.combinat.set_partition import SetPartitions as SetPartitions
40
+
41
+
42
+ def CompleteMatchings(n):
43
+ """
44
+ Return a generator for the complete matchings of the set [1..n].
45
+
46
+ INPUT:
47
+
48
+ - ``n`` -- nonnegative integer
49
+
50
+ OUTPUT:
51
+
52
+ A generator for the complete matchings of the set [1..n], or,
53
+ what is basically the same thing, complete matchings of the
54
+ graph K_n. Each complete matching is represented by a list of
55
+ 2-element tuples.
56
+
57
+ EXAMPLES:
58
+
59
+ There are 3 complete matchings on 4 vertices::
60
+
61
+ sage: from sage.tests.arxiv_0812_2725 import *
62
+ sage: [m for m in CompleteMatchings(4)]
63
+ [[(3, 4), (1, 2)], [(2, 4), (1, 3)], [(2, 3), (1, 4)]]
64
+
65
+ There are no complete matchings on an odd number of vertices; the
66
+ number of complete matchings on an even number of vertices is a
67
+ double factorial::
68
+
69
+ sage: from sage.tests.arxiv_0812_2725 import *
70
+ sage: [len([m for m in CompleteMatchings(n)]) for n in [0..8]]
71
+ [1, 0, 1, 0, 3, 0, 15, 0, 105]
72
+
73
+ The exact behavior of CompleteMatchings(n) if n is not a nonnegative
74
+ integer depends on what [1..n] returns, and also on what range(1,
75
+ len([1..n])) is.
76
+ """
77
+ yield from matchingsset(list(range(1, n + 1)))
78
+
79
+
80
+ def matchingsset(L):
81
+ """
82
+ Return a generator for complete matchings of the sequence L.
83
+
84
+ This is not really meant to be called directly, but rather by
85
+ CompleteMatchings().
86
+
87
+ INPUT:
88
+
89
+ - ``L`` -- a sequence. Lists, tuples, et cetera; anything that
90
+ supports ``len()`` and slicing should work.
91
+
92
+ OUTPUT:
93
+
94
+ A generator for complete matchings on K_n, where n is the length
95
+ of L and vertices are labeled by elements of L. Each matching is
96
+ represented by a list of 2-element tuples.
97
+
98
+ EXAMPLES::
99
+
100
+ sage: from sage.tests.arxiv_0812_2725 import *
101
+ sage: [m for m in matchingsset(('a', 'b', 'c', 'd'))]
102
+ [[('c', 'd'), ('a', 'b')], [('b', 'd'), ('a', 'c')], [('b', 'c'), ('a', 'd')]]
103
+
104
+ There's only one matching of the empty set/list/tuple: the empty
105
+ matching. ::
106
+
107
+ sage: [m for m in matchingsset(())]
108
+ [[]]
109
+ """
110
+ if not L:
111
+ yield []
112
+ else:
113
+ for k in range(1, len(L)):
114
+ for m in matchingsset(L[1: k] + L[k + 1:]):
115
+ yield m + [(L[0], L[k])]
116
+
117
+
118
+ def dcrossing(m_):
119
+ """
120
+ Return the largest k for which the given matching or set
121
+ partition has a k-distant crossing.
122
+
123
+ INPUT:
124
+
125
+ - ``m`` -- a matching or set partition, as a list of 2-element tuples
126
+ representing the edges. You'll need to call ``setp_to_edges()`` on
127
+ the objects returned by ``SetPartitions()`` to put them into the
128
+ proper format.
129
+
130
+ OUTPUT:
131
+
132
+ The largest k for which the object has a k-distant crossing.
133
+ Matchings and set partitions with no crossings at all yield -1.
134
+
135
+ EXAMPLES:
136
+
137
+ The main example from the paper::
138
+
139
+ sage: from sage.tests.arxiv_0812_2725 import *
140
+ sage: dcrossing(setp_to_edges(Set(map(Set, [[1,5],[2,4,9],[3],[6,12],[7,10,11],[8]]))))
141
+ 3
142
+
143
+ A matching example::
144
+
145
+ sage: from sage.tests.arxiv_0812_2725 import *
146
+ sage: dcrossing([(4, 7), (3, 6), (2, 5), (1, 8)])
147
+ 2
148
+
149
+ TESTS:
150
+
151
+ The empty matching and set partition are noncrossing::
152
+
153
+ sage: dcrossing([])
154
+ -1
155
+ sage: dcrossing(Set([]))
156
+ -1
157
+
158
+ One edge::
159
+
160
+ sage: dcrossing([Set((1,2))])
161
+ -1
162
+ sage: dcrossing(Set([Set((1,2))]))
163
+ -1
164
+
165
+ Set partition with block of size >= 3 is always at least
166
+ 0-dcrossing::
167
+
168
+ sage: dcrossing(setp_to_edges(Set([Set((1,2,3))])))
169
+ 0
170
+ """
171
+ d = -1
172
+ m = list(m_)
173
+ while m:
174
+ e1_ = m.pop()
175
+ for e2_ in m:
176
+ e1, e2 = sorted(e1_), sorted(e2_)
177
+ if (e1[0] < e2[0] and e2[0] <= e1[1] and e1[1] < e2[1] and
178
+ e1[1] - e2[0] > d):
179
+ d = e1[1] - e2[0]
180
+ if (e2[0] < e1[0] and e1[0] <= e2[1] and e2[1] < e1[1] and
181
+ e2[1] - e1[0] > d):
182
+ d = e2[1] - e1[0]
183
+ return d
184
+
185
+
186
+ def setp_to_edges(p):
187
+ """
188
+ Transform a set partition into a list of edges.
189
+
190
+ INPUT:
191
+
192
+ - ``p`` -- a Sage set partition
193
+
194
+ OUTPUT:
195
+
196
+ A list of non-loop edges of the set partition. As this code just
197
+ works with crossings, we can ignore the loops.
198
+
199
+ EXAMPLES:
200
+
201
+ The main example from the paper::
202
+
203
+ sage: from sage.tests.arxiv_0812_2725 import *
204
+ sage: sorted(setp_to_edges(Set(map(Set, [[1,5],[2,4,9],[3],[6,12],[7,10,11],[8]]))))
205
+ [[1, 5], [2, 4], [4, 9], [6, 12], [7, 10], [10, 11]]
206
+ """
207
+ q = (sorted(b) for b in p)
208
+ return [b[n: n + 2] for b in q for n in range(len(b) - 1)]
209
+
210
+
211
+ def dcrossvec_setp(n):
212
+ """
213
+ Return a list with the distribution of k-dcrossings on set partitions of [1..n].
214
+
215
+ INPUT:
216
+
217
+ - ``n`` -- nonnegative integer
218
+
219
+ OUTPUT:
220
+
221
+ A list whose k'th entry is the number of set partitions p for
222
+ which dcrossing(p) = k. For example, let L = dcrossvec_setp(3).
223
+ We have L = [1, 0, 4]. L[0] is 1 because there's 1 partition of
224
+ [1..3] that has 0-dcrossing: [(1, 2, 3)].
225
+
226
+ One tricky bit is that noncrossing matchings get put at the end,
227
+ because L[-1] is the last element of the list. Above, we have
228
+ L[-1] = 4 because the other four set partitions are all
229
+ d-noncrossing. Because of this, you should not think of the last
230
+ element of the list as having index n-1, but rather -1.
231
+
232
+ EXAMPLES::
233
+
234
+ sage: from sage.tests.arxiv_0812_2725 import *
235
+ sage: dcrossvec_setp(3)
236
+ [1, 0, 4]
237
+
238
+ sage: dcrossvec_setp(4)
239
+ [5, 1, 0, 9]
240
+
241
+ The one set partition of 1 element is noncrossing, so the last
242
+ element of the list is 1::
243
+
244
+ sage: dcrossvec_setp(1)
245
+ [1]
246
+ """
247
+ vec = [0] * n
248
+ for p in SetPartitions(n):
249
+ vec[dcrossing(setp_to_edges(p))] += 1
250
+ return vec
251
+
252
+
253
+ def dcrossvec_cm(n):
254
+ """
255
+ Return a list with the distribution of k-dcrossings on complete matchings on n vertices.
256
+
257
+ INPUT:
258
+
259
+ - ``n`` -- nonnegative integer
260
+
261
+ OUTPUT:
262
+
263
+ A list whose k'th entry is the number of complete matchings m
264
+ for which dcrossing(m) = k. For example, let L =
265
+ dcrossvec_cm(4). We have L = [0, 1, 0, 2]. L[1] is 1 because
266
+ there's one matching on 4 vertices that is 1-dcrossing: [(2, 4),
267
+ (1, 3)]. L[0] is zero because dcrossing() returns the *largest*
268
+ k for which the matching has a dcrossing, and 0-dcrossing is
269
+ equivalent to 1-dcrossing for complete matchings.
270
+
271
+ One tricky bit is that noncrossing matchings get put at the end,
272
+ because L[-1] is the last element of the list. Because of this, you
273
+ should not think of the last element of the list as having index
274
+ n-1, but rather -1.
275
+
276
+ If n is negative, you get silly results. Don't use them in your
277
+ next paper. :)
278
+
279
+ EXAMPLES:
280
+
281
+ The single complete matching on 2 vertices has no crossings, so the
282
+ only nonzero entry of the list (the last entry) is 1::
283
+
284
+ sage: from sage.tests.arxiv_0812_2725 import *
285
+ sage: dcrossvec_cm(2)
286
+ [0, 1]
287
+
288
+ Similarly, the empty matching has no crossings::
289
+
290
+ sage: dcrossvec_cm(0)
291
+ [1]
292
+
293
+ For odd n, there are no complete matchings, so the list has all
294
+ zeros::
295
+
296
+ sage: dcrossvec_cm(5)
297
+ [0, 0, 0, 0, 0]
298
+
299
+ sage: dcrossvec_cm(4)
300
+ [0, 1, 0, 2]
301
+ """
302
+ vec = [0] * max(n, 1)
303
+ for m in CompleteMatchings(n):
304
+ vec[dcrossing(m)] += 1
305
+ return vec
306
+
307
+
308
+ def tablecolumn(n, k):
309
+ """
310
+ Return column n of Table 1 or 2 from the paper :arxiv:`0812.2725`.
311
+
312
+ INPUT:
313
+
314
+ - ``n`` -- positive integer
315
+
316
+ - ``k`` -- integer for which table you want: Table 1 is complete
317
+ matchings, Table 2 is set partitions
318
+
319
+ OUTPUT:
320
+
321
+ The n'th column of the table as a list. This is basically just the
322
+ partial sums of dcrossvec_{cm,setp}(n).
323
+
324
+ table2column(1, 2) incorrectly returns [], instead of [1], but you
325
+ probably don't need this function to work through n = 1.
326
+
327
+ EXAMPLES:
328
+
329
+ Complete matchings::
330
+
331
+ sage: from sage.tests.arxiv_0812_2725 import *
332
+ sage: tablecolumn(2, 1)
333
+ [1]
334
+
335
+ sage: tablecolumn(6, 1)
336
+ [5, 5, 11, 14, 15]
337
+
338
+ Set partitions::
339
+
340
+ sage: tablecolumn(5, 2)
341
+ [21, 42, 51, 52]
342
+
343
+ sage: tablecolumn(2, 2)
344
+ [2]
345
+ """
346
+ if k == 1:
347
+ v = dcrossvec_cm(n)
348
+ else:
349
+ v = dcrossvec_setp(n)
350
+ i = v[-1]
351
+ return [i + sum(v[:k]) for k in range(len(v) - 1)]