Numpy arrays don't preview properly when debugging in 2.1 alpha


A picture is worth a thousand words.... Instead of showing the values in the numpy array like PTVS used to [i.e. (array([ 0.536]), array([-0.0801]))], in 2.1alpha it just shows the data type in the array. It also happens for non-array types like float64.

I was using VS2013 Ultimate with PTVS 2.1 alpha
Microsoft.PythonTools, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, FileVersion=2.1.20211.00

file attachments


Zooba wrote Feb 21 at 4:09 PM

Good catch.

We ran into some debugging issues with certain collections causing serious performance issues when debugging, which is why we made this change. We should definitely special case numpy collections, since we know they're well-behaved.

Currently we have a limit of around 15 items for built in collections, such that [0] * 14 would display as [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] but [0] * 16 would display as <list, len() = 16> (there's a limit of 10 for collections-inside-collections, and effectively a limit of 0 for deeper nesting). Regardless of the limit, you can always expand to see the individual elements - this only affects the top level summary.

Would applying this same limit to numpy arrays work for you? Or do you need to be able to see more than 15 values in the first tooltip without expanding/scrolling?

(Incidentally, if you want to hack around this, all the relevant code is in visualstudio_py_util.py in your install directory - the SafeRepr class does a lot to avoid performance problems when debugging, but it's easily tweakable.)

bde_fft wrote Mar 12 at 4:26 PM

Same "problem" here.

In addition, on 2.1 alpha and latest dev build (VS2012), expanding only show the item type, like <int32> :

[0] <int32>
[1] <int32>
[2] <int32>

This is not very handy. I can't manage to find the data by expending any of the items of the numpy array...
I'll take a look in SafeRepr but it would be nice to have access to the underlying data back at first expand (from my POV, the item limit for the summary is OK...)

Xycor wrote Jun 6 at 5:36 PM

Same issue in scipy. They probably look the same as numpy arrays to PTVS but scipy should be tested too.