Skip to content

"Failure during variable extraction" when opening data explorer  #3423

@luabud

Description

@luabud

VS Code Insiders 1.34.0
Extension version 2019.5.6963-dev

I ran a piece of code in the Python interactive window and then clicked on "Show variable in data explorer" for a ndarray. This is the error I got:

image

Developer tools output:

workbench.main.js:236 [Extension Host] Python Extension: Failure during variable extraction:
---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
<ipython-input-2-45f79c0cea73> in <module>
     36         _VSCODE_columnNames = list(_VSCODE_evalResult)
     37     elif _VSCODE_targetVariable['type'] == 'ndarray':
---> 38         _VSCODE_evalResult = _VSCODE_pd.Series(_VSCODE_evalResult)
     39         _VSCODE_evalResult = _VSCODE_pd.Series.to_frame(_VSCODE_evalResult)
     40         _VSCODE_columnTypes = list(_VSCODE_evalResult.dtypes)

~\AppData\Local\Programs\Python\Python37\lib\site-packages\pandas\core\series.py in __init__(self, data, index, dtype, name, copy, fastpath)
    260             else:
    261                 data = sanitize_array(data, index, dtype, copy,
--> 262                                       raise_cast_failure=True)
    263 
    264                 data = SingleBlockManager(data, index, fastpath=True)

~\AppData\Local\Programs\Python\Python37\lib\site-packages\pandas\core\internals\construction.py in sanitize_array(data, index, dtype, copy, raise_cast_failure)
    656     elif subarr.ndim > 1:
    657         if isinstance(data, np.ndarray):
--> 658             raise Exception('Data must be 1-dimensional')
    659         else:
    660             subarr = com.asarray_tuplesafe(data, dtype=dtype)

Exception: Data must be 1-dimensional (at r.logError (C:\Users\luabud\.vscode-insiders\extensions\ms-python.python-2019.5.6963-dev\out\client\extension.js:1:16640))
t.log @ workbench.main.js:236
workbench.main.js:2362 Error: Failure during variable extraction: --------------------------------------------------------------------------- Exception                                 Traceback (most recent call last) <ipython-input-2-45f79c0cea73> in <module>      36         _VSCODE_columnNames = list(_VSCODE_evalResult)      37     elif _VSCODE_targetVariable['type'] == 'ndarray': ---> 38         _VSCODE_evalResult = _VSCODE_pd.Series(_VSCODE_evalResult)      39         _VSCODE_evalResult = _VSCODE_pd.Series.to_frame(_VSCODE_evalResult)      40         _VSCODE_columnTypes = list(_VSCODE_evalResult.dtypes)  ~\AppData\Local\Programs\Python\Python37\lib\site-packages\pandas\core\series.py in __init__(self, data, index, dtype, name, copy, fastpath)     260             else:     261                 data = sanitize_array(data, index, dtype, copy, --> 262                                       raise_cast_failure=True)     263      264                 data = SingleBlockManager(data, index, fastpath=True)  ~\Ap...
onDidNotificationChange @ workbench.main.js:2362

Code:

print(__doc__)


# Code source: Gaël Varoquaux
# Modified for documentation by Jaques Grobler
# License: BSD 3 clause

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from sklearn import datasets
from sklearn.decomposition import PCA

# import some data to play with
iris = datasets.load_iris()
X = iris.data[:, :2]  # we only take the first two features.
y = iris.target

x_min, x_max = X[:, 0].min() - .5, X[:, 0].max() + .5
y_min, y_max = X[:, 1].min() - .5, X[:, 1].max() + .5

plt.figure(2, figsize=(8, 6))
plt.clf()

# Plot the training points
plt.scatter(X[:, 0], X[:, 1], c=y, cmap=plt.cm.Set1,
            edgecolor='k')
plt.xlabel('Sepal length')
plt.ylabel('Sepal width')

plt.xlim(x_min, x_max)
plt.ylim(y_min, y_max)
plt.xticks(())
plt.yticks(())

# To getter a better understanding of interaction of the dimensions
# plot the first three PCA dimensions
fig = plt.figure(1, figsize=(8, 6))
ax = Axes3D(fig, elev=-150, azim=110)
X_reduced = PCA(n_components=3).fit_transform(iris.data)
ax.scatter(X_reduced[:, 0], X_reduced[:, 1], X_reduced[:, 2], c=y,
           cmap=plt.cm.Set1, edgecolor='k', s=40)
ax.set_title("First three PCA directions")
ax.set_xlabel("1st eigenvector")
ax.w_xaxis.set_ticklabels([])
ax.set_ylabel("2nd eigenvector")
ax.w_yaxis.set_ticklabels([])
ax.set_zlabel("3rd eigenvector")
ax.w_zaxis.set_ticklabels([])

plt.show()

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions