Jan 24, 2012

Show all values in Numpy array

If an array is too large to be printed, (Scipy)NumPy automatically skips the central part of the array and only prints the corners:

>>> print arange(10000)
[   0    1    2 ..., 9997 9998 9999]
>>>
>>> print arange(10000).reshape(100,100)
[[   0    1    2 ...,   97   98   99]
 [ 100  101  102 ...,  197  198  199]
 [ 200  201  202 ...,  297  298  299]
 ...,
 [9700 9701 9702 ..., 9797 9798 9799]
 [9800 9801 9802 ..., 9897 9898 9899]
 [9900 9901 9902 ..., 9997 9998 9999]]
    


To disable this behaviour and force NumPy to print the entire array, you can change the printing options using

set_printoptions
.

>>> set_printoptions(threshold='nan')

No comments: