qtconsole: indentation problem printing numpy arrays #510

Closed
mspacek opened this Issue Jun 10, 2011 · 2 comments

Projects

None yet

2 participants

@mspacek
Contributor
mspacek commented Jun 10, 2011

In ipython --pylab=qt I get this:

In [1]: a = np.zeros((2,3,4), dtype=np.int16)

In [2]: a
Out[2]: 
array([[[0, 0, 0, 0],
        [0, 0, 0, 0],
        [0, 0, 0, 0]],

       [[0, 0, 0, 0],
        [0, 0, 0, 0],
        [0, 0, 0, 0]]], dtype=int16)

In [3]: 

Looks good. In ipython-qtconsole pylab=qt I get this:

In [1]: a = np.zeros((2,3,4), dtype=np.int16)

In [2]: a
Out[2]: array([[[0, 0, 0, 0],
        [0, 0, 0, 0],
        [0, 0, 0, 0]],

       [[0, 0, 0, 0],
        [0, 0, 0, 0],
        [0, 0, 0, 0]]], dtype=int16)

In [3]: pprint
Pretty printing has been turned OFF

In [4]: a
Out[4]: array([[[0, 0, 0, 0],
        [0, 0, 0, 0],
        [0, 0, 0, 0]],

       [[0, 0, 0, 0],
        [0, 0, 0, 0],
        [0, 0, 0, 0]]], dtype=int16)

In [5]: import pprint as pp

In [6]: pp.pprint(a)
array([[[0, 0, 0, 0],
        [0, 0, 0, 0],
        [0, 0, 0, 0]],

       [[0, 0, 0, 0],
        [0, 0, 0, 0],
        [0, 0, 0, 0]]], dtype=int16)

In [7]: 

So, there's an indentation problem printing arrays that isn't affected by the pprint magic toggle. Printing the array out using pprint.pprint() fixes the indentation problem, but then it doesn't show up on an [Out] line. I guess all that's missing in the qtconsole case is a newline after the [Out] prompt and before the array printout.

@takluyver takluyver added a commit to takluyver/ipython that referenced this issue Jun 10, 2011
@takluyver takluyver Add a new line before displaying multiline strings in the Qt console.
Closes gh-510
7445090
Owner

Made PR #511.

Contributor
mspacek commented Jun 10, 2011

Works for me. Thanks!

@takluyver takluyver closed this in 4066b42 Jun 10, 2011
@mattvonrocketstein mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014
@takluyver takluyver Add a new line before displaying multiline strings in the Qt console.
Closes gh-510
e6c5746
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment