If you'd like something a bit more readable, you can do this:

A = np.squeeze(np.asarray(M))

Equivalently, you could also do: A = np.asarray(M).reshape(-1), but that's a bit less easy to read.


result = M.A1

https://numpy.org/doc/stable/reference/generated/numpy.matrix.A1.html

matrix.A1
1-d base array