def test_ZeroOne(self): for N in np.arange(1,37): m = 0 w = pyyawt.dbwavf("db" + str(N)) np.testing.assert_almost_equal(np.sum(w[2*m:(2*N+2*m)]*w[0:2*N]),1, decimal=self.accuracy_decimal) for m in np.arange(1, N-1): np.testing.assert_almost_equal(np.sum(w[2*m:(2*N)]*w[0:2*N-2*m]),0, decimal=self.accuracy_decimal)
def test_ZeroOne(self): for N in np.arange(1, 37): m = 0 w = pyyawt.dbwavf("db" + str(N)) np.testing.assert_almost_equal(np.sum(w[2 * m:(2 * N + 2 * m)] * w[0:2 * N]), 1, decimal=self.accuracy_decimal) for m in np.arange(1, N - 1): np.testing.assert_almost_equal(np.sum(w[2 * m:(2 * N)] * w[0:2 * N - 2 * m]), 0, decimal=self.accuracy_decimal)
def test_haar(self): Lo_D,Hi_D,Lo_R,Hi_R = pyyawt.wfilters('haar') w = pyyawt.dbwavf('db1') lo_d,hi_d,lo_r,hi_r = pyyawt.orthfilt(w) np.testing.assert_almost_equal(lo_d, Lo_D) np.testing.assert_almost_equal(lo_r, Lo_R) np.testing.assert_almost_equal(hi_d, Hi_D) np.testing.assert_almost_equal(hi_r, Hi_R) Lo_D,Hi_D = pyyawt.wfilters('haar','d') Lo_R,Hi_R = pyyawt.wfilters('haar','r') np.testing.assert_almost_equal(lo_d, Lo_D) np.testing.assert_almost_equal(lo_r, Lo_R) np.testing.assert_almost_equal(hi_d, Hi_D) np.testing.assert_almost_equal(hi_r, Hi_R) Lo_D,Lo_R = pyyawt.wfilters('haar','l') Hi_D,Hi_R = pyyawt.wfilters('haar','h') np.testing.assert_almost_equal(lo_d, Lo_D) np.testing.assert_almost_equal(lo_r, Lo_R) np.testing.assert_almost_equal(hi_d, Hi_D) np.testing.assert_almost_equal(hi_r, Hi_R)
def test_haar(self): Lo_D, Hi_D, Lo_R, Hi_R = pyyawt.wfilters("haar") w = pyyawt.dbwavf("db1") lo_d, hi_d, lo_r, hi_r = pyyawt.orthfilt(w) np.testing.assert_almost_equal(lo_d, Lo_D) np.testing.assert_almost_equal(lo_r, Lo_R) np.testing.assert_almost_equal(hi_d, Hi_D) np.testing.assert_almost_equal(hi_r, Hi_R) Lo_D, Hi_D = pyyawt.wfilters("haar", "d") Lo_R, Hi_R = pyyawt.wfilters("haar", "r") np.testing.assert_almost_equal(lo_d, Lo_D) np.testing.assert_almost_equal(lo_r, Lo_R) np.testing.assert_almost_equal(hi_d, Hi_D) np.testing.assert_almost_equal(hi_r, Hi_R) Lo_D, Lo_R = pyyawt.wfilters("haar", "l") Hi_D, Hi_R = pyyawt.wfilters("haar", "h") np.testing.assert_almost_equal(lo_d, Lo_D) np.testing.assert_almost_equal(lo_r, Lo_R) np.testing.assert_almost_equal(hi_d, Hi_D) np.testing.assert_almost_equal(hi_r, Hi_R)
def test_dbwavf(self): for N in np.arange(1,37): Lo_D,Hi_D,Lo_R,Hi_R = pyyawt.wfilters("db" + str(N)) w = pyyawt.dbwavf("db" + str(N)) lo_d,hi_d,lo_r,hi_r = pyyawt.orthfilt(w) np.testing.assert_almost_equal(lo_d, Lo_D) np.testing.assert_almost_equal(lo_r, Lo_R) np.testing.assert_almost_equal(hi_d, Hi_D) np.testing.assert_almost_equal(hi_r, Hi_R) Lo_D,Hi_D = pyyawt.wfilters("db" + str(N),'d') Lo_R,Hi_R = pyyawt.wfilters("db" + str(N),'r') np.testing.assert_almost_equal(lo_d, Lo_D) np.testing.assert_almost_equal(lo_r, Lo_R) np.testing.assert_almost_equal(hi_d, Hi_D) np.testing.assert_almost_equal(hi_r, Hi_R) Lo_D,Lo_R = pyyawt.wfilters("db" + str(N),'l') Hi_D,Hi_R = pyyawt.wfilters("db" + str(N),'h') np.testing.assert_almost_equal(lo_d, Lo_D) np.testing.assert_almost_equal(lo_r, Lo_R) np.testing.assert_almost_equal(hi_d, Hi_D) np.testing.assert_almost_equal(hi_r, Hi_R)
def test_dbwavf(self): for N in np.arange(1, 37): Lo_D, Hi_D, Lo_R, Hi_R = pyyawt.wfilters("db" + str(N)) w = pyyawt.dbwavf("db" + str(N)) lo_d, hi_d, lo_r, hi_r = pyyawt.orthfilt(w) np.testing.assert_almost_equal(lo_d, Lo_D) np.testing.assert_almost_equal(lo_r, Lo_R) np.testing.assert_almost_equal(hi_d, Hi_D) np.testing.assert_almost_equal(hi_r, Hi_R) Lo_D, Hi_D = pyyawt.wfilters("db" + str(N), "d") Lo_R, Hi_R = pyyawt.wfilters("db" + str(N), "r") np.testing.assert_almost_equal(lo_d, Lo_D) np.testing.assert_almost_equal(lo_r, Lo_R) np.testing.assert_almost_equal(hi_d, Hi_D) np.testing.assert_almost_equal(hi_r, Hi_R) Lo_D, Lo_R = pyyawt.wfilters("db" + str(N), "l") Hi_D, Hi_R = pyyawt.wfilters("db" + str(N), "h") np.testing.assert_almost_equal(lo_d, Lo_D) np.testing.assert_almost_equal(lo_r, Lo_R) np.testing.assert_almost_equal(hi_d, Hi_D) np.testing.assert_almost_equal(hi_r, Hi_R)
# -*- coding: utf-8 -*- # Copyright (c) 2015 Holger Nahrstaedt from __future__ import division, print_function, absolute_import import os import numpy as np import sys import unittest import pyyawt F_coif3 = pyyawt.coifwavf('coif3') F_db2 = pyyawt.dbwavf('db2')
def test_sumOdd(self): for N in np.arange(1, 37): w = pyyawt.dbwavf("db" + str(N)) np.testing.assert_almost_equal(np.sum(w[1::2]), 1. / np.sqrt(2), decimal=self.accuracy_decimal)
def test_sumOdd(self): for N in np.arange(1,37): w = pyyawt.dbwavf("db" + str(N)) np.testing.assert_almost_equal(np.sum(w[1::2]),1./np.sqrt(2), decimal=self.accuracy_decimal)
def test_dbwavf(self): F = pyyawt.dbwavf("db2") F_req = np.array([0.4829629, 0.8365163, 0.2241439,-0.1294095]) np.testing.assert_almost_equal(F,F_req)