예제 #1
0
def main():
    value = 5.0
    cysqrtm_result = cyforksqrt.sqrtm(value)
    cysqrtm_time = timeit.timeit("cyforksqrt.sqrtm(" + str(value) + ")",
                                 setup="import cyforksqrt")
    print_results("cyforksqrt.sqrtm", cysqrtm_result, cysqrtm_time)

    cysqrt2_result = cyforksqrt.sqrt2(value)
    cysqrt2_time = timeit.timeit("cyforksqrt.sqrt2(" + str(value) + ")",
                                 setup="import cyforksqrt")
    print_results("cyforksqrt.sqrt2", cysqrt2_result, cysqrt2_time)

    forksqrt2_result = forksqrt.sqrt2(value, False)
    forksqrt2_time = timeit.timeit("forksqrt.sqrt2(" + str(value) + ", False)",
                                   setup="import forksqrt")
    print_results("forksqrt.sqrt2", forksqrt2_result, forksqrt2_time)

    mathsqrt_result = math.sqrt(value)
    mathsqrt_time = timeit.timeit("math.sqrt(" + str(value) + ")",
                                  setup="import math")
    print_results("math.sqrt", mathsqrt_result, mathsqrt_time)
예제 #2
0
def test_sqr2_neg_val():
    sqrt2(Decimal(-5))
예제 #3
0
def test_sqrt2():
    for i in range(1, 100):
        assert round(float(sqrt2(i)), 15) == round(math.sqrt(i), 15)
예제 #4
0
def test_sqrt2_char():
    sqrt2("hello")
예제 #5
0
def test_sqrt2_neg_val():
    forksqrt.sqrt2(-10, False)
예제 #6
0
def test_sqrt2():
    assert float(forksqrt.sqrt2(5, False)) == float('{:.14f}'.format(
        math.sqrt(5)))
예제 #7
0
def test_sqrt2_char():
    forksqrt.sqrt2('Kohlefaser', False)