예제 #1
0
 def test_mux_rare(self, weight, mux_class):
     "This should give us all the reference before all the noise"
     reference = list(T.finite_generator(50))
     noise = list(T.finite_generator(50, size=1))
     stream = pescador.Streamer(reference)
     stream2 = pescador.Streamer(noise)
     mux = mux_class([stream, stream2], 2, rate=256, weights=weight)
     estimate = list(mux)
     assert T._eq_list_of_dicts(reference + noise, estimate)
예제 #2
0
파일: test_mux.py 프로젝트: bmcfee/pescador
 def test_mux_rare(self, weight, mux_class):
     "This should give us all the reference before all the noise"
     reference = list(T.finite_generator(50))
     noise = list(T.finite_generator(50, size=1))
     stream = pescador.Streamer(reference)
     stream2 = pescador.Streamer(noise)
     mux = mux_class([stream, stream2], 2, rate=256,
                     weights=weight)
     estimate = list(mux)
     assert T._eq_list_of_dicts(reference + noise, estimate)
예제 #3
0
def test_mux_rare(weight):
    reference = list(T.finite_generator(50))
    noise = list(T.finite_generator(50, size=1))
    stream = pescador.Streamer(reference)
    stream2 = pescador.Streamer(noise)
    mux = pescador.mux.Mux([stream, stream2],
                           2,
                           weights=weight,
                           with_replacement=False)
    estimate = list(mux)
    assert (reference + noise) == estimate
예제 #4
0
 def test_mux_weighted(self, weight, mux_class):
     reference = list(T.finite_generator(50))
     noise = list(T.finite_generator(50, size=1))
     stream = pescador.Streamer(reference)
     stream2 = pescador.Streamer(noise)
     mux = mux_class([stream, stream2], 2, rate=256, weights=[1.0, weight])
     estimate = list(mux)
     if weight == 0.0:
         assert T._eq_list_of_dicts(reference, estimate)
     else:
         assert not T._eq_list_of_dicts(reference, estimate)
예제 #5
0
파일: test_mux.py 프로젝트: bmcfee/pescador
 def test_mux_weighted(self, weight, mux_class):
     reference = list(T.finite_generator(50))
     noise = list(T.finite_generator(50, size=1))
     stream = pescador.Streamer(reference)
     stream2 = pescador.Streamer(noise)
     mux = mux_class([stream, stream2], 2, rate=256,
                     weights=[1.0, weight])
     estimate = list(mux)
     if weight == 0.0:
         assert T._eq_list_of_dicts(reference, estimate)
     else:
         assert not T._eq_list_of_dicts(reference, estimate)
예제 #6
0
def test_mux_weighted(weight):
    reference = list(T.finite_generator(50))
    noise = list(T.finite_generator(50, size=1))
    stream = pescador.Streamer(reference)
    stream2 = pescador.Streamer(noise)
    mux = pescador.mux.Mux([stream, stream2],
                           2,
                           weights=[1.0, weight],
                           with_replacement=False)
    estimate = list(mux)
    if weight == 0.0:
        assert reference == estimate
    else:
        assert reference != estimate
예제 #7
0
def test_mux_single():

    reference = list(T.finite_generator(50))
    stream = pescador.Streamer(reference)

    mux = pescador.mux.Mux([stream], 1, with_replacement=False)
    estimate = list(mux)
    assert reference == estimate
예제 #8
0
파일: test_mux.py 프로젝트: hugovk/pescador
def test_mux_single_finite(mux_class):
    "Test a single finite streamer for each mux with an exhaustive setting."

    reference = list(T.finite_generator(50))
    stream = pescador.Streamer(reference)

    mux = mux_class([stream])
    estimate = list(mux)
    assert len(reference) == len(estimate)
    for i, d in enumerate(estimate):
        assert d.items() == estimate[i].items()
