def test_chunk2doc_ranker_driver_traverse_apply_larger_range():
    docs = [create_chunk_chunk_matches_to_score()]
    driver = SimpleChunk2DocRankDriver(granularity_range=(0, 2))
    executor = MinRanker()
    driver.attach(executor=executor, pea=None)
    driver._traverse_apply(docs)
    for doc in docs:
        assert (len(doc.matches) == 1)
        assert (len(doc.chunks) == 1)
        chunk = doc.chunks[0]
        assert (len(chunk.matches) == 2)
        min_granularity_2 = chunk.matches[0].score.value
        for (idx, m) in enumerate(chunk.matches):
            if (m.score.value < min_granularity_2):
                min_granularity_2 = m.score.value
            assert (m.score.value == pytest.approx((1.0 / (1 + (m.id * 2.0))), 0.0001))
            assert (m.score.ref_id == 101)
        match = doc.matches[0]
        assert (match.score.ref_id == 100)
        assert (match.score.value == pytest.approx((1.0 / (1 + min_granularity_2)), 0.0001))
def test_chunk2doc_ranker_driver_traverse_apply_larger_range():
    docs = [create_chunk_chunk_matches_to_score()]
    driver = SimpleChunk2DocRankDriver(granularity_range=(0, 2))
    executor = MinRanker()
    driver.attach(executor=executor, pea=None)
    driver._traverse_apply(docs)
    for doc in docs:
        assert (len(doc.matches) == 1)
        assert (len(doc.chunks) == 1)
        chunk = doc.chunks[0]
        assert (len(chunk.matches) == 2)
        min_granularity_2 = chunk.matches[0].score.value
        for (idx, m) in enumerate(chunk.matches):
            if (m.score.value < min_granularity_2):
                min_granularity_2 = m.score.value
            assert (m.score.value == pytest.approx((1.0 / (1 + (m.id * 2.0))), 0.0001))
            assert (m.score.ref_id == 101)
        match = doc.matches[0]
        assert (match.score.ref_id == 100)
        assert (match.score.value == pytest.approx((1.0 / (1 + min_granularity_2)), 0.0001))