Exemple #1
0
    def test_vector_even(self):
        a = np.random.randn(50)
        ind = np.arange(50)
        b = pyyawt.dyadup(a)
        b1 = pyyawt.dyadup(a, 0)
        b2 = pyyawt.dyadup(a, 1)
        c = np.zeros(101)
        c[2 * ind + 1] = a[ind]
        c1 = np.zeros(99)
        c1[2 * ind] = a[ind]

        np.testing.assert_almost_equal(b, b2)
        np.testing.assert_almost_equal(b1, c1)
        np.testing.assert_almost_equal(b2, c)

        a = np.random.randn(1, 50)
        ind = np.arange(50)
        b = pyyawt.dyadup(a)
        b1 = pyyawt.dyadup(a, 0)
        b2 = pyyawt.dyadup(a, 1)
        b3 = pyyawt.dyadup(a.T)
        b4 = pyyawt.dyadup(a.T, 0)
        b5 = pyyawt.dyadup(a.T, 1)
        c = np.zeros((1, 101))
        c[:, 2 * ind + 1] = a[:, ind]
        c1 = np.zeros((1, 99))
        c1[:, 2 * ind] = a[:, ind]

        np.testing.assert_almost_equal(b, b2)
        np.testing.assert_almost_equal(b1, c1)
        np.testing.assert_almost_equal(b2, c)
        np.testing.assert_almost_equal(b3, b2.T)
        np.testing.assert_almost_equal(b4, c1.T)
        np.testing.assert_almost_equal(b5, c.T)
Exemple #2
0
    def test_vector_even(self):
        a = np.random.randn(50)
        ind = np.arange(50)
        b = pyyawt.dyadup(a)
        b1 = pyyawt.dyadup(a,0)
        b2 = pyyawt.dyadup(a,1)
        c = np.zeros(101)
        c[2*ind+1] = a[ind]
        c1 = np.zeros(99)
        c1[2*ind] = a[ind]

        np.testing.assert_almost_equal(b, b2)
        np.testing.assert_almost_equal(b1, c1)
        np.testing.assert_almost_equal(b2, c)

        a = np.random.randn(1,50)
        ind = np.arange(50)
        b = pyyawt.dyadup(a)
        b1 = pyyawt.dyadup(a,0)
        b2 = pyyawt.dyadup(a,1)
        b3 = pyyawt.dyadup(a.T)
        b4 = pyyawt.dyadup(a.T,0)
        b5 = pyyawt.dyadup(a.T,1)
        c = np.zeros((1,101))
        c[:,2*ind+1] = a[:,ind]
        c1 = np.zeros((1,99))
        c1[:,2*ind] = a[:,ind]

        np.testing.assert_almost_equal(b, b2)
        np.testing.assert_almost_equal(b1, c1)
        np.testing.assert_almost_equal(b2, c)
        np.testing.assert_almost_equal(b3, b2.T)
        np.testing.assert_almost_equal(b4, c1.T)
        np.testing.assert_almost_equal(b5, c.T)
Exemple #3
0
 def test_type5(self):
     s1 = self.s1
     x1 = self.x1
     x2 = self.x2
     wname = "db7"
     dwtModes = ['symw', 'asymh', 'asymw', 'zpd', 'sp0', 'sp1',
                 'ppd','per']
     [cA,cD] = pyyawt.dwt(x1,wname)
     [Lo_R,Hi_R] = pyyawt.wfilters(wname,'r')
     a0 = pyyawt.conv(pyyawt.dyadup(cA),Lo_R)
     d0 = pyyawt.conv(pyyawt.dyadup(cD),Hi_R)
     x0 = pyyawt.wkeep(a0+d0,50)
     for N in np.arange(len(dwtModes)-1):
         r = pyyawt.idwt(cA,cD,wname,50,'mode',dwtModes[N])
         np.testing.assert_almost_equal(r, x0)
     r = pyyawt.idwt(cA,cD,wname,50,'mode','per')
     x0 = pyyawt.wkeep(a0+d0,50)
     np.testing.assert_almost_equal(r, x0)
