I\'m working in PyCharm on Windows. In the project I\'m currently working on I have \"large\" matrices, but when i output them Pycharm automatically adds linebreaks so that one
PyCharm default console width is set to 80 characters.
Lines are printed without wrapping unless you set soft wrap
in options:
File -> Settings -> Editor -> General -> Console -> Use soft wraps in console
.
However both options make reading big matrices hard. You can fix this in few ways.
With this test code:
import random
m = [[random.random() for a in range(10)] for b in range(10)]
print(m)
You can try one of these:
Use pprint
module, and override line width:
import pprint
pprint.pprint(m, width=300)
For numpy version 1.13 and lower:
If you use numpy
module, configure arrayprint option:
import numpy
numpy.core.arrayprint._line_width = 300
print(numpy.matrix(m))
For numpy version 1.14 and above (thanks to @Alex Johnson):
import numpy
numpy.set_printoptions(linewidth=300)
print(numpy.matrix(m))
If you use pandas
module, configure display.width option:
import pandas
pandas.set_option('display.width', 300)
print(pandas.DataFrame(m))