a1 = np.asmatrix(a1)
a2 = np.asmatrix(a2)
a3 = np.asmatrix(a3)
z = np.asmatrix(np.zeros((3, 3)))
r = np.asarray(np.bmat('a1, z, z; z, a2, z; z, z, a3'))
How can I transform blocks into a blockdiagonal matrix (NumPy)