11 rng = np.random.default_rng()
12 mat = np.array(np.ones((rows, cols)).astype(np.int32), dtype=dtype)
13 mat = rng.random((rows, cols)).astype(dtype)
15 assert (mat == mat_copy).all()
16 assert not (mat != mat_copy).all()
26 mat_op = mat.copy(order=
"F") + mat.copy(order=
"C")
30 mat_op = mat.dot(mat.T)
35 assert (mat >= mat).all()
36 assert (mat <= mat).all()
37 assert not (mat > mat).all()
38 assert not (mat < mat).all()
41 mat2_ref = mat.astype(np.double).dot(mat.T.astype(np.double))
42 assert np.isclose(mat2.astype(np.double), mat2_ref).all()
43 if np.__version__ >=
"1.17.0":
44 mat2 = np.matmul(mat, mat.T)
45 assert np.isclose(mat2.astype(np.double), mat2_ref).all()
49 np.can_cast(from_dtype, to_dtype)
51 from_mat = np.zeros((rows, cols), dtype=from_dtype)
52 to_mat = from_mat.astype(dtype=to_dtype)
55 test(user_type.CustomDouble)
57 test_cast(user_type.CustomDouble, np.double)
58 test_cast(np.double, user_type.CustomDouble)
60 test_cast(user_type.CustomDouble, np.int64)
61 test_cast(np.int64, user_type.CustomDouble)
63 test_cast(user_type.CustomDouble, np.int32)
64 test_cast(np.int32, user_type.CustomDouble)
66 test(user_type.CustomFloat)
68 v = user_type.CustomDouble(1)
70 assert type(v) == a.dtype.type