[Scipy-svn] r5536 - branches/special_refactor/scipy/special/core/tests

scipy-svn@scip... scipy-svn@scip...
Tue Feb 10 13:11:01 CST 2009


Author: cdavid
Date: 2009-02-10 13:10:53 -0600 (Tue, 10 Feb 2009)
New Revision: 5536

Modified:
   branches/special_refactor/scipy/special/core/tests/test_core.py
Log:
Add Bessel tests.

Modified: branches/special_refactor/scipy/special/core/tests/test_core.py
===================================================================
--- branches/special_refactor/scipy/special/core/tests/test_core.py	2009-02-10 18:37:39 UTC (rev 5535)
+++ branches/special_refactor/scipy/special/core/tests/test_core.py	2009-02-10 19:10:53 UTC (rev 5536)
@@ -2,7 +2,8 @@
 
 import numpy as np
 from numpy.testing import *
-from scipy.special import arccosh, arcsinh, arctanh, erf, erfc, log1p, expm1
+from scipy.special import arccosh, arcsinh, arctanh, erf, erfc, log1p, expm1, \
+jn, jv, yn, yv, iv, kv, kn
 
 DATA_DIR = os.path.join(os.path.dirname(__file__), "data")
 
@@ -21,6 +22,19 @@
     'log1p_expm1_data.txt': (id, log1p, expm1),
 }
 
+TEST_MAPPING_2 = {
+    'bessel_i_data.txt': (id, iv),
+    'bessel_i_int_data.txt': (id, iv),
+    'bessel_j_data.txt': (id, jv),
+    'bessel_j_int_data.txt': (id, jn),
+    'bessel_j_large_data.txt': (id, jn),
+    'bessel_k_data.txt': (id, kv),
+    'bessel_k_int_data.txt': (id, kn),
+    'bessel_y01_data.txt': (id, yn),
+    'bessel_yn_data.txt': (id, yn),
+    'bessel_yv_data.txt': (id, yv),
+}
+
 def scaled_error(x, ref, eps):
     aerr = np.abs(x-ref)
     rerr = aerr * np.abs(ref)
@@ -34,6 +48,15 @@
         assert_array_almost_equal(funcs[i](dtype(data[:,0])),
                 dtype(data[:,i]))
 
+def _test_factory_two_args(func, datafile, dtype=np.double):
+    data = np.fromfile(os.path.join(DATA_DIR, datafile), sep=",", dtype=dtype)
+    data = data.reshape((data.size / 3, 3))
+    eps = np.finfo(dtype).eps
+    #print func(dtype(data[:,0]), dtype(data[:,1])), dtype(data[:, 2])
+
+    assert_array_almost_equal(func(dtype(data[:,0]), dtype(data[:,1])),
+        dtype(data[:, 2]))
+
 def test_one_arg():
     for k, v in TEST_MAPPING_1.items():
         func = _test_factory_one_arg
@@ -41,3 +64,8 @@
             ",".join([f.__name__ for f in v[1:]])
         yield func, v, k
 
+def test_two_args():
+    for k, v in TEST_MAPPING_2.items():
+        func = _test_factory_two_args
+        test_one_arg.__doc__ = "Boost test for %s" %  v[1].__name__
+        yield func, v[1], k



More information about the Scipy-svn mailing list