11 mat = np.array(np.ones((rows, cols)).astype(np.intc), dtype=dtype)
12 mat = np.random.rand(rows, cols).astype(dtype)
14 assert (mat == mat_copy).all()
15 assert not (mat != mat_copy).all()
25 mat_op = mat.copy(order=
"F") + mat.copy(order=
"C")
29 mat_op = mat.dot(mat.T)
34 assert (mat >= mat).all()
35 assert (mat <= mat).all()
36 assert not (mat > mat).all()
37 assert not (mat < mat).all()
40 mat2_ref = mat.astype(np.double).dot(mat.T.astype(np.double))
41 assert np.isclose(mat2.astype(np.double), mat2_ref).all()
42 if np.__version__ >=
"1.17.0":
43 mat2 = np.matmul(mat, mat.T)
44 assert np.isclose(mat2.astype(np.double), mat2_ref).all()
48 np.can_cast(from_dtype, to_dtype)
50 from_mat = np.zeros((rows, cols), dtype=from_dtype)
51 to_mat = from_mat.astype(dtype=to_dtype)
54 test(user_type.CustomDouble)
56 test_cast(user_type.CustomDouble, np.double)
57 test_cast(np.double, user_type.CustomDouble)
59 test_cast(user_type.CustomDouble, np.int64)
60 test_cast(np.int64, user_type.CustomDouble)
62 test_cast(user_type.CustomDouble, np.int32)
63 test_cast(np.int32, user_type.CustomDouble)
65 test(user_type.CustomFloat)
67 v = user_type.CustomDouble(1)
69 assert type(v) == a.dtype.type