Exemple #1
0
def test_exercise_6():
    P4_list = [1,-2,-3,4]
    P4 = pd.Series(P4_list)
    P5_list = [1,3,2,-4]
    P5 = pd.Series(P5_list)
    ncycles = Lab7.cycles(Lab7.genome_to_graph([P4]),Lab7.genome_to_graph([P5]))
    assert answers['exercise6_ncycles'] == ncycles
Exemple #2
0
def test_exercise_3():
    P_list2 = [3,4,5,-12,-8,-7,-6,1,2,10,9,-11,13,14]
    P2 = pd.Series(P_list2,index=list(range(1,len(P_list2)+1)))
    nbreakpoints_P2 = Lab7.count_breakpoints(P2)
    P_list3 = [3,4,5,-12,-8,-7,-6,1,2,10,9,-11,14,13]
    P3 = pd.Series(P_list3,index=list(range(1,len(P_list2)+1)))
    nbreakpoints_P3 = Lab7.count_breakpoints(P3)
    assert answers["exercise_3_nbreakpoints_P2"] == nbreakpoints_P2
    assert answers["exercise_3_nbreakpoints_P3"] == nbreakpoints_P3
Exemple #3
0
def test_exercise_7():
    P6_list = [1,2,3,4,5,6]
    P6 = pd.Series(P6_list)
    P7_list = [1,-3,-6,-5]
    P7 = pd.Series(P7_list)
    P8_list = [2,-4]
    P8 = pd.Series(P8_list)
    distance = Lab7.two_break_distance(Lab7.genome_to_graph([P6]),Lab7.genome_to_graph([P7,P8]))
    assert answers['exercise7_distance'] == distance
Exemple #4
0
def test_exercise_5():
    P4_list = [1,-2,-3,4]
    P4 = pd.Series(P4_list)
    P5_list = [1,3,2,-4]
    P5 = pd.Series(P5_list)

    G_P4_P5 = Lab7.combine(Lab7.genome_to_graph([P4]),Lab7.genome_to_graph([P5]))
    answers['exercise5_edge_list'] = fix_edge_list(answers['exercise5_edge_list'])
    edge_list = fix_edge_list(Lab7.to_edge_list(G_P4_P5))    
    assert set(answers['exercise5_edge_list']) == set(edge_list)
Exemple #5
0
 def test_edit_distance(self):
     string = [
         "Pittsburgh", "Pennsylvania", "Tucson", "Arizona", "Cincinnati",
         "Ohio", "Albuquerque", "New Mexico", "Culpeper", "Virginia",
         "Asheville", "North Carolina", "Worcester", "Massachusetts",
         "Manhattan", "New York", "Phoenix", "Arizona", "Niagara Falls",
         "New York"
     ]
     ##        string1 = "Sunday"
     ##        string2 = "Saturday"
     for i in range(len(string)):
         if i + 1 == len(string):
             return
         string1 = string[i]
         string2 = string[i + 1]
         print(string1, string2)
         Lab7.edit_distance(string1, string2, len(string1), len(string2))
def main():
    ## First test case
    s = 0
    t = 0
    z = Lab7.findSecretVector(s, t)
    print("The result for the first test case is: \n")
    print(z)
    print()

    ## Second test case
    s = 1 * one
    t = 1 * one
    z = Lab7.findSecretVector(s, t)
    print("The result for the second test case is: \n")
    print(z)
    print()

    ## Third teste case
    s = 1 * one
    t = 0
    z = Lab7.findSecretVector(s, t)
    print("The result for the third test case is: \n")
    print(z)
    print()
Exemple #7
0
def test_show_message_none():
    assert Lab7.show_message(None) == "Hi, you sent: None"
Exemple #8
0
def test_show_message():
    assert Lab7.show_message('Howdy, howdy my little friend'
                             ) == "Hi, you sent: Howdy, howdy my little friend"
Exemple #9
0
def test_sum_of_values_none():
    with pytest.raises(TypeError):
        Lab7.sum_of_values(None)
Exemple #10
0
def test_sum_of_values_err():
    with pytest.raises(ValueError):
        Lab7.sum_of_values((1, 3, 5, 7))
Exemple #11
0
def test_another_process_none():
    with pytest.raises(AttributeError):
        Lab7.another_process(None)
Exemple #12
0
def test_process_text_none():
    with pytest.raises(TypeError):
        Lab7.process_text(None)
Exemple #13
0
def test_exercise_9():
    steps = Lab7.shortest_rearrangement_scenario([pd.Series([1,-2,-3,4])],[pd.Series([1,2,-4,-3])])
    assert answers['exercise9_last_step'] == steps[-1]
Exemple #14
0
def test_exercise_8():
    test_edge_cycle = [[1, -3], [-3, -4], [-4, -1], [-1, 4], [4, 2], [2, 1]]
    checked_cycle, colors = Lab7.red_blue_cycle_check(Lab7.G_P4_P5,test_edge_cycle)
    assert np.all(answers['exercise8_colors'] == colors)
Exemple #15
0
def test_exercise_4():
    G = Lab7.genome_to_graph([pd.Series([1,-2,-3,4]),pd.Series([5,6,7,8,9,10])])
    edge_list = fix_edge_list(Lab7.to_edge_list(G))
    answers['exercise4_edge_list'] = fix_edge_list(answers['exercise4_edge_list'])
    assert set(answers['exercise4_edge_list']) == set(edge_list)
Exemple #16
0
def test_potentially_unsafe_func():
    result = Lab7.potentially_unsafe_func('name')
    assert result == 'test'
Exemple #17
0
def test_process_text():
    result = Lab7.process_text(
        'the French revolution resulted in 3 concepts: freedom,equality,fraternity'
    )
    assert result == 'thE FrencH RevolutioN ResulteD IN 3 Concepts  Freedom equality fraternity'
Exemple #18
0
def test_potentially_unsafe_func_none():
    with pytest.raises(TypeError):
        Lab7.potentially_unsafe_func(None, None)
Exemple #19
0
def test_another_process():
    result = Lab7.another_process(
        'the French revolution resulted in 3 concepts: freedom,equality,fraternity'
    )
    assert result == 'thE FrencH RevolutioN ResulteD IN 3 ConceptS  FreedoM EqualitY Fraternity'
Exemple #20
0
def test_sum_of_values():
    result = Lab7.sum_of_values((1, 3, 5))
    assert result == 9
Exemple #21
0
def test_potentially_unsafe_func_silented():
    result = Lab7.potentially_unsafe_func('abc')
    assert result is None
Exemple #22
0
def test_exercise_2():
    answer = Lab7.greedy_sorting(Lab7.P)
    assert answers["exercise_2"] == answer