7

First of all, sorry if it's not the place to post this question, I know it is more related to the software I'm using to program than programming itself, but I figured someone here would probably know the answer.

I often use PyCharm (currently on version 2016.1.2) and its useful debugger to code in Python. I'm currently translating Matlab code to Python code and I often need to compare outputs of functions. In PyCharm's debugger, I can right click on a variable in the variable space and then press « View as array ». This gives me a nice grid view of my array (Excel kind of grid) and I can easily compare with my array in Matlab, which can also be displayed in a grid. However, sometimes, this option won't work in PyCharm and I don't know why! For example, I have a variable of type numpy.ndarray containing 137 by 60 floats and when I press « view as array », it displays the window, but instead of showing the grid, it shows « Nothing to show ». Curiously, I tried to copy the first 30 lines in another variable and this time PyCharm was able to show me the grid associated with this new variable. Usually, the number doesn't seem to be a problem. I tried to display a 500 by 500 array containing floats and it did just fine.

If someone could tell me why this happens and how I can overcome this problem, I'd be very glad. Also, if anyone has another way to display a matrix in Python in an elegant way, I'd take it too since it could also help me in my task!

Thanks!

3
  • You can try Spyder instead of PyCharm as it is closer to MATLAB's interface, but I don't think it's as stable as PyCharm. Commented Jun 30, 2016 at 16:06
  • 1
    Please provide a minimal reproducible example. Commented Jun 30, 2016 at 16:33
  • @excaza Is there a way I can copy the variable in question and put it as an example here? Commented Jun 30, 2016 at 17:33

2 Answers 2

7

I encountered the same problem when I tried to view a complex arrays with 'Color' check box checked. Unchecking the check box showed the array. Maybe some inf or nan value present in you array which does not allow to show colored array.

Sign up to request clarification or add additional context in comments.

Comments

0

You need to ensure that after you "view as array" you then enter the correct slice. I.e. if you view a color image which has shape (500, 1000, 3) as an array, the default slicing option will be image[0]. This is the first row of pixels and will appear as a (1000, 3) array. In order to see one of the three color channels you must change the slicing option to image[:, :, color], then you will see one of the three color channels slices appear as a (500, 1000) array.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.