Exemple #4
0
 def test_type6(self):
     s1 = self.s1
     x1 = self.x1
     x2 = self.x2
     wname = "db7"
     dwtModes = ['symw', 'asymh', 'asymw', 'zpd', 'sp0', 'sp1',
                 'ppd','per']
     [cA,cD] = pyyawt.dwt(x1,wname)
     Lo_R = np.random.rand(14)
     Hi_R = np.random.rand(14)
     a0 = pyyawt.conv(pyyawt.dyadup(cA),Lo_R.flatten())
     d0 = pyyawt.conv(pyyawt.dyadup(cD),Hi_R.flatten())
     x0 = pyyawt.wkeep(a0+d0,50)
     for N in np.arange(len(dwtModes)-1):
         r = pyyawt.idwt(cA,cD,Lo_R,Hi_R,50,'mode',dwtModes[N])
         np.testing.assert_almost_equal(r, x0)
     r = pyyawt.idwt(cA,cD,Lo_R,Hi_R,50,'mode','per')
     x0 = pyyawt.wkeep(a0+d0,50)
     np.testing.assert_almost_equal(r, x0)
Exemple #5
0
 def test_type5(self):
     s1 = self.s1
     x1 = self.x1
     x2 = self.x2
     wname = "db7"
     dwtModes = [
         'symw', 'asymh', 'asymw', 'zpd', 'sp0', 'sp1', 'ppd', 'per'
     ]
     [cA, cD] = pyyawt.dwt(x1, wname)
     [Lo_R, Hi_R] = pyyawt.wfilters(wname, 'r')
     a0 = pyyawt.conv(pyyawt.dyadup(cA), Lo_R)
     d0 = pyyawt.conv(pyyawt.dyadup(cD), Hi_R)
     x0 = pyyawt.wkeep(a0 + d0, 50)
     for N in np.arange(len(dwtModes) - 1):
         r = pyyawt.idwt(cA, cD, wname, 50, 'mode', dwtModes[N])
         np.testing.assert_almost_equal(r, x0)
     r = pyyawt.idwt(cA, cD, wname, 50, 'mode', 'per')
     x0 = pyyawt.wkeep(a0 + d0, 50)
     np.testing.assert_almost_equal(r, x0)
Exemple #6
0
 def test_type6(self):
     s1 = self.s1
     x1 = self.x1
     x2 = self.x2
     wname = "db7"
     dwtModes = [
         'symw', 'asymh', 'asymw', 'zpd', 'sp0', 'sp1', 'ppd', 'per'
     ]
     [cA, cD] = pyyawt.dwt(x1, wname)
     Lo_R = np.random.rand(14)
     Hi_R = np.random.rand(14)
     a0 = pyyawt.conv(pyyawt.dyadup(cA), Lo_R.flatten())
     d0 = pyyawt.conv(pyyawt.dyadup(cD), Hi_R.flatten())
     x0 = pyyawt.wkeep(a0 + d0, 50)
     for N in np.arange(len(dwtModes) - 1):
         r = pyyawt.idwt(cA, cD, Lo_R, Hi_R, 50, 'mode', dwtModes[N])
         np.testing.assert_almost_equal(r, x0)
     r = pyyawt.idwt(cA, cD, Lo_R, Hi_R, 50, 'mode', 'per')
     x0 = pyyawt.wkeep(a0 + d0, 50)
     np.testing.assert_almost_equal(r, x0)
