@@ -0,0 +1,1398 @@
+# -*- coding: utf-8 -*-%0A%0Aimport numpy as np%0Aimport unittest%0Afrom . import misc%0A%0A%0A@misc.array_adapter%0Adef apply_func(func, x):%0A    return func(x)%0A%0A%0Adef sample_gen():%0A    for i in range(10):%0A        yield i, i*i%0A%0A%0Aclass TestArrayAdapter(unittest.TestCase):%0A%0A    def test_apply_first(self):%0A        f = lambda x: 2*x%0A        t = 2, 3, 4%0A        s = misc._apply(f, t)%0A        self.assertEqual(type(s), tuple)%0A        self.assertEqual(s, (4, 3, 4))%0A%0A    def test_apply_first_gen(self):%0A        f = lambda x: 2*x%0A        G = misc._apply_first_gen(f, sample_gen())%0A        for t, (a, b) in enumerate(G):%0A            self.assertEqual(a, 2*t)%0A            self.assertEqual(b, t*t)%0A%0A    def test_apply(self):%0A        f = lambda x: 2*x%0A        self.assertEqual(misc._apply(f, 2), 4)%0A        s = misc._apply(f, (2, 3, 4))%0A        self.assertEqual(type(s), tuple)%0A        self.assertEqual(s, (4, 3, 4))%0A        G = misc._apply(f, sample_gen())%0A        for t, (a, b) in enumerate(G):%0A            self.assertEqual(a, 2*t)%0A            self.assertEqual(b, t*t)%0A%0A    def test_array_adapter(self):%0A        shape = (2, 3)%0A%0A        def f(x):%0A            self.assertEqual(x.shape, shape)%0A            return 2*x%0A        x = np.ones(shape)%0A        ad = misc.ArrayAdapter(f, x)%0A        y = ad.convert(x)%0A        np.testing.assert_allclose(y, np.ones(6))%0A        y = ad(y)%0A        np.testing.assert_allclose(y, 2*np.ones(6))%0A

Add test of array_adapter