def test_rad2deg_int32(): rads = np.array([0, 1]).astype('int32') degs = rad2deg(rads) expected = np.rad2deg(rads) expect_eq(degs, expected)
def test_add(): expect_eq(double_i64(1), 2) expect_eq(double_i64(-1), -2) expect_eq(double_f64(1.0), 2.0) expect_eq(double_f64(-1.0), -2.0)
def test_2d_2d(): x = np.zeros((2, 3)) y = np.ones((2, 3)) res = add(x, y) expect_eq(res, x + y)
def test_rad2deg_bool(): rads = np.array([False,True]) degs = rad2deg(rads) expected = np.rad2deg(rads) expect_eq(degs, expected)
def test_sum(): expect_eq(sum_i64(np.array([1, 2, 3])), 6) expect_eq(sum_f64(np.array([-1.0, 1.0, 2.0])), 2.0)
def test_2d_scalar(): x = np.zeros((2,3)) res = add(x, 1) expect_eq(res, x + 1)
def test_square_scalars(): expect_eq(square(1), 1) expect_eq(square(2), 4) expect_eq(square(-2), 4) expect_eq(square(True), True) expect_eq(square(False), False) expect_eq(square(-4.0), 16.0)
def test_vec_add(): xs,ys = np.array([1,2,3]), np.array([10,20,30]) zs = vec_add(xs, ys) expected = xs + ys expect_eq(zs, expected)
def test_square_vectors(): expect_eq(square(intvec), intvec * intvec) expect_eq(square(floatvec), floatvec * floatvec)
def test_square_matrices(): expect_eq(square(intmat), intmat * intmat) expect_eq(square(floatmat), floatmat * floatmat)
def test_sum(): expect_eq(sum_i64(np.array([1,2,3])), 6) expect_eq(sum_f64(np.array([-1.0, 1.0, 2.0])), 2.0)
def test_rad2deg_int32(): rads = np.array([0,1]).astype('int32') degs = rad2deg(rads) expected = np.rad2deg(rads) expect_eq(degs, expected)
def test_rad2deg_float64(): rads = np.array([0.1, 0.2]).astype('float64') degs = rad2deg(rads) expected = np.rad2deg(rads) expect_eq(degs, expected)
def test_rad2deg_bool(): rads = np.array([False, True]) degs = rad2deg(rads) expected = np.rad2deg(rads) expect_eq(degs, expected)
def test_square_vectors(): expect_eq(square(intvec), intvec*intvec) expect_eq(square(floatvec), floatvec*floatvec)
def test_square_matrices(): expect_eq(square(intmat), intmat*intmat) expect_eq(square(floatmat), floatmat*floatmat)
def test_2d_2d(): x = np.zeros((2,3)) y = np.ones((2,3)) res = add(x, y) expect_eq(res, x + y)
def test_2d_scalar(): x = np.zeros((2, 3)) res = add(x, 1) expect_eq(res, x + 1)
def test_identity(): expect_eq(identity_i64(1), 1) expect_eq(identity_i64(-1), -1) expect_eq(identity_f64(1.0), 1.0) expect_eq(identity_f64(-1.0), -1.0)
def test_vec_add(): xs, ys = np.array([1, 2, 3]), np.array([10, 20, 30]) zs = vec_add(xs, ys) expected = xs + ys expect_eq(zs, expected)