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,27 @@
1
+ # sage_setup: distribution = sagemath-repl
2
+ r"""
3
+ Ensure that ``functools.partial`` is correctly handled by
4
+ :func:`~sage.misc.sageinspect.sage_getsourcelines`.
5
+ """
6
+ from functools import partial
7
+
8
+
9
+ def base(x):
10
+ """
11
+ Test function to make sure
12
+ :func:`~sage.misc.sageinspect.sage_getsourcelines` can get
13
+ the code of a function created by ``functools.partial``.
14
+
15
+ EXAMPLES::
16
+
17
+ sage: from sage.tests.functools_partial_src import base, test_func
18
+ sage: base(3)
19
+ 21
20
+ sage: test_func()
21
+ 42
22
+ """
23
+ x = x * 7
24
+ return x
25
+
26
+
27
+ test_func = partial(base, 6)
@@ -0,0 +1,218 @@
1
+ # sage_setup: distribution = sagemath-repl
2
+ # sage.doctest: needs sage.symbolic
3
+ """
4
+ Some tests about Gosper sums.
5
+
6
+ References
7
+ ==========
8
+
9
+ - [PWZ1997]_
10
+
11
+ TESTS::
12
+
13
+ sage: _ = var('a b k m n r')
14
+ sage: SR(1).gosper_sum(k)
15
+ k
16
+ sage: SR(1).gosper_sum(k,0,n)
17
+ n + 1
18
+ sage: SR(1).gosper_sum(k, a, b)
19
+ -a + b + 1
20
+ sage: a.gosper_sum(k)
21
+ a*k
22
+ sage: a.gosper_sum(k,0,n)
23
+ a*(n + 1)
24
+ sage: a.gosper_sum(k,a,b)
25
+ -(a - b - 1)*a
26
+ sage: k.gosper_sum(k)
27
+ 1/2*(k - 1)*k
28
+ sage: k.gosper_sum(k,0,n)
29
+ 1/2*(n + 1)*n
30
+ sage: k.gosper_sum(k, a, b)
31
+ -1/2*(a + b)*(a - b - 1)
32
+ sage: k.gosper_sum(k, a+1, b)
33
+ -1/2*(a + b + 1)*(a - b)
34
+ sage: k.gosper_sum(k, a, b+1)
35
+ -1/2*(a + b + 1)*(a - b - 2)
36
+ sage: (k^3).gosper_sum(k)
37
+ 1/4*(k - 1)^2*k^2
38
+ sage: (k^3).gosper_sum(k, a, b)
39
+ -1/4*(a^2 + b^2 - a + b)*(a + b)*(a - b - 1)
40
+
41
+ sage: (1/k).gosper_sum(k)
42
+ Traceback (most recent call last):
43
+ ...
44
+ ValueError: expression not Gosper-summable
45
+ sage: x = (1/k/(k+1)/(k+2)/(k+3)/(k+5)/(k+7)).gosper_sum(k,a,b)
46
+ sage: y = sum(1/k/(k+1)/(k+2)/(k+3)/(k+5)/(k+7) for k in range(5,500))
47
+ sage: assert x.subs(a==5,b==499) == y
48
+
49
+ The following are from A==B, p.78 ff. Since the resulting expressions
50
+ get more and more complicated with many correct representations that
51
+ may differ depending on future capabilities, we check correctness by
52
+ doing random summations::
53
+
54
+ sage: def check(ex, var, val1, val2from, val2to):
55
+ ....: import random
56
+ ....: symb = SR.var('symb')
57
+ ....: s1 = ex.gosper_sum(var, val1, symb)
58
+ ....: R = random.SystemRandom
59
+ ....: val2 = R().randint(val2from, val2to)
60
+ ....: s2 = sum(ex.subs(var==i) for i in range(val1, val2+1))
61
+ ....: assert s1.subs(symb==val2) == s2
62
+
63
+ sage: def check_unsolvable(ex, *args):
64
+ ....: try:
65
+ ....: SR(ex).gosper_sum(*args)
66
+ ....: raise AssertionError
67
+ ....: except ValueError:
68
+ ....: pass
69
+
70
+ sage: check((4*n+1) * factorial(n)/factorial(2*n+1), n, 0, 10, 20)
71
+ sage: check_unsolvable(factorial(k), k,0,n)
72
+ sage: (k * factorial(k)).gosper_sum(k,1,n)
73
+ n*factorial(n) + factorial(n) - 1
74
+ sage: (k * factorial(k)).gosper_sum(k)
75
+ factorial(k)
76
+ sage: check_unsolvable(binomial(n,k), k,0,n)
77
+ sage: ((-1)^k*binomial(n,k)).gosper_sum(k,0,n)
78
+ 0
79
+ sage: ((-1)^k*binomial(n,k)).gosper_sum(k,0,a)
80
+ -(-1)^a*(a - n)*binomial(n, a)/n
81
+ sage: (binomial(1/2,a-k+1)*binomial(1/2,a+k)).gosper_sum(k,1,b)
82
+ (2*a + 2*b - 1)*(a - b + 1)*b*binomial(1/2, a + b)*binomial(1/2, a - b + 1)/((2*a + 1)*a)
83
+ sage: t = (binomial(2*k,k)/4^k).gosper_sum(k,0,n); t
84
+ (2*n + 1)*binomial(2*n, n)/4^n
85
+ sage: t = t.gosper_sum(n,0,n); t
86
+ 1/3*(2*n + 3)*(2*n + 1)*binomial(2*n, n)/4^n
87
+ sage: t = t.gosper_sum(n,0,n); t
88
+ 1/15*(2*n + 5)*(2*n + 3)*(2*n + 1)*binomial(2*n, n)/4^n
89
+ sage: t = t.gosper_sum(n,0,n); t
90
+ 1/105*(2*n + 7)*(2*n + 5)*(2*n + 3)*(2*n + 1)*binomial(2*n, n)/4^n
91
+ sage: (binomial(2*k+2*a,2*a)*binomial(2*k,k)/binomial(k+a,a)/4^k).gosper_sum(k,0,n)
92
+ (2*a + 2*n + 1)*binomial(2*a + 2*n, 2*a)*binomial(2*n, n)/(4^n*(2*a + 1)*binomial(a + n, a))
93
+ sage: (4^k/binomial(2*k,k)).gosper_sum(k,0,n)
94
+ 1/3*(2*4^n*n + 2*4^n + binomial(2*n, n))/binomial(2*n, n)
95
+
96
+ # The following are from A==B, 5.7 Exercises
97
+ sage: for k in range(1,5): (n^k).gosper_sum(n,0,m)
98
+ 1/2*(m + 1)*m
99
+ 1/6*(2*m + 1)*(m + 1)*m
100
+ 1/4*(m + 1)^2*m^2
101
+ 1/30*(3*m^2 + 3*m - 1)*(2*m + 1)*(m + 1)*m
102
+ sage: for k in range(1,4): (n^k*2^n).gosper_sum(n,0,m)
103
+ 2*2^m*m - 2*2^m + 2
104
+ 2*2^m*m^2 - 4*2^m*m + 6*2^m - 6
105
+ 2*2^m*m^3 - 6*2^m*m^2 + 18*2^m*m - 26*2^m + 26
106
+ sage: (1 / (n^2 + sqrt(5)*n - 1)).gosper_sum(n,0,m) # known bug
107
+ ....: # TODO: algebraic solutions
108
+ sage: check((n^4 * 4^n / binomial(2*n, n)), n, 0, 10, 20)
109
+ sage: check((factorial(3*n) / (factorial(n) * factorial(n+1) * factorial(n+2) * 27^n)), n,0,10,20)
110
+ sage: (binomial(2*n, n)^2 / (n+1) / 4^(2*n)).gosper_sum(n,0,m)
111
+ (2*m + 1)^2*binomial(2*m, m)^2/(4^(2*m)*(m + 1))
112
+ sage: (((4*n-1) * binomial(2*n, n)^2) / (2*n-1)^2 / 4^(2*n)).gosper_sum(n,0,m)
113
+ -binomial(2*m, m)^2/4^(2*m)
114
+ sage: check(n * factorial(n-1/2)^2 / factorial(n+1)^2, n,0,10,20)
115
+
116
+ sage: (n^2 * a^n).gosper_sum(n,0,m)
117
+ (a^2*a^m*m^2 - 2*a*a^m*m^2 - 2*a*a^m*m + a^m*m^2 + a*a^m + 2*a^m*m + a^m - a - 1)*a/(a - 1)^3
118
+ sage: ((n - r/2)*binomial(r, n)).gosper_sum(n,0,m)
119
+ 1/2*(m - r)*binomial(r, m)
120
+ sage: x = var('x')
121
+ sage: (factorial(n-1)^2 / factorial(n-x) / factorial(n+x)).gosper_sum(n,1,m)
122
+ (m^2*factorial(m - 1)^2*factorial(x + 1)*factorial(-x + 1) + x^2*factorial(m + x)*factorial(m - x) - factorial(m + x)*factorial(m - x))/(x^2*factorial(m + x)*factorial(m - x)*factorial(x + 1)*factorial(-x + 1))
123
+ sage: ((n*(n+a+b)*a^n*b^n)/factorial(n+a)/factorial(n+b)).gosper_sum(n,1,m).simplify_full() # long time
124
+ -(a^(m + 1)*b^(m + 1)*factorial(a - 1)*factorial(b - 1) - factorial(a + m)*factorial(b + m))/(factorial(a + m)*factorial(a - 1)*factorial(b + m)*factorial(b - 1))
125
+
126
+ sage: check_unsolvable(1/n, n,1,m)
127
+ sage: check_unsolvable(1/n^2, n,1,m)
128
+ sage: check_unsolvable(1/n^3, n,1,m)
129
+ sage: ((6*n + 3) / (4*n^4 + 8*n^3 + 8*n^2 + 4*n + 3)).gosper_sum(n,1,m)
130
+ (m + 2)*m/(2*m^2 + 4*m + 3)
131
+ sage: (2^n * (n^2 - 2*n - 1)/(n^2 * (n+1)^2)).gosper_sum(n,1,m)
132
+ -2*(m^2 - 2^m + 2*m + 1)/(m + 1)^2
133
+ sage: ((4^n * n^2)/((n+2) * (n+1))).gosper_sum(n,1,m)
134
+ 2/3*(2*4^m*m - 2*4^m + m + 2)/(m + 2)
135
+ sage: check_unsolvable(2^n / (n+1), n,0,m-1)
136
+ sage: check((4*(1-n) * (n^2-2*n-1) / n^2 / (n+1)^2 / (n-2)^2 / (n-3)^2), n, 4, 10, 20)
137
+ sage: check(((n^4-14*n^2-24*n-9) * 2^n / n^2 / (n+1)^2 / (n+2)^2 / (n+3)^2), n, 1, 10, 20)
138
+
139
+ Exercises 3 (h), (i), (j) require symbolic product support so we leave
140
+ them out for now.
141
+
142
+ ::
143
+
144
+ sage: _ = var('a b k m n r')
145
+ sage: check_unsolvable(binomial(2*n, n) * a^n, n)
146
+ sage: (binomial(2*n,n)*(1/4)^n).gosper_sum(n)
147
+ 2*(1/4)^n*n*binomial(2*n, n)
148
+ sage: ((k-1) / factorial(k)).gosper_sum(k)
149
+ -k/factorial(k)
150
+ sage: F(n, k) = binomial(n, k) / 2^n
151
+ sage: check_unsolvable(F(n, k), k)
152
+ sage: _ = (F(n+1,k)-F(n,k)).gosper_term(k)
153
+ sage: F(n,k).WZ_certificate(n,k)
154
+ 1/2*k/(k - n - 1)
155
+ sage: F(n, k) = binomial(n, k)^2 / binomial(2*n, n)
156
+ sage: check_unsolvable(F(n, k), k)
157
+ sage: _ =(F(n+1, k) - F(n, k)).gosper_term(k)
158
+ sage: F(n,k).WZ_certificate(n,k)
159
+ 1/2*(2*k - 3*n - 3)*k^2/((k - n - 1)^2*(2*n + 1))
160
+ sage: F(n, k) = binomial(n,k) * factorial(n) / factorial(k) / factorial(a-k) / factorial(a+n)
161
+ sage: check_unsolvable(F(n, k), k)
162
+ sage: _ = (F(n+1, k) - F(n, k)).gosper_term(k)
163
+ sage: F(n,k).WZ_certificate(n,k)
164
+ k^2/((a + n + 1)*(k - n - 1))
165
+
166
+ sage: (1/n/(n+1)/(n+2)/(n+5)).gosper_sum(n)
167
+ 1/720*(55*n^5 + 550*n^4 + 1925*n^3 + 2510*n^2 - 1728)/((n + 4)*(n + 3)*(n + 2)*(n + 1)*n)
168
+ sage: (1/n/(n+1)/(n+2)/(n+7)).gosper_sum(n)
169
+ 1/1050*(91*n^7 + 1911*n^6 + 15925*n^5 + 66535*n^4 + 142534*n^3 + 132104*n^2 - 54000)/((n + 6)*(n + 5)*(n + 4)*(n + 3)*(n + 2)*(n + 1)*n)
170
+ sage: (1/n/(n+1)/(n+2)/(n+5)/(n+7)).gosper_sum(n)
171
+ 1/10080*(133*n^7 + 2793*n^6 + 23275*n^5 + 97755*n^4 + 213472*n^3 + 206892*n^2 - 103680)/((n + 6)*(n + 5)*(n + 4)*(n + 3)*(n + 2)*(n + 1)*n)
172
+
173
+ The following are from A=B, 7.2 WZ Proofs of the hypergeometric database::
174
+
175
+ sage: _ = var('a b c i j k m n r')
176
+ sage: F(n,k) = factorial(n+k)*factorial(b+k)*factorial(c-n-1)*factorial(c-b-1)/factorial(c+k)/factorial(n-1)/factorial(c-n-b-1)/factorial(k+1)/factorial(b-1)
177
+ sage: F(n,k).WZ_certificate(n,k)
178
+ -(c + k)*(k + 1)/((c - n - 1)*n)
179
+ sage: F(n,k)=(-1)^(n+k)*factorial(2*n+c-1)*factorial(n)*factorial(n+c-1)/factorial(2*n+c-1-k)/factorial(2*n-k)/factorial(c+k-1)/factorial(k)
180
+ sage: F(n,k).WZ_certificate(n,k)
181
+ 1/2*(c^2 - 2*c*k + k^2 + 7*c*n - 6*k*n + 10*n^2 + 4*c - 3*k + 10*n + 2)*(c + k - 1)*k/((c - k + 2*n + 1)*(c - k + 2*n)*(k - 2*n - 1)*(k - 2*n - 2))
182
+ sage: F(n,k)=factorial(a+k-1)*factorial(b+k-1)*factorial(n)*factorial(n+c-b-a-k-1)*factorial(n+c-1)/factorial(k)/factorial(n-k)/factorial(k+c-1)/factorial(n+c-a-1)/factorial(n+c-b-1)
183
+ sage: F(n,k).WZ_certificate(n,k)
184
+ -(a + b - c + k - n)*(c + k - 1)*k/((a - c - n)*(b - c - n)*(k - n - 1))
185
+ sage: F(n,k)=(-1)^k*binomial(n+b,n+k)*binomial(n+c,c+k)*binomial(b+c,b+k)/factorial(n+b+c)*factorial(n)*factorial(b)*factorial(c)
186
+ sage: F(n,k).WZ_certificate(n,k)
187
+ 1/2*(b + k)*(c + k)/((b + c + n + 1)*(k - n - 1))
188
+ sage: phi(t) = factorial(a+t-1)*factorial(b+t-1)/factorial(t)/factorial(-1/2+a+b+t)
189
+ sage: psi(t) = factorial(t+a+b-1/2)*factorial(t)*factorial(t+2*a+2*b-1)/factorial(t+2*a-1)/factorial(t+a+b-1)/factorial(t+2*b-1)
190
+ sage: F(n,k) = phi(k)*phi(n-k)*psi(n)
191
+ sage: F(n,k).WZ_certificate(n,k)
192
+ (2*a + 2*b + 2*k - 1)*(2*a + 2*b - 2*k + 3*n + 2)*(a - k + n)*(b - k + n)*k/((2*a + 2*b - 2*k + 2*n + 1)*(2*a + n)*(a + b + n)*(2*b + n)*(k - n - 1))
193
+
194
+ The following are also from A=B, 7 The WZ Phenomenon::
195
+
196
+ sage: F(n,k) = factorial(n-i)*factorial(n-j)*factorial(i-1)*factorial(j-1)/factorial(n-1)/factorial(k-1)/factorial(n-i-j+k)/factorial(i-k)/factorial(j-k)
197
+ sage: F(n,k).WZ_certificate(n,k)
198
+ (k - 1)/n
199
+ sage: F(n,k) = binomial(3*n,k)/8^n
200
+ sage: F(n,k).WZ_certificate(n,k)
201
+ 1/8*(4*k^2 - 30*k*n + 63*n^2 - 22*k + 93*n + 32)*k/((k - 3*n - 1)*(k - 3*n - 2)*(k - 3*n - 3))
202
+
203
+ Example 7.5.1 gets a different but correct certificate (the certificate
204
+ in the book fails the proof)::
205
+
206
+ sage: F(n,k) = 2^(k+1)*(k+1)*factorial(2*n-k-2)*factorial(n)/factorial(n-k-1)/factorial(2*n)
207
+ sage: c = F(n,k).WZ_certificate(n,k); c
208
+ -1/2*(k - 2*n + 1)*k/((k - n)*(2*n + 1))
209
+ sage: G(n,k) = c*F(n,k)
210
+ sage: t = (F(n+1,k) - F(n,k) - G(n,k+1) + G(n,k))
211
+ sage: t.simplify_full().is_trivial_zero() # long time
212
+ True
213
+ sage: c = k/2/(-1+k-n)
214
+ sage: GG(n,k) = c*F(n,k)
215
+ sage: t = (F(n+1,k) - F(n,k) - GG(n,k+1) + GG(n,k))
216
+ sage: t.simplify_full().is_trivial_zero() # long time
217
+ False
218
+ """
@@ -0,0 +1,28 @@
1
+ # sage_setup: distribution = sagemath-repl
2
+ # sage.doctest: needs sage.all
3
+ r"""
4
+ TESTS:
5
+
6
+ Check that all non deprecated lazy imports resolve correctly. We avoid libgiac
7
+ on purpose because it does print stuff, see :issue:`31655`.::
8
+
9
+ sage: from sage.misc.lazy_import import LazyImport
10
+ sage: G = globals()
11
+ sage: for name, obj in sorted(G.items()):
12
+ ....: if name == 'libgiac':
13
+ ....: continue
14
+ ....: if type(obj) is LazyImport and obj._get_deprecation_issue() == 0:
15
+ ....: try:
16
+ ....: _ = obj._get_object()
17
+ ....: except Exception as e:
18
+ ....: print('{} does not resolve: {}'.format(name, e))
19
+
20
+ Check that all deprecated lazy imports resolve correctly::
21
+
22
+ sage: import warnings
23
+ sage: for name, obj in sorted(G.items()):
24
+ ....: if type(obj) is LazyImport and obj._get_deprecation_issue() != 0:
25
+ ....: with warnings.catch_warnings(record=True) as w:
26
+ ....: _ = obj._get_object()
27
+ ....: assert w[0].category == DeprecationWarning
28
+ """
@@ -0,0 +1,80 @@
1
+ # sage_setup: distribution = sagemath-repl
2
+ # sage.doctest: optional - p_group_cohomology
3
+ r"""
4
+ Tests for the optional ``p_group_cohomology`` package.
5
+
6
+ AUTHOR:
7
+
8
+ - Simon King
9
+
10
+ TESTS::
11
+
12
+ sage: from pGroupCohomology import CohomologyRing
13
+
14
+ Computation of a modular cohomology ring of a prime power group in
15
+ characteristic 2, and comparison with stored result in a database::
16
+
17
+ sage: CohomologyRing.set_workspace(tmp_dir())
18
+ sage: H = CohomologyRing(64,14,from_scratch=True)
19
+ sage: H.make()
20
+ sage: CohomologyRing.set_workspace(tmp_dir())
21
+ sage: H0 = CohomologyRing(64,14)
22
+ sage: H.is_isomorphic(H0)
23
+ ('1*a_2_1', '1*c_2_2', '1*c_4_4', '1*a_1_0', '1*a_1_1', '1*a_3_3')
24
+
25
+ Computation of a modular cohomology ring of a prime power group in odd
26
+ characteristic, and some algebraic constructions in the cohomology
27
+ ring::
28
+
29
+ sage: H = CohomologyRing(27,4)
30
+ sage: H.make()
31
+ sage: print(H)
32
+ <BLANKLINE>
33
+ Cohomology ring of Extraspecial 3-group of order 27
34
+ and exponent 9 with coefficients in GF(3)
35
+ <BLANKLINE>
36
+ Computation complete
37
+ Minimal list of generators:
38
+ [b_2_1: 2-Cocycle in H^*(M27; GF(3)),
39
+ c_6_2: 6-Cocycle in H^*(M27; GF(3)),
40
+ a_1_0: 1-Cocycle in H^*(M27; GF(3)),
41
+ a_1_1: 1-Cocycle in H^*(M27; GF(3)),
42
+ a_3_1: 3-Cocycle in H^*(M27; GF(3)),
43
+ a_5_1: 5-Cocycle in H^*(M27; GF(3))]
44
+ Minimal list of algebraic relations:
45
+ [b_2_1*a_1_0,
46
+ a_1_0*a_3_1,
47
+ b_2_1*a_3_1,
48
+ a_1_0*a_5_1,
49
+ a_3_1*a_5_1]
50
+ sage: H.5.massey_power()
51
+ <a_3_1; 1>: 8-Cocycle in H^*(M27; GF(3))
52
+ sage: H.5.massey_power().as_polynomial()
53
+ '-c_6_2*a_1_0*a_1_1'
54
+ sage: H.essential_ideal()
55
+ a_1_0*a_1_1,
56
+ a_1_1*a_3_1
57
+ sage: ascii_art(H.bar_code('LowerCentralSeries')[2]) # known bug
58
+ *
59
+ *-*
60
+ *-*
61
+ *
62
+
63
+ Computation of a modular cohomology ring of a non prime power group in
64
+ characteristic 2::
65
+
66
+ sage: H = CohomologyRing(libgap.AlternatingGroup(6),
67
+ ....: GroupName='A(6)', prime=2,
68
+ ....: from_scratch=True)
69
+ sage: H.make()
70
+ sage: print(H)
71
+ Cohomology ring of A(6) with coefficients in GF(2)
72
+ <BLANKLINE>
73
+ Computation complete
74
+ Minimal list of generators:
75
+ [c_2_0: 2-Cocycle in H^*(A(6); GF(2)),
76
+ b_3_0: 3-Cocycle in H^*(A(6); GF(2)),
77
+ b_3_1: 3-Cocycle in H^*(A(6); GF(2))]
78
+ Minimal list of algebraic relations:
79
+ [b_3_0*b_3_1]
80
+ """
sage/tests/numpy.py ADDED
@@ -0,0 +1,21 @@
1
+ # sage_setup: distribution = sagemath-repl
2
+ # sage.doctest: needs numpy
3
+ r"""
4
+ TESTS:
5
+
6
+ Sage integers can index NumPy matrices (see :issue:`10928`)::
7
+
8
+ sage: import numpy as np
9
+ sage: m = np.matrix(np.arange(4).reshape(2, 2))
10
+ sage: a = m[:, int(0)]
11
+ sage: b = m[:, Integer(0)]
12
+ sage: a.shape, b.shape
13
+ ((2, 1), (2, 1))
14
+ sage: print('{}\n{}\n{}'.format(m, a, b))
15
+ [[0 1]
16
+ [2 3]]
17
+ [[0]
18
+ [2]]
19
+ [[0]
20
+ [2]]
21
+ """
sage/tests/parigp.py ADDED
@@ -0,0 +1,76 @@
1
+ # sage_setup: distribution = sagemath-repl
2
+ # sage.doctest: needs sage.libs.pari sage.modules
3
+ r"""
4
+ This file is meant to catch errors in the PARI/GP package which are not
5
+ caught by any other tests.
6
+
7
+ Check that :issue:`9876` has been fixed, this test comes from PARI's
8
+ self-test :pari:`rnfkummer` but was modified such that the answer is
9
+ canonical::
10
+
11
+ sage: pari('K = bnfinit(y^4-52*y^2+26,1); pol = rnfkummer(bnrinit(K,3,1),Mat(5)); L = rnfinit(K, [pol, 10^6]); polredabs(polredbest(L.polabs))') # long time
12
+ x^20 - 112*x^18 + 5108*x^16 - 123460*x^14 + 1724337*x^12 - 14266996*x^10 + 69192270*x^8 - 188583712*x^6 + 260329852*x^4 - 141461008*x^2 + 19860776
13
+
14
+ Check that :issue:`10195` (PARI bug 1153) has been fixed::
15
+
16
+ sage: print(gp.eval("mathnf([0,0,0,0,0,0,0,0,0,13;0,0,0,0,0,0,0,0,23,6;0,0,0,0,0,0,0,23,-4,-7;0,0,0,0,0,0,17,-3,5,-5;0,0,0,0,0,56,16,-16,-15,-17;0,0,0,0,57,24,-16,-25,2,-21;0,0,0,114,9,56,51,-52,25,-55;0,0,113,-31,-11,24,0,28,34,-16;0,50,3,2,16,-6,-2,7,-19,-21;118,43,51,23,37,-52,18,38,51,28],0)"))
17
+ [787850171872400 32189386376004 356588299060422 742392731867995 282253457851430 665185047494955 664535243562463 744564809133574 113975061998590 527459013372200]
18
+ [0 12 6 11 5 3 7 6 6 0]
19
+ [0 0 3 1 2 1 1 0 0 0]
20
+ [0 0 0 1 0 0 0 0 0 0]
21
+ [0 0 0 0 1 0 0 0 0 0]
22
+ [0 0 0 0 0 1 0 0 0 0]
23
+ [0 0 0 0 0 0 1 0 0 0]
24
+ [0 0 0 0 0 0 0 1 0 0]
25
+ [0 0 0 0 0 0 0 0 1 0]
26
+ [0 0 0 0 0 0 0 0 0 1]
27
+
28
+ Check that :issue:`11604` (PARI bug 1154) has been fixed::
29
+
30
+ sage: A = Matrix(ZZ,4,4,[32982266684193100, 1368614777139719, 224591013270052693, 276460184982223238,1368614777139719, 56791380087354, 9319512049770279, 11471848267545007,224591013270052693, 9319512049770279,1529340971891522140, 1882541434053596358,276460184982223238, 11471848267545007, 1882541434053596358, 2317313350044091414])
31
+ sage: pari(A).qfminim(2,0)
32
+ [0, 0, [;]]
33
+
34
+ Check :issue:`13314`, the following should not give a
35
+ Segmentation Fault::
36
+
37
+ sage: x = polygen(ComplexField(128))
38
+ sage: p = x^84 + (16*x^4 - 1)^20 * (2^48*x^4 - 2049^4)
39
+ sage: len(pari(p).polroots(precision=128))
40
+ 84
41
+
42
+ Check that the optional PARI databases work::
43
+
44
+ sage: # optional - pari_elldata
45
+ sage: gp.ellinit('"299998a1"')
46
+ [1, 0, 1, 110, -3660, ...]
47
+ sage: E = EllipticCurve("1728ba1") # needs sage.schemes
48
+ sage: gp(E).ellidentify() # needs sage.schemes
49
+ [["1728ba1", [0, 0, 0, -6, 6], [[1, 1]]], [1, 0, 0, 0]]
50
+
51
+ sage: pari("ellmodulareqn(211)") # optional - pari_seadata
52
+ [x^212 + (-y^7 + 5207*y^6 - 10241606*y^5 + 9430560101*y^4 - 4074860204015*y^3
53
+ + 718868274900397*y^2 - 34897101275826114*y + 104096378056356968)*x^211...
54
+
55
+ The following requires the modular polynomials up to degree 223, while
56
+ only those up to degree 199 come standard in Sage::
57
+
58
+ sage: p = next_prime(2^328)
59
+ sage: E = EllipticCurve(GF(p), [6,1]) # needs sage.schemes
60
+ sage: E.cardinality() # long time (108s on sage.math, 2013), optional - pari_seadata, needs sage.schemes
61
+ 546812681195752981093125556779405341338292357723293496548601032930284335897180749997402596957976244
62
+
63
+ Create a number field with Galois group `A4`. Group `A4` corresponds to
64
+ transitive group `(12,3)` in GAP::
65
+
66
+ sage: # optional - pari_galpol
67
+ sage: R.<x> = PolynomialRing(ZZ)
68
+ sage: pol = pari("galoisgetpol(12,3)[1]")
69
+ sage: K.<a> = NumberField(R(pol))
70
+ sage: factor(K.discriminant())
71
+ 163^8
72
+ sage: [F.degree() for F,a,b in K.subfields()]
73
+ [1, 3, 4, 4, 4, 4, 6, 6, 6, 12]
74
+ sage: sorted([12/H.cardinality() for H in AlternatingGroup(4).subgroups()])
75
+ [1, 3, 4, 4, 4, 4, 6, 6, 6, 12]
76
+ """
sage/tests/startup.py ADDED
@@ -0,0 +1,27 @@
1
+ # sage_setup: distribution = sagemath-repl
2
+ r"""
3
+ Ensure that certain modules are not loaded on startup.
4
+
5
+ Check that IPython is not imported at startup (:issue:`18726`). It is
6
+ imported by the doctest framework, so the simple test like above would
7
+ not work. Instead, we test this by starting a new Python process::
8
+
9
+ sage: from sage.tests.cmdline import test_executable
10
+ sage: environment = "sage.all"
11
+ sage: cmd = f"from {environment} import *\nprint('IPython' in sys.modules)\n"
12
+ sage: print(test_executable(["sage", "--python"], cmd)[0]) # long time
13
+ False
14
+
15
+ Check that numpy (:issue:`11714`) and pyparsing are not imported on startup
16
+ as they increase the startup time. Since :issue:`23696` those are imported
17
+ by the doctest framework via a matplotlib import. Again the simple test
18
+ would not work (but we don't have to avoid loading IPython)::
19
+
20
+ sage: from sage.tests.cmdline import test_executable
21
+ sage: cmd = "print('numpy' in sys.modules)\n"
22
+ sage: print(test_executable(["sage", "-c", cmd])[0]) # long time
23
+ False
24
+ sage: cmd = "print('pyparsing' in sys.modules)\n"
25
+ sage: print(test_executable(["sage", "-c", cmd])[0]) # long time
26
+ False
27
+ """
@@ -0,0 +1,76 @@
1
+ # sage_setup: distribution = sagemath-repl
2
+ # sage.doctest: needs sage.symbolic
3
+ """
4
+ Tests for the fast univariate series expansion in Pynac
5
+ -------------------------------------------------------
6
+
7
+ This is a transcription of part of a testsuite that was
8
+ originally written for Symengine. Instead of matching
9
+ the first few terms of the expansion we pick specific
10
+ coefficients and compare to known values.
11
+
12
+ AUTHORS
13
+ -------
14
+ (c) 2016 Ralf Stephan <ralf@ark.in-berlin.de>
15
+
16
+ See https://github.com/symengine/symengine/blob/master/symengine/tests/basic/
17
+
18
+ TESTS::
19
+
20
+ sage: def test(ex, coeff, value):
21
+ ....: assert(ex.series(x, coeff+3).coefficient(x,coeff) == value)
22
+
23
+ sage: test(sin(x), 9, 1/362880)
24
+ sage: test(sin(x)+cos(x), 8, 1/40320)
25
+ sage: test(sin(x)*cos(x), 11, -4/155925)
26
+ sage: test(sin(atan(x)), 27, -1300075/8388608)
27
+ sage: test(cos(x/(1-x)), 11, -125929/362880)
28
+ sage: test(1/(1-x), 99, 1)
29
+ sage: test(x/(1-x-x^2), 35, 9227465)
30
+ sage: test(x^3/(1-2*x^2), 49, 8388608)
31
+ sage: test(1/(1-sin(x)), 10, 1382/14175)
32
+ sage: test(1/x, -1, 1)
33
+ sage: test(1/x/(1-x), 0, 1)
34
+ sage: test(sqrt(4-x), 6, -21/2097152)
35
+ sage: test((1-x)^(-2/3), 10, 1621477/4782969)
36
+ sage: test(sqrt(1-x), 10, -2431/262144)
37
+ sage: test(sqrt(cos(x)), 8, -559/645120)
38
+ sage: test(cos(x)^(-2/3), 10, 701/127575)
39
+ sage: test(log(1+x), 98, -1/98)
40
+ sage: test(log(cos(x)), 12, -691/935550)
41
+ sage: test(log(1/(1-x)), 48, 1/48)
42
+ sage: test(exp(x), 9, 1/362880)
43
+ sage: test(exp(log(1+x)), 0, 1)
44
+ sage: test(exp(log(1+x)), 1, 1)
45
+ sage: test(log(exp(x)), 1, 1)
46
+ sage: test(exp(sin(x)), 10, -2951/3628800)
47
+ sage: test(cos(x)^sin(x), 16, 1381/2661120)
48
+ sage: test(tan(x), 13, 21844/6081075)
49
+ sage: test(tan(x/(1-x)), 12, 1303712/14175)
50
+ sage: test(cot(x), 13, -4/18243225)
51
+ sage: test(cot(log(1+x)), 8, 4399/41472)
52
+ sage: test(sec(x), 14, 199360981/87178291200)
53
+ sage: test(sec(x*sqrt(1-x)), 11, -21463/103680)
54
+ sage: test(csc(x), 13, 8191/37362124800)
55
+ sage: test(csc(x/(1-x)), 14, 355857510913/100590336000)
56
+ sage: test(asin(x), 15, 143/10240)
57
+ sage: test(asin(x/(1-x)), 16, 1259743/2048)
58
+ sage: test(atan(x), 19, -1/19)
59
+ sage: test(atan(x/(1-x)), 33, 65536/33)
60
+ sage: test(sinh(x), 9, 1/362880)
61
+ sage: test(sinh(x/(1-x)), 10, 325249/40320)
62
+ sage: test(cosh(x), 10, 1/3628800)
63
+ sage: test(cosh(x/(1-x)), 11, 3756889/362880)
64
+ sage: test(tanh(x), 13, 21844/6081075)
65
+ sage: test(tanh(x/(1-x)), 14, 225979/66825)
66
+ sage: test(coth(x), 13, 4/18243225)
67
+ sage: test(coth(x/(1-x)), 14, -3651803/16372125)
68
+ sage: test(sech(x), 16, 3878302429/4184557977600)
69
+ sage: test(sech(x/(1-x)), 16, -34746888589811/4184557977600)
70
+ sage: test(csch(x), 13, -8191/37362124800)
71
+ sage: test(csch(x/(1-x)), 14, 2431542527/11176704000)
72
+ sage: test(atanh(x), 99, 1/99)
73
+ sage: test(atanh(x/(1-x)), 16, 2048)
74
+ sage: test(asinh(x), 15, -143/10240)
75
+ sage: test(asinh(x/(1-x)), 16, -3179/2048)
76
+ """
sage/tests/sympy.py ADDED
@@ -0,0 +1,16 @@
1
+ # sage_setup: distribution = sagemath-repl
2
+ # sage.doctest: optional - sympy
3
+ r"""
4
+ TESTS:
5
+
6
+ Checking that sympy handles correctly Sage real numbers as
7
+ coefficients of polynomials (see :issue:`24380`)::
8
+
9
+ sage: import sympy, sympy.polys
10
+ sage: x = sympy.Symbol('x')
11
+ sage: p = sympy.polys.Poly(x**2 - 2.0)
12
+ sage: p
13
+ Poly(1.0*x**2 - 2.0, x, domain='RR')
14
+ sage: p.coeffs()
15
+ [1.00000000000000, -2.00000000000000]
16
+ """
@@ -0,0 +1,31 @@
1
+ # sage_setup: distribution = sagemath-repl
2
+ """
3
+ Tests Deprecation
4
+
5
+ EXAMPLES::
6
+
7
+ sage: import sage.tests.test_deprecation
8
+ sage: sage.tests.test_deprecation.function_old()
9
+ doctest:...: DeprecationWarning: function_old is deprecated. Please
10
+ use sage.tests.test_deprecation.function_new instead.
11
+ See https://github.com/sagemath/sage/issues/12345 for details.
12
+ """
13
+ from sage.misc.superseded import deprecated_function_alias
14
+
15
+
16
+ def function_new():
17
+ """
18
+ New function, deprecating ``old_function``.
19
+
20
+ EXAMPLES::
21
+
22
+ sage: from sage.tests.test_deprecation import function_old
23
+ sage: function_old()
24
+ doctest:...: DeprecationWarning: function_old is deprecated. Please
25
+ use sage.tests.test_deprecation.function_new instead.
26
+ See https://github.com/sagemath/sage/issues/12345 for details.
27
+ """
28
+ pass
29
+
30
+
31
+ function_old = deprecated_function_alias(12345, function_new)