@staticmethod
def testcase():
    ' test the filt+downsample transformation filter by incremental calling '
    X = np.sin((((np.arange(100)[:, np.newaxis] * 2) * np.pi) / 30))
    xs = np.arange(X.shape[0])[:, np.newaxis]
    bands = (0, 20, 'bandpass')
    fs = 200
    fs_out = 130
    fds = butterfilt_and_downsample(stopband=bands, fs=fs, fs_out=fs_out)
    print('single step')
    fds.fit(X[0:1, :])
    (m0, xs0) = fds.transform(X, xs)
    print('M0 -> {}'.format(m0[:20]))
    step = 6
    print('Step size = {}'.format(step))
    fds.fit(X[0:1, :])
    m1 = np.zeros(m0.shape, m0.dtype)
    xs1 = np.zeros(xs0.shape, xs0.dtype)
    t = 0
    for i in range(0, len(X), step):
        idx = np.arange(i, min((i + step), len(X)))
        (mm, idx1) = fds.transform(X[idx, :], idx[:, np.newaxis])
        m1[t:(t + mm.shape[0]), :] = mm
        xs1[t:(t + mm.shape[0])] = idx1
        t = (t + mm.shape[0])
    print('M1 -> {}'.format(m1[:20]))
    print('diff: {}'.format(np.max(np.abs((m0 - m1)))))
    import matplotlib.pyplot as plt
    plt.plot(xs, X, '*-', label='X')
    plt.plot(xs0, m0, '*-', label='{} {}->{}Hz single'.format(bands, fs, fs_out))
    plt.plot(xs1, m1, '*-', label='{} {}->{}Hz incremental'.format(bands, fs, fs_out))
    plt.legend()
    plt.show()
test the filt+downsample transformation filter by incremental calling
@staticmethod
def testcase():
    '  '
    X = np.sin((((np.arange(100)[:, np.newaxis] * 2) * np.pi) / 30))
    xs = np.arange(X.shape[0])[:, np.newaxis]
    bands = (0, 20, 'bandpass')
    fs = 200
    fs_out = 130
    fds = butterfilt_and_downsample(stopband=bands, fs=fs, fs_out=fs_out)
    print('single step')
    fds.fit(X[0:1, :])
    (m0, xs0) = fds.transform(X, xs)
    print('M0 -> {}'.format(m0[:20]))
    step = 6
    print('Step size = {}'.format(step))
    fds.fit(X[0:1, :])
    m1 = np.zeros(m0.shape, m0.dtype)
    xs1 = np.zeros(xs0.shape, xs0.dtype)
    t = 0
    for i in range(0, len(X), step):
        idx = np.arange(i, min((i + step), len(X)))
        (mm, idx1) = fds.transform(X[idx, :], idx[:, np.newaxis])
        m1[t:(t + mm.shape[0]), :] = mm
        xs1[t:(t + mm.shape[0])] = idx1
        t = (t + mm.shape[0])
    print('M1 -> {}'.format(m1[:20]))
    print('diff: {}'.format(np.max(np.abs((m0 - m1)))))
    import matplotlib.pyplot as plt
    plt.plot(xs, X, '*-', label='X')
    plt.plot(xs0, m0, '*-', label='{} {}->{}Hz single'.format(bands, fs, fs_out))
    plt.plot(xs1, m1, '*-', label='{} {}->{}Hz incremental'.format(bands, fs, fs_out))
    plt.legend()
    plt.show()