Exemple #7
0
    def test_type2(self):
        s1 = self.s1
        x1 = self.x1
        x2 = self.x2
        wname = "bior3.9"
        [cA,cD] = pyyawt.dwt(x1,wname)
        Lo_R = np.random.randn(20)
        Hi_R = np.random.randn(20)
        a0 = pyyawt.conv(pyyawt.dyadup(cA),Lo_R)
        d0 = pyyawt.conv(pyyawt.dyadup(cD),Hi_R)
        x0 = pyyawt.wkeep(a0+d0,2*np.size(cA)-np.size(Lo_R)+2)
        r = pyyawt.idwt(cA,cD,Lo_R.flatten(),Hi_R.flatten())
        np.testing.assert_almost_equal(r, x0)

        [cA,cD] = pyyawt.dwt(x2,wname)
        Lo_R = np.random.randn(20)
        Hi_R = np.random.randn(20)
        a0 = pyyawt.conv(pyyawt.dyadup(cA),Lo_R)
        d0 = pyyawt.conv(pyyawt.dyadup(cD),Hi_R)
        x0 = pyyawt.wkeep(a0+d0,2*np.size(cA)-np.size(Lo_R)+2)
        r = pyyawt.idwt(cA,cD,Lo_R.flatten(),Hi_R.flatten())
        np.testing.assert_almost_equal(r, x0)

        [cA,cD] = pyyawt.dwt(s1,wname)
        Lo_R = np.random.randn(20)
        Hi_R = np.random.randn(20)
        a0 = pyyawt.conv(pyyawt.dyadup(cA),Lo_R)
        d0 = pyyawt.conv(pyyawt.dyadup(cD),Hi_R)
        x0 = pyyawt.wkeep(a0+d0,2*np.size(cA)-np.size(Lo_R)+2)
        r = pyyawt.idwt(cA,cD,Lo_R.flatten(),Hi_R.flatten())
        np.testing.assert_almost_equal(r, x0)
Exemple #8
0
    def test_coif(self):
        s1 = self.s1
        x1 = self.x1
        x2 = self.x2
        for N in np.arange(1, 6):
            wname = "coif" + str(N)
            [cA, cD] = pyyawt.dwt(x1, wname)
            [cA, cD] = pyyawt.dwt(x1, wname)
            [Lo_D, Hi_D, Lo_R, Hi_R] = pyyawt.wfilters(wname)
            a0 = pyyawt.conv(pyyawt.dyadup(cA), Lo_R)
            d0 = pyyawt.conv(pyyawt.dyadup(cD), Hi_R)
            x0 = pyyawt.wkeep(a0 + d0, 2 * np.size(cA) - np.size(Lo_R) + 2)
            r = pyyawt.idwt(cA, cD, wname)
            np.testing.assert_almost_equal(r, x0)

            [cA, cD] = pyyawt.dwt(x1, wname)
            [Lo_D, Hi_D, Lo_R, Hi_R] = pyyawt.wfilters(wname)
            a0 = pyyawt.conv(pyyawt.dyadup(cA), Lo_R)
            d0 = pyyawt.conv(pyyawt.dyadup(cD), Hi_R)
            x0 = pyyawt.wkeep(a0 + d0, 2 * np.size(cA) - np.size(Lo_R) + 2)
            r = pyyawt.idwt(cA, cD, wname)
            np.testing.assert_almost_equal(r, x0)

            [cA, cD] = pyyawt.dwt(x1, wname)
            [Lo_D, Hi_D, Lo_R, Hi_R] = pyyawt.wfilters(wname)
            a0 = pyyawt.conv(pyyawt.dyadup(cA), Lo_R)
            d0 = pyyawt.conv(pyyawt.dyadup(cD), Hi_R)
            x0 = pyyawt.wkeep(a0 + d0, 2 * np.size(cA) - np.size(Lo_R) + 2)
            r = pyyawt.idwt(cA, cD, wname)
            np.testing.assert_almost_equal(r, x0)
