Printing arrays in matrix format
I have a python ( A
) list , and each list entry is a list that I would like to print in matrix form (for comparison with another output). I can basically accomplish this with:
print(np.array(A[i]).reshape(dim1,dim2),'\n')
...
However, I would also like to control the formatting of the output, i.e. scientific notation, decimal places, etc. In this respect I have tried
print("{0:.3f}".format(np.array(A[i]).reshape(2*n+1,2*n+1)),'\n')
which throws an error non-empty format string passed to object.__format__
.
How do I format the output and convert it to something that looks like a printable matrix?
source to share
No one has answered this question yet
See similar questions:
or similar: