def test_cove_reader(n=10000):
    plt.interactive(True)
    try:
        FIG = plt.figure()
        Q = Queue()
        bs_reader = BS3Reader(COVEProtocolHandler, Q, verbose=True,
                              ident='TestCOVE')
        bs_reader.start()
        for _ in xrange(n):
            print Q.qsize()
            try:
                item = Q.get(block=True, timeout=2)
                FIG.clf()
                plt.imshow(item.data_lst[-1], shape=item.data_lst[-1].shape,
                           figure=FIG)
            except Empty:
                continue
    except Exception, ex:
        print ex
#
# Acknowledgements:
#   Philipp Meier <*****@*****.**>
#_____________________________________________________________________________
#

##---IMPORTS

from numpy.testing import assert_equal, assert_almost_equal
import scipy as sp
from scipy.io import loadmat
from botmpy.common import TimeSeriesCovE, mcvec_from_conc, VERBOSE
from botmpy.nodes import BOTMNode
from spikeplot import plt

plt.interactive(False)

##---TESTS

def get_input_data(tf):
    noise = loadmat('/home/phil/matlab.mat')['noise'].T
    nc = noise.shape[1]
    spike_proto_sc = sp.cos(sp.linspace(-sp.pi, 3 * sp.pi, tf))
    spike_proto_sc *= sp.hanning(tf)
    scale = sp.linspace(0, 2, tf)
    cvals = [(5., .5), (4., 9.), (3., 3.), (7., 2.5)]
    xi1 = sp.vstack([spike_proto_sc * cvals[i][0] * scale
                     for i in xrange(nc)]).T
    xi2 = sp.vstack([spike_proto_sc * cvals[i][1] * scale[::-1]
                     for i in xrange(nc)]).T
    temps = sp.asarray([xi1, xi2])