def test_sources_and_sinks():
    fragments = rolling_hash_search(filepath=st2,
                                    part_num=0,
                                    table=GreekFootHashTable())
    sources, sinks = path_finding_utils.sources_and_sinks(fragments)

    assert len(sources) == 2
    assert len(sinks) == 3
Exemplo n.º 2
0
def test_peons():
    GFHT = GreekFootHashTable()
    p1 = GreekFoot("Peon_I")
    p2 = GreekFoot("Peon_II")
    p3 = GreekFoot("Peon_III")
    p4 = GreekFoot("Peon_IV")
    peons = [p1, p2, p3, p4]

    for p in peons:
        assert GFHT.data[p.ql_tuple()]["fragment"] == p
Exemplo n.º 3
0
def test_greek_foot_hash_table():
    GFHT = GreekFootHashTable()
    fragment_data = session.query(GreekFootData).all()
    fragments = [GreekFoot(x.name) for x in fragment_data]
    for fragment in fragments:
        modification_and_mod_val = random.choice(funcs)(fragment.ql_array())
        if any(x <= 0 for x in modification_and_mod_val[0]):
            continue

        modification = tuple(modification_and_mod_val[0])
        mod_value = modification_and_mod_val[1]
        search_result = GFHT.data[modification]

        assert search_result is not None
Exemplo n.º 4
0
def test_create_database():
	with tempfile.NamedTemporaryFile() as tmpfile:
		db_path = tmpfile.name + ".db"
		create_database(
			db_path = db_path,
			filepath = os.path.dirname(here) + "/tests/static/Shuffled_Transcription_2.xml",
			table = GreekFootHashTable(),
			part_nums = [0],
		)
		engine = get_engine(filepath=db_path)
		session = get_session(engine=engine)

		comps = session.query(CompositionData).all()
		assert comps[0].name == "Shuffled_Transcription_2.xml"
		assert comps[0].part_num == 0

		frags = session.query(Extraction).all()
		assert [x.fragment_type == "greek_foot" for x in frags]
Exemplo n.º 5
0
def s1_fragments():
    return rolling_hash_search(filepath=filepath,
                               part_num=0,
                               table=GreekFootHashTable())
Exemplo n.º 6
0
def test_stretch_augmentation():
    GFHT = GreekFootHashTable()
    nc_ex2 = [0.125, 0.5]  # Described as "Iambique".
    found = GFHT.data[tuple(nc_ex2)]
    assert found["fragment"].name == "Iamb"
    assert found["mod_hierarchy_val"] == 7  # Stretch augmentation