Exemple #9
0
    def test_haar(self):
        s1 = self.s1
        x1 = self.x1
        x2 = self.x2
        wname = 'haar'
        [cA, cD] = pyyawt.dwt(x1, wname)
        [Lo_D, Hi_D, Lo_R, Hi_R] = pyyawt.wfilters(wname)
        a0 = pyyawt.conv(pyyawt.dyadup(cA), Lo_R)
        d0 = pyyawt.conv(pyyawt.dyadup(cD), Hi_R)
        x0 = pyyawt.wkeep(a0 + d0, 2 * np.size(cA) - np.size(Lo_R) + 2)
        r = pyyawt.idwt(cA, cD, wname)
        np.testing.assert_almost_equal(r, x0)

        [cA, cD] = pyyawt.dwt(x1, wname)
        [Lo_D, Hi_D, Lo_R, Hi_R] = pyyawt.wfilters(wname)
        a0 = pyyawt.conv(pyyawt.dyadup(cA), Lo_R)
        d0 = pyyawt.conv(pyyawt.dyadup(cD), Hi_R)
        x0 = pyyawt.wkeep(a0 + d0, 2 * np.size(cA) - np.size(Lo_R) + 2)
        r = pyyawt.idwt(cA, cD, wname)
        np.testing.assert_almost_equal(r, x0)

        [cA, cD] = pyyawt.dwt(x1, wname)
        [Lo_D, Hi_D, Lo_R, Hi_R] = pyyawt.wfilters(wname)
        a0 = pyyawt.conv(pyyawt.dyadup(cA), Lo_R)
        d0 = pyyawt.conv(pyyawt.dyadup(cD), Hi_R)
        x0 = pyyawt.wkeep(a0 + d0, 2 * np.size(cA) - np.size(Lo_R) + 2)
        r = pyyawt.idwt(cA, cD, wname)
        np.testing.assert_almost_equal(r, x0)
Exemple #10
0
    def test_type2(self):
        s1 = self.s1
        x1 = self.x1
        x2 = self.x2
        wname = "bior3.9"
        [cA, cD] = pyyawt.dwt(x1, wname)
        Lo_R = np.random.randn(20)
        Hi_R = np.random.randn(20)
        a0 = pyyawt.conv(pyyawt.dyadup(cA), Lo_R)
        d0 = pyyawt.conv(pyyawt.dyadup(cD), Hi_R)
        x0 = pyyawt.wkeep(a0 + d0, 2 * np.size(cA) - np.size(Lo_R) + 2)
        r = pyyawt.idwt(cA, cD, Lo_R.flatten(), Hi_R.flatten())
        np.testing.assert_almost_equal(r, x0)

        [cA, cD] = pyyawt.dwt(x2, wname)
        Lo_R = np.random.randn(20)
        Hi_R = np.random.randn(20)
        a0 = pyyawt.conv(pyyawt.dyadup(cA), Lo_R)
        d0 = pyyawt.conv(pyyawt.dyadup(cD), Hi_R)
        x0 = pyyawt.wkeep(a0 + d0, 2 * np.size(cA) - np.size(Lo_R) + 2)
        r = pyyawt.idwt(cA, cD, Lo_R.flatten(), Hi_R.flatten())
        np.testing.assert_almost_equal(r, x0)

        [cA, cD] = pyyawt.dwt(s1, wname)
        Lo_R = np.random.randn(20)
        Hi_R = np.random.randn(20)
        a0 = pyyawt.conv(pyyawt.dyadup(cA), Lo_R)
        d0 = pyyawt.conv(pyyawt.dyadup(cD), Hi_R)
        x0 = pyyawt.wkeep(a0 + d0, 2 * np.size(cA) - np.size(Lo_R) + 2)
        r = pyyawt.idwt(cA, cD, Lo_R.flatten(), Hi_R.flatten())
        np.testing.assert_almost_equal(r, x0)
