def test_add_negatives(self): self.assertEqual(mylib.add(-1,3), 2)
def test_add_simple(self): self.assertEqual(mylib.add(1,1), 2)
# 모든 함수를 import from math import * n = sqrt(5) + fabs(-12.5) print(n) # factorial() 함수를 f()로 사용 가능 from math import factorial as f n = f(5) / f(2) print(n) import sys sys.path.append("C:\PySrc") for i in sys.path: print(i) from mylib import * i = add(10, 20) print(i) i = substract(20, 5) print(i) import mylib i = mylib.add(10, 20) print(i) i = mylib.substract(20, 5) print(i)
def test_add(): assert mylib.add(1, 1) == 2 assert not mylib.add(0, 1) == 2
import numpy as np import mylib print(mylib.add(1, 2)) a = mylib.make_ints(10) print(a) v_np = np.ones(shape=(200,), dtype=np.float32) print("sum(numpy): {}".format(mylib.sum(v_np))) print("sum_eigen(numpy): {}".format(mylib.sum_eigen(v_np))) v_l = [1.0, 1.0, 1.0, 1.0] print("sum(list): {}".format(mylib.sum(v_l))) print("sum_eigen(list): {}".format(mylib.sum_eigen(v_l))) a = np.array([ [120, 0, 320], [ 0, 120, 240], [ 0, 0, 1], ]) points = np.array([ [0, 0, 0], [0, 1, 0], [0, 0, 1] ]) res = mylib.mv_mul(a, points) print(res)