Ribz
Ribz

Reputation: 551

How to prevent numpy array to split when using print?

I have a 8 by 8 numpy array with small numbers like 5.4231321e-10. When I print it, it gets split in two lines like this. So I cannot read it correctly.

array([[  5.41551e-10,   2.31361e-11,   1.79643e-09,   1.32782e-09,
          9.99061e-09,   1.37974e-10,   1.68653e-10,   2.61762e-10],
       [  3.21808e-10,   1.84807e-11,   9.93054e-10,   5.18492e-10,
          2.92982e-09,   8.94640e-11,   1.19873e-10,   1.37401e-10],
       [  1.04832e-09,   1.57888e-09,   3.33561e-10,   5.42693e-10,
          2.04617e-10,   1.96376e-08,   2.04300e-09,   2.84603e-09],
       [  1.57525e-09,   3.62806e-11,   7.63004e-09,   4.30767e-09,
          1.46114e-07,   2.87260e-10,   3.59310e-10,   5.61422e-10],
       [  9.47560e-10,   7.08887e-10,   3.26366e-10,   7.42231e-10,
          2.28443e-10,   1.12095e-08,   1.27734e-09,   5.86095e-09],
       [  4.37084e-09,   3.95485e-09,   9.89599e-10,   4.80913e-10,
          3.43515e-10,   4.04070e-08,   1.09085e-07,   8.75856e-10],
       [  3.15515e-10,   1.17984e-10,   3.39262e-10,   7.50043e-11,
          1.38889e-10,   1.59371e-10,   5.11399e-10,   5.60740e-11],
       [  1.08464e-09,   3.68540e-11,   1.94090e-09,   2.89622e-08,
          1.39165e-08,   3.58588e-10,   2.75284e-10,   1.97203e-09]])

I tried using set_printoptions(precision=1) but I got the same splitting problem.

Even though my screen is large enough.

enter image description here

Upvotes: 2

Views: 484

Answers (1)

Tejas
Tejas

Reputation: 165

You can customize it through "numpy.set_printoptions" function. https://docs.scipy.org/doc/numpy/reference/generated/numpy.set_printoptions.html

Here's the output for my screen: enter image description here

Upvotes: 3

Related Questions