Exemple #11
0
    def test_bior(self):
        s1 = self.s1
        x1 = self.x1
        x2 = self.x2
        wnames = [
            'bior1.1', 'bior1.3', 'bior1.5', 'bior2.2', 'bior2.4', 'bior2.6',
            'bior2.8', 'bior3.1', 'bior3.3', 'bior3.5', 'bior3.7', 'bior3.9',
            'bior4.4', 'bior5.5', 'bior6.8'
        ]
        for N in np.arange(1, 13):
            wname = wnames[N]
            [cA, cD] = pyyawt.dwt(x1, wname)
            [cA, cD] = pyyawt.dwt(x1, wname)
            [Lo_D, Hi_D, Lo_R, Hi_R] = pyyawt.wfilters(wname)
            a0 = pyyawt.conv(pyyawt.dyadup(cA), Lo_R)
            d0 = pyyawt.conv(pyyawt.dyadup(cD), Hi_R)
            x0 = pyyawt.wkeep(a0 + d0, 2 * np.size(cA) - np.size(Lo_R) + 2)
            r = pyyawt.idwt(cA, cD, wname)
            np.testing.assert_almost_equal(r, x0)

            [cA, cD] = pyyawt.dwt(x1, wname)
            [Lo_D, Hi_D, Lo_R, Hi_R] = pyyawt.wfilters(wname)
            a0 = pyyawt.conv(pyyawt.dyadup(cA), Lo_R)
            d0 = pyyawt.conv(pyyawt.dyadup(cD), Hi_R)
            x0 = pyyawt.wkeep(a0 + d0, 2 * np.size(cA) - np.size(Lo_R) + 2)
            r = pyyawt.idwt(cA, cD, wname)
            np.testing.assert_almost_equal(r, x0)

            [cA, cD] = pyyawt.dwt(x1, wname)
            [Lo_D, Hi_D, Lo_R, Hi_R] = pyyawt.wfilters(wname)
            a0 = pyyawt.conv(pyyawt.dyadup(cA), Lo_R)
            d0 = pyyawt.conv(pyyawt.dyadup(cD), Hi_R)
            x0 = pyyawt.wkeep(a0 + d0, 2 * np.size(cA) - np.size(Lo_R) + 2)
            r = pyyawt.idwt(cA, cD, wname)
            np.testing.assert_almost_equal(r, x0)
Exemple #12
0
    def test_haar(self):
        s1 = self.s1
        x1 = self.x1
        x2 = self.x2
        wname = 'haar'
        [cA,cD] = pyyawt.dwt(x1,wname)
        [Lo_D,Hi_D,Lo_R,Hi_R] = pyyawt.wfilters(wname)
        a0 = pyyawt.conv(pyyawt.dyadup(cA),Lo_R)
        d0 = pyyawt.conv(pyyawt.dyadup(cD),Hi_R)
        x0 = pyyawt.wkeep(a0+d0,2*np.size(cA)-np.size(Lo_R)+2)
        r = pyyawt.idwt(cA,cD,wname)
        np.testing.assert_almost_equal(r, x0)

        [cA,cD] = pyyawt.dwt(x1,wname)
        [Lo_D,Hi_D,Lo_R,Hi_R] = pyyawt.wfilters(wname)
        a0 = pyyawt.conv(pyyawt.dyadup(cA),Lo_R)
        d0 = pyyawt.conv(pyyawt.dyadup(cD),Hi_R)
        x0 = pyyawt.wkeep(a0+d0,2*np.size(cA)-np.size(Lo_R)+2)
        r = pyyawt.idwt(cA,cD,wname)
        np.testing.assert_almost_equal(r, x0)

        [cA,cD] = pyyawt.dwt(x1,wname)
        [Lo_D,Hi_D,Lo_R,Hi_R] = pyyawt.wfilters(wname)
        a0 = pyyawt.conv(pyyawt.dyadup(cA),Lo_R)
        d0 = pyyawt.conv(pyyawt.dyadup(cD),Hi_R)
        x0 = pyyawt.wkeep(a0+d0,2*np.size(cA)-np.size(Lo_R)+2)
        r = pyyawt.idwt(cA,cD,wname)
        np.testing.assert_almost_equal(r, x0)
