예제 #1
0
 def startGen(self):
     from testfunc import test
     if not self.dataGenPath:
         self.showError("Ошибка", "Нет датасета", "Выберите папку с датасетом")
         self.select_dataGenPath()
     elif not self.XtoYPath:
         self.showError("Ошибка", "Нет Модели", "Выберите файл модели XtoY")
         self.select_XtoY()
     elif not self.YtoXPath:
         self.showError("Ошибка", "Нет Модели", "Выберите файл модели YtoX")
         self.select_YtoX()
     else:
         test(dataset=self.dataGenPath, imSize = self.imsizeGen, genXtoY = self.XtoYPath, genYtoX = self.YtoXPath)
예제 #2
0
def main():
    add_result = addition(10, 20)
    test_equal("Addition", add_result, 30)

    sub_result = subtraction(60, 20)
    test_equal("Subbtraction", sub_result, 40)

    mul_result = multiplication(40, 50)
    test_equal("Multiplication", 2000)

    div_result = division(60, 2)
    test_equal("Division", 30)

    gen_str_result = gen_str("Hello", "World!")
    test_equal("Generate Str", gen_str_result, "HelloWorld!")

    gen_list_result = gen_list(1, 5)
    test_equal("Generate List", gen_list_result, [1, 1, 1, 1, 1])

    judge_result = judge_value(10, 20)
    test("Judge Value", not judge_result)
예제 #3
0
from testfunc import test

test(dataset="datasets/horse2zebra",
     batch=1,
     imSize=128,
     cuda=True,
     genXtoY="minecraftday2night/weights/netXtoY.pth",
     genYtoX="minecraftday2night/weights/netYtoX.pth")
예제 #4
0
# Задача-4:
# Даны четыре точки А1(х1, у1), А2(x2 ,у2), А3(x3 , у3), А4(х4, у4).
# Определить, будут ли они вершинами параллелограмма.
# Комментарий: используется свойство - диагонали параллелограмма делятся пополам в одной точке.
# Дополнительно проверяется равенство любых 2-х точек, что позволяет выявить вырожденный случай, когда
# все 4 точки равны. Для уменьшения числа операций можно рядом с a1==a3 сравнивать через or a2==a4.
def isparallelogramm(a1, a2, a3, a4):
    def centerpoint(a, b):
        return ((a[0] + b[0]) / 2, (a[1] + b[1]) / 2)

    if a1 == a3: return False
    return centerpoint(a1, a3) == centerpoint(a2, a4)


print("Задача 1. Ряд Фибоначчи.")
test("2-5", fibonacci(2, 5), [2, 3, 5, 8])
test("0-4", fibonacci(0, 4), [1, 1, 2, 3, 5])
test("1-8", fibonacci(1, 8), [1, 2, 3, 5, 8, 13, 21, 34])

print("\nЗадача 2. Сортировка.")
test("1", sort_to_max([8, 7, 6, 5, 4, 3, 2, 1]), [1, 2, 3, 4, 5, 6, 7, 8])
test("2", sort_to_max([8, 7, 12, 6, 10, 5, 9, 4, 3, 11, 2, 1]),
     [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])

print("\nЗадача 3. Filter")
test("my_filter 1", my_filter(lambda x: x >= 0, [-1, 2, 4, -8, 0, 6]),
     [2, 4, 0, 6])
test("my_filter 2", my_filter(lambda x: x > 1, [-1, 2, 4, -8, 0, 6]),
     [2, 4, 6])
test("my_iter_filter 1",
     list(my_iter_filter(lambda x: x >= 0, [-1, 2, 4, -8, 0, 6])),
예제 #5
0
from testfunc import test
# from pt_recursive import solve
# from pt_iteration1 import solve
# from pt_combination3 import solve
from pt_final import solve

test_data1 = [((1, 1), 1), ((2, 1), 1), ((2, 2), 1), ((3, 1), 1), ((3, 2), 2),
              ((3, 3), 1), ((4, 2), 3), ((5, 2), 4), ((5, 3), 6), ((9, 5), 70)]

# large value
test_data2 = [((30, 15), 77558760), ((100, 50), 50445672272782096667406248628),
              ((30000, 30000), 1), ((30000, 29998), 449955001)]

# illegal input
test_data3 = [((1, 2), None), (('1', 1), None), ((1, -1), None),
              ((1, 100000), None)]

test(solve, test_data1)
test(solve, test_data2)
# test(solve, test_data3)