예제 #1
0
def test_gaja_gajajhampa_gajalila():
    gaja = Decitala("Gaja")
    gajajhampa = Decitala("77_Gajajhampa")
    gajalila = Decitala("18_Gajalila.xml")

    assert gaja.name == "99_Gaja"
    assert gajajhampa.name == "77_Gajajhampa"
    assert gajalila.name == "18_Gajalila"
예제 #2
0
def test_jaya_jayacri_jayamangala():
    jaya = Decitala("Jaya")
    jaya2 = Decitala("Jaya.xml")
    jayacri = Decitala("46_Jayacri")
    jayamangala = Decitala("Jayamangala.xml")

    assert jaya.name == "28_Jaya"
    assert jaya2.name == "28_Jaya"
    assert jayacri.name == "46_Jayacri"
    assert jayamangala.name == "42_Jayamangala"
예제 #3
0
def test_all_decitala_names():
    # 4 possible inputs are allowed for the names.
    funcs = [
        full_name, without_extension, without_id_num,
        without_id_num_without_extension
    ]
    for this_file in os.listdir(decitala_path):
        new_name = random.choice(funcs)(this_file)
        this_decitala = Decitala(new_name)
        assert this_decitala.full_path == decitala_path + "/" + this_file
예제 #4
0
def test_decitala_hash_table():
    DHT = DecitalaHashTable()
    fragment_data = session.query(DecitalaData).all()
    fragments = [Decitala(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 = DHT.data[modification]

        assert search_result is not None
예제 #5
0
def decitala_collection():
    talas = [
        {
            "fragment": Decitala("75_Pratapacekhara"),
            "mod": ('sr', 0.6666666666666666),
            "onset_range": (2.0, 6.25)
        },
        {
            "fragment": Decitala("93_Ragavardhana"),
            "mod": ('rsr', 2.0),
            "onset_range": (2.0, 6.75)
        },
        {
            "fragment": Decitala("Karanayati"),
            "mod": ('r', 1.0),
            "onset_range": (0.0, 1.0)
        },
        {
            "fragment": Decitala("5_Pancama"),
            "mod": ('r', 4.0),
            "onset_range": (2.0, 4.0)
        },
    ]
    return talas
예제 #6
0
def test_write_analysis():
    f1 = Decitala("Lakskmica")
    f2 = GreekFoot("Peon_III")
    f3 = GeneralFragment([4.0, 4.0, 4.0, 1.0], name="weird fragment set")
    analysis = [{
        "fragment": f1,
        "onset_range": (3.0, 9.0)
    }, {
        "fragment": f2,
        "onset_range": (9.5, 12.25)
    }, {
        "fragment": f3,
        "onset_range": (12.0, 13.125)
    }]
    with tempfile.NamedTemporaryFile() as tmpfile:
        utils.write_analysis(data=analysis, filepath=tmpfile.name)
        # Reread to check proper serialization.
        loaded = utils.loader(tmpfile.name)
        fragments = [x["fragment"] for x in loaded]
        assert set(fragments) == set([f1, f2, f3])
예제 #7
0
def test_loader():
    loaded = utils.loader(analysis_filepath)
    fragments = set([x["fragment"] for x in loaded])
    actual = {Decitala("Laya"), Decitala("Bhagna"), Decitala("Niccanka")}

    assert fragments == actual
예제 #8
0
def test_ragavardhana():
    DHT = DecitalaHashTable()
    frag = [3.0, 0.5, 0.75, 0.5]
    assert DHT.data[tuple(frag)]["fragment"] == Decitala("Ragavardhana")
예제 #9
0
def test_sama_kankala_sama():
    sama = Decitala("Sama.xml")
    kankala_sama = Decitala("Kankala_Sama")

    assert sama.name == "53_Sama"
    assert kankala_sama.name == "65_C_Kankala_Sama"
예제 #10
0
 def test_class_one(self):  # X
     aditala = Decitala("Aditala")
     assert aditala.morris_symmetry_class() == 1
예제 #11
0
def test_decitala_fragment_encoder():
    d = Decitala("Anlarakrida")
    dumped = json.dumps(d, cls=FragmentEncoder)
    expected = """{"frag_type": "decitala", "name": "95_Anlarakrida"}"""

    assert dumped == expected
예제 #12
0
def test_decitala_num_matras():
    frag = Decitala("Rajatala")  # [1.0, 1.5, 0.25, 0.25, 1.0, 0.5, 1.5]
    assert frag.num_matras == 12
예제 #13
0
def test_decitala_repr():
    name_in = "Gajalila"
    frag_id = Decitala(name_in).id_num
    assert Decitala(
        name_in).__repr__() == "<fragment.Decitala {0}_{1}>".format(
            frag_id, name_in)
예제 #14
0
def test_decitala_carnatic_string():
    rajacudamani = Decitala("Rajacudamani")
    predicted = "o o | | | o o | S"
    assert rajacudamani.carnatic_string == predicted
예제 #15
0
def test_id_num():
    for i in range(0, 121, 20):
        if i == 0:
            assert Decitala("Aditala").id_num == str(i + 1)
        else:
            assert Decitala.get_by_id(i).id_num == str(i)
예제 #16
0
def test_get_by_id():
    random_nums = [str(x) for x in [71, 23, 14, 91, 108, 44]]
    for this_id in random_nums:
        assert Decitala.get_by_id(this_id) is not None