Exemple #13
0
    def test_bior(self):
        s1 = self.s1
        x1 = self.x1
        x2 = self.x2
        wnames = ['bior1.1', 'bior1.3', 'bior1.5', 'bior2.2', 'bior2.4', 'bior2.6',
                  'bior2.8', 'bior3.1', 'bior3.3', 'bior3.5', 'bior3.7', 'bior3.9',
                  'bior4.4', 'bior5.5', 'bior6.8']
        for N in np.arange(1,13):
            wname = wnames[N]
            [cA,cD] = pyyawt.dwt(x1,wname)
            [cA,cD] = pyyawt.dwt(x1,wname)
            [Lo_D,Hi_D,Lo_R,Hi_R] = pyyawt.wfilters(wname)
            a0 = pyyawt.conv(pyyawt.dyadup(cA),Lo_R)
            d0 = pyyawt.conv(pyyawt.dyadup(cD),Hi_R)
            x0 = pyyawt.wkeep(a0+d0,2*np.size(cA)-np.size(Lo_R)+2)
            r = pyyawt.idwt(cA,cD,wname)
            np.testing.assert_almost_equal(r, x0)

            [cA,cD] = pyyawt.dwt(x1,wname)
            [Lo_D,Hi_D,Lo_R,Hi_R] = pyyawt.wfilters(wname)
            a0 = pyyawt.conv(pyyawt.dyadup(cA),Lo_R)
            d0 = pyyawt.conv(pyyawt.dyadup(cD),Hi_R)
            x0 = pyyawt.wkeep(a0+d0,2*np.size(cA)-np.size(Lo_R)+2)
            r = pyyawt.idwt(cA,cD,wname)
            np.testing.assert_almost_equal(r, x0)

            [cA,cD] = pyyawt.dwt(x1,wname)
            [Lo_D,Hi_D,Lo_R,Hi_R] = pyyawt.wfilters(wname)
            a0 = pyyawt.conv(pyyawt.dyadup(cA),Lo_R)
            d0 = pyyawt.conv(pyyawt.dyadup(cD),Hi_R)
            x0 = pyyawt.wkeep(a0+d0,2*np.size(cA)-np.size(Lo_R)+2)
            r = pyyawt.idwt(cA,cD,wname)
            np.testing.assert_almost_equal(r, x0)
Exemple #14
0
    def test_coif(self):
        s1 = self.s1
        x1 = self.x1
        x2 = self.x2
        for N in np.arange(1,6):
            wname = "coif" + str(N)
            [cA,cD] = pyyawt.dwt(x1,wname)
            [cA,cD] = pyyawt.dwt(x1,wname)
            [Lo_D,Hi_D,Lo_R,Hi_R] = pyyawt.wfilters(wname)
            a0 = pyyawt.conv(pyyawt.dyadup(cA),Lo_R)
            d0 = pyyawt.conv(pyyawt.dyadup(cD),Hi_R)
            x0 = pyyawt.wkeep(a0+d0,2*np.size(cA)-np.size(Lo_R)+2)
            r = pyyawt.idwt(cA,cD,wname)
            np.testing.assert_almost_equal(r, x0)

            [cA,cD] = pyyawt.dwt(x1,wname)
            [Lo_D,Hi_D,Lo_R,Hi_R] = pyyawt.wfilters(wname)
            a0 = pyyawt.conv(pyyawt.dyadup(cA),Lo_R)
            d0 = pyyawt.conv(pyyawt.dyadup(cD),Hi_R)
            x0 = pyyawt.wkeep(a0+d0,2*np.size(cA)-np.size(Lo_R)+2)
            r = pyyawt.idwt(cA,cD,wname)
            np.testing.assert_almost_equal(r, x0)

            [cA,cD] = pyyawt.dwt(x1,wname)
            [Lo_D,Hi_D,Lo_R,Hi_R] = pyyawt.wfilters(wname)
            a0 = pyyawt.conv(pyyawt.dyadup(cA),Lo_R)
            d0 = pyyawt.conv(pyyawt.dyadup(cD),Hi_R)
            x0 = pyyawt.wkeep(a0+d0,2*np.size(cA)-np.size(Lo_R)+2)
            r = pyyawt.idwt(cA,cD,wname)
            np.testing.assert_almost_equal(r, x0)
