[Scipy-svn] r6969 - in trunk/scipy/special: cephes tests

scipy-svn@scip... scipy-svn@scip...
Sun Nov 28 11:46:31 CST 2010


Author: ptvirtan
Date: 2010-11-28 11:46:31 -0600 (Sun, 28 Nov 2010)
New Revision: 6969

Modified:
   trunk/scipy/special/cephes/hyp2f1.c
   trunk/scipy/special/tests/test_mpmath.py
   trunk/scipy/special/tests/test_orthogonal_eval.py
Log:
BUG: special: fix mistaken divergence test in hyp2f1 for cases where the series terminates (fixes #1298)

Modified: trunk/scipy/special/cephes/hyp2f1.c
===================================================================
--- trunk/scipy/special/cephes/hyp2f1.c	2010-11-28 15:44:33 UTC (rev 6968)
+++ trunk/scipy/special/cephes/hyp2f1.c	2010-11-28 17:46:31 UTC (rev 6969)
@@ -137,7 +137,7 @@
     if (d <= -1 && !(fabs(d-id) > EPS && s < 0) && !(neg_int_a || neg_int_b)) {
         return pow(s, d) * hyp2f1(c - a, c - b, c, x);
     }
-    if (d <= 0 && x == 1)
+    if (d <= 0 && x == 1 && !(neg_int_a || neg_int_b))
         goto hypdiv;
 
     if (ax < 1.0 || x == -1.0) {

Modified: trunk/scipy/special/tests/test_mpmath.py
===================================================================
--- trunk/scipy/special/tests/test_mpmath.py	2010-11-28 15:44:33 UTC (rev 6968)
+++ trunk/scipy/special/tests/test_mpmath.py	2010-11-28 17:46:31 UTC (rev 6969)
@@ -83,6 +83,10 @@
         (-8, 18.016500331508873, 10.805295997850628, 0.90875647507000001),
         (-10,900,-10.5,0.99),
         (-10,900,10.5,0.99),
+        (-1,2,1,1.0),
+        (-1,2,1,-1.0),
+        (-3,13,5,1.0),
+        (-3,13,5,-1.0),
     ]
     dataset = [p + (float(mpmath.hyp2f1(*p)),) for p in pts]
     dataset = np.array(dataset, dtype=np.float_)

Modified: trunk/scipy/special/tests/test_orthogonal_eval.py
===================================================================
--- trunk/scipy/special/tests/test_orthogonal_eval.py	2010-11-28 15:44:33 UTC (rev 6968)
+++ trunk/scipy/special/tests/test_orthogonal_eval.py	2010-11-28 17:46:31 UTC (rev 6969)
@@ -47,6 +47,8 @@
                 else:
                     p = (n,)
                 x = x_range[0] + (x_range[1] - x_range[0])*np.random.rand(nx)
+                x[0] = x_range[0] # always include domain start point
+                x[1] = x_range[1] # always include domain end point
                 poly = np.poly1d(cls(*p))
                 z = np.c_[np.tile(p, (nx,1)), x, poly(x)]
                 dataset.append(z)



More information about the Scipy-svn mailing list