3

I have a python list (A) and each entry of the list is a list that I would like to print out in matrix form (to compare with some other output). I can mostly 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, number of decimal places, etc. In that regard, I tried

print("{0:.3f}".format(np.array(A[i]).reshape(2*n+1,2*n+1)),'\n')

which throws the error non-empty format string passed to object.__format__.

How to I format the output and reshape it into something that looks like a matrix for printing?

laflij
  • 31
  • 1

0 Answers0