Exemple #15
0
    def test_type3(self):
        s1 = self.s1
        x1 = self.x1
        x2 = self.x2
        wname = "sym8"
        [cA, cD] = pyyawt.dwt(x1, wname)
        r = pyyawt.idwt(cA, cD, wname, 50)
        [Lo_D, Hi_D, Lo_R, Hi_R] = pyyawt.wfilters(wname)
        a0 = pyyawt.conv(pyyawt.dyadup(cA), Lo_R)
        d0 = pyyawt.conv(pyyawt.dyadup(cD), Hi_R)
        x0 = pyyawt.wkeep(a0 + d0, 50)
        np.testing.assert_almost_equal(r, x0)

        [cA, cD] = pyyawt.dwt(x2, wname)
        r = pyyawt.idwt(cA, cD, wname, 50)
        [Lo_D, Hi_D, Lo_R, Hi_R] = pyyawt.wfilters(wname)
        a0 = pyyawt.conv(pyyawt.dyadup(cA), Lo_R)
        d0 = pyyawt.conv(pyyawt.dyadup(cD), Hi_R)
        x0 = pyyawt.wkeep(a0 + d0, 50)
        np.testing.assert_almost_equal(r, x0)

        [cA, cD] = pyyawt.dwt(s1, wname)
        r = pyyawt.idwt(cA, cD, wname, 50)
        [Lo_D, Hi_D, Lo_R, Hi_R] = pyyawt.wfilters(wname)
        a0 = pyyawt.conv(pyyawt.dyadup(cA), Lo_R)
        d0 = pyyawt.conv(pyyawt.dyadup(cD), Hi_R)
        x0 = pyyawt.wkeep(a0 + d0, 50)
        np.testing.assert_almost_equal(r, x0)

        Lo_R = np.random.randn(50)
        Hi_R = np.random.randn(50)
        a0 = pyyawt.conv(pyyawt.dyadup(cA), Lo_R)
        d0 = pyyawt.conv(pyyawt.dyadup(cD), Hi_R)
        x0 = pyyawt.wkeep(a0 + d0, 50)
        r = pyyawt.idwt(cA, cD, Lo_R.flatten(), Hi_R.flatten(), 50)
        np.testing.assert_almost_equal(r, x0)
Exemple #16
0
    def test_type3(self):
        s1 = self.s1
        x1 = self.x1
        x2 = self.x2
        wname = "sym8"
        [cA,cD] = pyyawt.dwt(x1,wname)
        r = pyyawt.idwt(cA,cD,wname,50)
        [Lo_D,Hi_D,Lo_R,Hi_R] = pyyawt.wfilters(wname)
        a0 = pyyawt.conv(pyyawt.dyadup(cA),Lo_R)
        d0 = pyyawt.conv(pyyawt.dyadup(cD),Hi_R)
        x0 = pyyawt.wkeep(a0+d0,50)
        np.testing.assert_almost_equal(r, x0)

        [cA,cD] = pyyawt.dwt(x2,wname)
        r = pyyawt.idwt(cA,cD,wname,50)
        [Lo_D,Hi_D,Lo_R,Hi_R] = pyyawt.wfilters(wname)
        a0 = pyyawt.conv(pyyawt.dyadup(cA),Lo_R)
        d0 = pyyawt.conv(pyyawt.dyadup(cD),Hi_R)
        x0 = pyyawt.wkeep(a0+d0,50)
        np.testing.assert_almost_equal(r, x0)

        [cA,cD] = pyyawt.dwt(s1,wname)
        r = pyyawt.idwt(cA,cD,wname,50)
        [Lo_D,Hi_D,Lo_R,Hi_R] = pyyawt.wfilters(wname)
        a0 = pyyawt.conv(pyyawt.dyadup(cA),Lo_R)
        d0 = pyyawt.conv(pyyawt.dyadup(cD),Hi_R)
        x0 = pyyawt.wkeep(a0+d0,50)
        np.testing.assert_almost_equal(r, x0)

        Lo_R = np.random.randn(50)
        Hi_R = np.random.randn(50)
        a0 = pyyawt.conv(pyyawt.dyadup(cA),Lo_R)
        d0 = pyyawt.conv(pyyawt.dyadup(cD),Hi_R)
        x0 = pyyawt.wkeep(a0+d0,50)
        r = pyyawt.idwt(cA,cD,Lo_R.flatten(),Hi_R.flatten(),50)
        np.testing.assert_almost_equal(r, x0)