예제 #9
0
파일: test_mux.py 프로젝트: bmcfee/pescador
def test_mux_single_finite(mux_class):
    "Test a single finite streamer for each mux with an exhaustive setting."

    reference = list(T.finite_generator(50))
    stream = pescador.Streamer(reference)

    mux = mux_class([stream])
    estimate = list(mux)
    assert len(reference) == len(estimate)
    for i, d in enumerate(estimate):
        assert d.items() == estimate[i].items()
예제 #10
0
def test_streamer_generator_func():
    n_items = 10
    expected = list(T.finite_generator(n_items))
    streamer = pescador.core.Streamer(T.finite_generator, n_items)

    # Test generate interface
    actual1 = list(streamer)
    assert len(expected) == len(actual1) == n_items
    for b1, b2 in zip(expected, actual1):
        T._eq_batch(b1, b2)

    # Test __iter__ interface
    actual2 = list(streamer)
    assert len(expected) == len(actual2) == n_items
    for b1, b2 in zip(expected, actual2):
        T._eq_batch(b1, b2)
예제 #11
0
파일: test_mux.py 프로젝트: hugovk/pescador
def test_mux_single_infinite(mux_class):
    """Test a single finite streamer for each mux class which can revive it's
    streamers.
    """
    reference = list(T.finite_generator(50))
    stream = pescador.Streamer(reference)

    mux = mux_class([stream])
    estimate = list(mux.iterate(max_iter=100))

    assert len(estimate) == 2 * len(reference)
    reference = (reference + reference)
    for i in range(len(reference)):
        assert set(reference[i].keys()) == set(estimate[i].keys())
        for key in reference[i].keys():
            assert np.all(reference[i][key] == estimate[i][key])
예제 #12
0
def test_streamer_generator_func():
    n_items = 10
    expected = list(T.finite_generator(n_items))
    streamer = pescador.core.Streamer(T.finite_generator, n_items)

    # Test generate interface
    actual1 = list(streamer)
    assert len(expected) == len(actual1) == n_items
    for b1, b2 in zip(expected, actual1):
        T._eq_batch(b1, b2)

    # Test __iter__ interface
    actual2 = list(streamer)
    assert len(expected) == len(actual2) == n_items
    for b1, b2 in zip(expected, actual2):
        T._eq_batch(b1, b2)
예제 #13
0
파일: test_mux.py 프로젝트: bmcfee/pescador
def test_mux_single_infinite(mux_class):
    """Test a single finite streamer for each mux class which can revive it's
    streamers.
    """
    reference = list(T.finite_generator(50))
    stream = pescador.Streamer(reference)

    mux = mux_class([stream])
    estimate = list(mux.iterate(max_iter=100))

    assert len(estimate) == 2 * len(reference)
    reference = (reference + reference)
    for i in range(len(reference)):
        assert set(reference[i].keys()) == set(estimate[i].keys())
        for key in reference[i].keys():
            assert np.all(reference[i][key] == estimate[i][key])
예제 #14
0
def test_streamer_finite(n_max, stream_size, generate):
    reference = list(T.finite_generator(50, size=stream_size))

    if n_max is not None:
        reference = reference[:n_max]

    streamer = pescador.core.Streamer(T.finite_generator, 50, size=stream_size)

    if generate:
        gen = streamer.iterate(max_iter=n_max)
    else:
        gen = streamer(max_iter=n_max)

    for i in range(3):

        query = list(gen)
        for b1, b2 in zip(reference, query):
            T._eq_batch(b1, b2)
예제 #15
0
def test_streamer_finite(n_max, stream_size, generate):
    reference = list(T.finite_generator(50, size=stream_size))

    if n_max is not None:
        reference = reference[:n_max]

    streamer = pescador.core.Streamer(T.finite_generator, 50, size=stream_size)

    if generate:
        gen = streamer.iterate(max_iter=n_max)
    else:
        gen = streamer(max_iter=n_max)

    for i in range(3):

        query = list(gen)
        for b1, b2 in zip(reference, query):
            T._eq_batch(b1, b2)