[Scipy-svn] r6553 - branches/0.8.x/scipy/special/tests

scipy-svn@scip... scipy-svn@scip...
Sun Jun 20 18:50:09 CDT 2010


Author: ptvirtan
Date: 2010-06-20 18:50:09 -0500 (Sun, 20 Jun 2010)
New Revision: 6553

Modified:
   branches/0.8.x/scipy/special/tests/test_mpmath.py
Log:
TST: special: add test for complex erf

(cherry picked from commits r6549, r6550)

Modified: branches/0.8.x/scipy/special/tests/test_mpmath.py
===================================================================
--- branches/0.8.x/scipy/special/tests/test_mpmath.py	2010-06-20 23:49:56 UTC (rev 6552)
+++ branches/0.8.x/scipy/special/tests/test_mpmath.py	2010-06-20 23:50:09 UTC (rev 6553)
@@ -42,7 +42,7 @@
     for r in np.logspace(-99, 2, 10):
         for p in np.linspace(0, 2*np.pi, 30):
             z = r*np.exp(1j*p)
-            dataset.append((z, mpmath.ei(z)))
+            dataset.append((z, complex(mpmath.ei(z))))
     dataset = np.array(dataset, dtype=np.complex_)
 
     FuncData(sc.expi, dataset, 0, 1).check()
@@ -152,3 +152,24 @@
         ds[4] = float(mpmath.hyp2f1(*tuple(ds[:4])))
 
     FuncData(sc.hyp2f1, dataset, (0,1,2,3), 4, rtol=1e-9).check()
+
+#------------------------------------------------------------------------------
+# erf (complex)
+#------------------------------------------------------------------------------
+
+@mpmath_check('0.14')
+def test_erf_complex():
+    # need to increase mpmath precision for this test
+    old_dps, old_prec = mpmath.mp.dps, mpmath.mp.prec
+    try:
+        mpmath.mp.dps = 70
+        x1, y1 = np.meshgrid(np.linspace(-10, 1, 11), np.linspace(-10, 1, 11))
+        x2, y2 = np.meshgrid(np.logspace(-10, .8, 11), np.logspace(-10, .8, 11))
+        points = np.r_[x1.ravel(),x2.ravel()] + 1j*np.r_[y1.ravel(),y2.ravel()]
+
+        # note that the global accuracy of our complex erf algorithm is limited
+        # roughly to 2e-8
+        assert_func_equal(sc.erf, lambda x: complex(mpmath.erf(x)), points,
+                          vectorized=False, rtol=2e-8)
+    finally:
+        mpmath.mp.dps, mpmath.mp.prec = old_dps, old_prec



More information about the Scipy-svn mailing list