Skip to content

Commit 41976b3

Browse files
author
Release Manager
committed
Trac #32964: very slow doctest in functions.orthogonal_polys
{{{ $ sage -t --warn-long 10.0 --random- seed=80495217684824677825915603387163671014 src/sage/functions/orthogonal_polys.py ********************************************************************** File "src/sage/functions/orthogonal_polys.py", line 2084, in sage.functions.orthogonal_polys.Func_ultraspherical Warning, slow doctest: for N in range(100): n = ZZ.random_element(5, 5001) a = QQ.random_element().abs() + 5 assert ((n+1)*ultraspherical(n+1,a,x) - 2*x*(n+a)*ultraspherical(n,a,x) + (n+2*a-1)*ultraspherical(n-1,a,x)).expand().is_zero() Test ran for 261.17 s [400 tests, 273.87 s] }}} Since the test is randomized, we don't need to repeat it a hundred times. Coverage is provided more by the number of testers. And we shouldn't use `assert()` in EXAMPLES... URL: https://trac.sagemath.org/32964 Reported by: mjo Ticket author(s): Michael Orlitzky Reviewer(s): Frédéric Chapoton
2 parents 1ad688e + 9b2f042 commit 41976b3

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/sage/functions/orthogonal_polys.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -498,8 +498,7 @@ def _eval_(self, n, x):
498498
sage: chebyshev_T(5,Qp(3)(2))
499499
2 + 3^2 + 3^3 + 3^4 + 3^5 + O(3^20)
500500
sage: chebyshev_T(100001/2, 2)
501-
doctest:...: RuntimeWarning: mpmath failed, keeping expression unevaluated
502-
chebyshev_T(100001/2, 2)
501+
...chebyshev_T(100001/2, 2)
503502
sage: chebyshev_U._eval_(1.5, Mod(8,9)) is None
504503
True
505504
"""
@@ -1914,7 +1913,7 @@ class Func_hermite(GinacFunction):
19141913
...
19151914
RuntimeError: hermite_eval: The index n must be a nonnegative integer
19161915
1917-
sage: _ = var('m x')
1916+
sage: m,x = SR.var('m,x')
19181917
sage: hermite(m, x).diff(m)
19191918
Traceback (most recent call last):
19201919
...
@@ -1965,7 +1964,7 @@ def __init__(self):
19651964
19661965
EXAMPLES::
19671966
1968-
sage: _ = var('n a b x')
1967+
sage: n,a,b,x = SR.var('n,a,b,x')
19691968
sage: loads(dumps(jacobi_P))
19701969
jacobi_P
19711970
sage: jacobi_P(n, a, b, x, hold=True)._sympy_()
@@ -1979,7 +1978,7 @@ def _eval_(self, n, a, b, x):
19791978
"""
19801979
EXAMPLES::
19811980
1982-
sage: _ = var('n a b x')
1981+
sage: n,a,b,x = SR.var('n,a,b,x')
19831982
sage: jacobi_P(1,n,n,n)
19841983
(n + 1)*n
19851984
sage: jacobi_P(2,n,n,n)
@@ -2083,17 +2082,20 @@ class Func_ultraspherical(GinacFunction):
20832082
sage: t = PolynomialRing(RationalField(),"t").gen()
20842083
sage: gegenbauer(3,2,t)
20852084
32*t^3 - 12*t
2086-
sage: _ = var('x')
2087-
sage: for N in range(100):
2088-
....: n = ZZ.random_element(5, 5001)
2089-
....: a = QQ.random_element().abs() + 5
2090-
....: assert ((n+1)*ultraspherical(n+1,a,x) - 2*x*(n+a)*ultraspherical(n,a,x) + (n+2*a-1)*ultraspherical(n-1,a,x)).expand().is_zero()
2085+
sage: x = SR.var('x')
2086+
sage: n = ZZ.random_element(5, 5001)
2087+
sage: a = QQ.random_element().abs() + 5
2088+
sage: s = ( (n+1)*ultraspherical(n+1,a,x)
2089+
....: - 2*x*(n+a)*ultraspherical(n,a,x)
2090+
....: + (n+2*a-1)*ultraspherical(n-1,a,x) )
2091+
sage: s.expand().is_zero()
2092+
True
20912093
sage: ultraspherical(5,9/10,3.1416)
20922094
6949.55439044240
20932095
sage: ultraspherical(5,9/10,RealField(100)(pi))
20942096
6949.4695419382702451843080687
20952097
2096-
sage: _ = var('a n')
2098+
sage: a,n = SR.var('a,n')
20972099
sage: gegenbauer(2,a,x)
20982100
2*(a + 1)*a*x^2 - a
20992101
sage: gegenbauer(3,a,x)

0 commit comments

Comments
 (0)