Пример #1
0
 def update(self, R2, name):
     if R2 == 4:
         conn = pymysql.connect(host='127.0.0.1',
                                user='******',
                                password='******',
                                db='javap',
                                charset='utf8')
         try:
             with conn.cursor() as cursor:
                 sql = "update pypeople set answer=answer+1 where person = %s"
                 cursor.execute(sql, name)
             conn.commit()
         finally:
             conn.close()
     q3.q3(name)
Пример #2
0
def main():
    # q4(200, 0.2, 0.0, 8, 8, 50)
    times = 50
    import q3
    draft = q3.q3(times, True)

    alpha = 0.2
    epsilon = 0.01
    num_tilings = 32
    num_tiles = 4
    better_list, build_polt = find_better_parameters(times, alpha, epsilon,
                                                     num_tilings, num_tiles,
                                                     draft)

    if build_polt:
        title = "alpha={a},epsilon={b},num_tilings={c},num_tiles={d}".format(
            a=alpha, b=epsilon, c=num_tilings, d=num_tiles)
        plot_with_title(better_list, title)
    alpha1 = 0.5
    better_list1, build_polt1 = find_better_parameters(times, alpha1, epsilon,
                                                       num_tilings, num_tiles,
                                                       draft)

    if build_polt1:
        title = "alpha={a},epsilon={b},num_tilings={c},num_tiles={d}".format(
            a=alpha1, b=epsilon, c=num_tilings, d=num_tiles)
        plot_with_title(better_list1, title)

    plot1(draft, better_list, better_list1)
Пример #3
0
from q1 import q1
from q2 import q2
from q3 import q3
from q4 import q4
from q5 import q5

print "Question 1"
q1()
raw_input()

print "Question 2"
q2()

print "Question 3"
q3()

print "Question 4"
q4()

print "Question 5"
q5()
Пример #4
0
        [-1.5, 1.5, 0],
        [-0.65, -0.65, 2.5],
        [0.65, -0.65, 2.5],
        [0.65, 0.65, 2.5],
        [-0.65, 0.65, 2.5],
    ])

    # # PRIMEIRA QUESTÃO
    q1(cube_points, parallel_points, pyramid_points, tronco_points)

    # SEGUNDA QUESTÃO
    cube_points, parallel_points, pyramid_points, tronco_points = q2(
        cube_points, parallel_points, pyramid_points, tronco_points)
    # TERCEIRA QUESTÃO
    c_points, p_points = q3(copy(cube_points), copy(pyramid_points),
                            copy(parallel_points), copy(tronco_points),
                            np.array([3, -3, 3]), True)

    # QUARTA QUESTÃO
    q4(c_points, p_points, True)

    # OPCIONAL
    eyes = [np.array([i, -3, 3]) for i in np.arange(-2, 8, .5)]
    for i, eye in enumerate(eyes):
        # TERCEIRA QUESTÃO
        c_points, p_points = q3(copy(cube_points), copy(pyramid_points),
                                copy(parallel_points), copy(tronco_points),
                                eye)

        # QUARTA QUESTÃO
        q4(c_points, p_points, show=False)
Пример #5
0
def test_start_from_right_end():
    assert q3([6, 6]) == 8
Пример #6
0
def test_example_1():
    assert q3([6, 2]) == 12
Пример #7
0
def test_invalid_argument():
    with pytest.raises(TypeError):
        q3([5000, 'k'])
    with pytest.raises(ValueError):
        q3([5000])
Пример #8
0
def test_large_a1():
    with pytest.raises(ValueError):
        q3([5000, 10000])
Пример #9
0
def test_large_n():
    assert q3([1000000, 500000]) == 250000250710
Пример #10
0
def test_start_from_left_end():
    assert q3([9, 1]) == 20
Пример #11
0
def main():
    q1()
    q2()
    q3()
    q4()
Пример #12
0
def main():
    q1()
    q2()
    q3()
    q4()