[IPython-user] NumPy display problem

Travis E. Oliphant oliphant.travis at ieee.org
Wed Jan 25 03:54:54 CST 2006


Ryan Krauss wrote:
> I just accidentally requested a 21000 element NumPy array be printed
> to the ipython terminal (by just typing the variable name at the
> interactive prompt).  It seems like this used to be handled gracefully
> by printing the first 100 or so elements and then a mesage about there
> being more elments.  But this isn't happening for me, instead it hangs
> for a few seconds and then prints the entire array.
> 
> Am I doing something wrong?

What are you running?  Are you really using NumPy or are you using Numeric?

In [1]: a = rand(21000)

In [2]: a
Out[2]:
array([ 0.72911787,  0.41493949,  0.88521075, ...,  0.3816934 ,
         0.71684723,  0.18389534])


NumPy has a limit in the number of elements that are printed.  The 
default is 1000 I think.  It can be changed using set_printoptions.

The code is adapted from NumArray so thank Perry Greenfield and friends 
for this very nice feature :-)

-Travis




More information about the IPython-user mailing list