Monday, December 12, 2011

Changing how numpy arrays are printed

Use numpy.set_printoptions. One of the things I like most about pylab (and numpy) is this flexibility, especially the summarization feature, which, when the array is very large, prints ellipses (...) instead of clobbering you with lines and lines of output. I like to set the threshold low (default is 1000) and I do this with pylab.set_printoptions(threshold=10)

1 comment:

  1. My favorite when working with nasty floats and exp format is precision = N. Makes the printed arrays much easier to read and reduces output file size.

    ReplyDelete