Exemple #17
0
    def test_matrix(self):
        a = np.random.randn(50, 51)
        b = pyyawt.dyadup(a)
        b1 = pyyawt.dyadup(a, 0)
        b2 = pyyawt.dyadup(a, 1)
        b3 = pyyawt.dyadup(a, 'r')
        b4 = pyyawt.dyadup(a, 'c')
        b5 = pyyawt.dyadup(a, 'm')
        b6 = pyyawt.dyadup(a, 0, 'r')
        b7 = pyyawt.dyadup(a, 0, 'c')
        b8 = pyyawt.dyadup(a, 0, 'm')
        b9 = pyyawt.dyadup(a, 1, 'r')
        b10 = pyyawt.dyadup(a, 1, 'c')
        b11 = pyyawt.dyadup(a, 1, 'm')
        ind = np.arange(50)
        ind1 = np.arange(51)
        c = np.zeros((99, 51))
        c[2 * ind, :] = a[ind, :]
        c1 = np.zeros((101, 51))
        c1[2 * ind + 1, :] = a[ind, :]

        c2 = np.zeros((50, 101))
        c2[:, 2 * ind1] = a[:, ind1]
        c3 = np.zeros((50, 103))
        c3[:, 2 * ind1 + 1] = a[:, ind1]

        c4 = np.zeros((99, 101))
        c4[2 * ind, :][:, 2 * ind1] = a[ind, :][:, ind1]
        c5 = np.zeros((101, 103))
        c5[2 * ind + 1, :][:, 2 * ind1 + 1] = a[ind, :][:, ind1]
        np.testing.assert_almost_equal(b, b10)
        np.testing.assert_almost_equal(b, c3)
        np.testing.assert_almost_equal(b1, c2)
        np.testing.assert_almost_equal(b2, b)
        np.testing.assert_almost_equal(b3, c1)
        np.testing.assert_almost_equal(b4, b2)
        # np.testing.assert_almost_equal(b5, c5)
        np.testing.assert_almost_equal(b6, c)
        np.testing.assert_almost_equal(b7, c2)
        # np.testing.assert_almost_equal(b8, c4)
        np.testing.assert_almost_equal(b9, c1)
        np.testing.assert_almost_equal(b10, c3)
        np.testing.assert_almost_equal(b11, b5)
Exemple #18
0
    def test_matrix(self):
        a = np.random.randn(50,51)
        b = pyyawt.dyadup(a)
        b1 = pyyawt.dyadup(a,0)
        b2 = pyyawt.dyadup(a,1)
        b3 = pyyawt.dyadup(a,'r')
        b4 = pyyawt.dyadup(a,'c')
        b5 = pyyawt.dyadup(a,'m')
        b6 = pyyawt.dyadup(a,0,'r')
        b7 = pyyawt.dyadup(a,0,'c')
        b8 = pyyawt.dyadup(a,0,'m')
        b9 = pyyawt.dyadup(a,1,'r')
        b10 = pyyawt.dyadup(a,1,'c')
        b11 = pyyawt.dyadup(a,1,'m')
        ind = np.arange(50)
        ind1 = np.arange(51)
        c = np.zeros((99,51))
        c[2*ind,:] = a[ind,:]
        c1 = np.zeros((101,51))
        c1[2*ind+1,:] = a[ind,:]

        c2 = np.zeros((50,101))
        c2[:,2*ind1] = a[:,ind1]
        c3 = np.zeros((50,103))
        c3[:,2*ind1+1] = a[:,ind1]

        c4 = np.zeros((99,101))
        c4[2*ind,:][:,2*ind1] = a[ind,:][:,ind1]
        c5 = np.zeros((101,103))
        c5[2*ind+1,:][:,2*ind1+1] = a[ind,:][:,ind1]
        np.testing.assert_almost_equal(b, b10)
        np.testing.assert_almost_equal(b, c3)
        np.testing.assert_almost_equal(b1, c2)
        np.testing.assert_almost_equal(b2, b)
        np.testing.assert_almost_equal(b3, c1)
        np.testing.assert_almost_equal(b4, b2)
        # np.testing.assert_almost_equal(b5, c5)
        np.testing.assert_almost_equal(b6, c)
        np.testing.assert_almost_equal(b7, c2)
        # np.testing.assert_almost_equal(b8, c4)
        np.testing.assert_almost_equal(b9, c1)
        np.testing.assert_almost_equal(b10, c3)
        np.testing.assert_almost_equal(b11, b5)