Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't visualise 3D arrays with variables explorer #1464

Closed
theoroborus opened this issue Oct 10, 2019 · 5 comments
Closed

Can't visualise 3D arrays with variables explorer #1464

theoroborus opened this issue Oct 10, 2019 · 5 comments

Comments

@theoroborus
Copy link

Data science require visualising 3D arrays for testing/debugging purposes.

import numpy
array =  numpy.zeros((3,3,3))

When double clicking on the variable array in the variable explorer :

This array can't be visualised in the variable explorer, only 2D arrays are allowed.
Spyder displays it as a 2D array and allow to switch dimenssion and slice through the array.
Not super intuitive at first but works and should be easy to implement. It's just about extracting 2D from 3D.


Error: Failure during variable extraction:
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
c:\Users\Boris\Desktop\3Darray.py in <module>
     45         _VSCODE_df = _VSCODE_pd.Series.to_frame(_VSCODE_evalResult)
     46     elif _VSCODE_targetVariable['type'] == 'ndarray':
---> 47         _VSCODE_df = _VSCODE_pd.DataFrame(_VSCODE_evalResult)
     48 
     49     # If any rows, use pandas json to convert a single row to json. Extract

~\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\core\frame.py in __init__(self, data, index, columns, dtype, copy)
    438                 mgr = init_dict({data.name: data}, index, columns, dtype=dtype)
    439             else:
--> 440                 mgr = init_ndarray(data, index, columns, dtype=dtype, copy=copy)
    441 
    442         # For data is list-like, or Iterable (will consume into list)

~\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\core\internals\construction.py in init_ndarray(values, index, columns, dtype, copy)
    169     # by definition an array here
    170     # the dtypes will be coerced to a single dtype
--> 171     values = prep_ndarray(values, copy=copy)
    172 
    173     if dtype is not None:

~\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\core\internals\construction.py in prep_ndarray(values, copy)
    293         values = values.reshape((values.shape[0], 1))
    294     elif values.ndim != 2:
--> 295         raise ValueError("Must pass 2-d input")
    296 
    297     return values

ValueError: Must pass 2-d input


@rchiodo
Copy link
Contributor

rchiodo commented Oct 10, 2019

Sounds like we'll have to special case this in the dataviewer and in our extraction code. 3D arrays would need some sort of slicing mechanism.

@theoroborus
Copy link
Author

Slicing is what is done with Spyder.
http://www.noelshack.com/2019-41-4-1570725842-slice.png

@jmew
Copy link
Contributor

jmew commented Oct 10, 2019

TODO: add an error message

@rajkundu
Copy link

Possible duplicate of #1145?

@rchiodo
Copy link
Contributor

rchiodo commented Mar 31, 2021

This is actually fixed now.
https://devblogs.microsoft.com/python/jupyter-in-visual-studio-code-april-2021-release/

Thanks for noticing @rajkundu

@rchiodo rchiodo closed this as completed Mar 31, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants