diff --git a/news/1 Enhancements/5368.md b/news/1 Enhancements/5368.md new file mode 100644 index 000000000000..a92213fde27c --- /dev/null +++ b/news/1 Enhancements/5368.md @@ -0,0 +1 @@ +Swap getsizeof size value for something more sensible in the variable explorer \ No newline at end of file diff --git a/package.nls.json b/package.nls.json index 6592103d2c73..09c57644bda7 100644 --- a/package.nls.json +++ b/package.nls.json @@ -239,7 +239,7 @@ "LanguageService.reloadVSCodeIfSeachPathHasChanged": "Search paths have changed for this Python interpreter. Please reload the extension to ensure that the IntelliSense works correctly", "DataScience.variableExplorerNameColumn": "Name", "DataScience.variableExplorerTypeColumn": "Type", - "DataScience.variableExplorerSizeColumn": "Size", + "DataScience.variableExplorerSizeColumn": "Count", "DataScience.variableExplorerValueColumn": "Value", "DataScience.showDataExplorerTooltip": "Show variable in data explorer.", "DataScience.dataExplorerInvalidVariableFormat": "'{0}' is not an active variable.", diff --git a/pythonFiles/datascience/getJupyterVariableValue.py b/pythonFiles/datascience/getJupyterVariableValue.py index efd098e9ba65..38ef30c89c70 100644 --- a/pythonFiles/datascience/getJupyterVariableValue.py +++ b/pythonFiles/datascience/getJupyterVariableValue.py @@ -8,10 +8,10 @@ _VSCODE_evalResult = eval(_VSCODE_targetVariable['name']) # Find shape and count if available -if _VSCODE_targetVariable['type'] in ['ndarray','DataFrame','Series']: +if (hasattr(_VSCODE_evalResult, 'shape')): _VSCODE_targetVariable['shape'] = str(_VSCODE_evalResult.shape) -if _VSCODE_targetVariable['type'] in ['tuple', 'str', 'dict', 'list', 'set', 'ndarray','DataFrame','Series']: +if (hasattr(_VSCODE_evalResult, '__len__')): _VSCODE_targetVariable['count'] = len(_VSCODE_evalResult) # Get the string of the eval result, truncate it as it could be far too long diff --git a/src/datascience-ui/history-react/variableExplorer.tsx b/src/datascience-ui/history-react/variableExplorer.tsx index 2b82bf03e3ff..ebbfb7ffbd79 100644 --- a/src/datascience-ui/history-react/variableExplorer.tsx +++ b/src/datascience-ui/history-react/variableExplorer.tsx @@ -53,7 +53,7 @@ export class VariableExplorer extends React.Component}, {key: 'type', name: getLocString('DataScience.variableExplorerTypeColumn', 'Type'), type: 'string', width: 120}, - {key: 'size', name: getLocString('DataScience.variableExplorerSizeColumn', 'Size'), type: 'number', width: 120, formatter: }, + {key: 'size', name: getLocString('DataScience.variableExplorerSizeColumn', 'Count'), type: 'string', width: 120, formatter: }, {key: 'value', name: getLocString('DataScience.variableExplorerValueColumn', 'Value'), type: 'string', width: 300}, {key: 'buttons', name: '', type: 'boolean', width: 34, formatter: } ]; @@ -125,7 +125,7 @@ export class VariableExplorer extends React.Component { - return { buttons: {name: newVar.name, supportsDataExplorer: newVar.supportsDataExplorer}, name: newVar.name, type: newVar.type, size: newVar.size, value: getLocString('DataScience.variableLoadingValue', 'Loading...')}; + return { buttons: {name: newVar.name, supportsDataExplorer: newVar.supportsDataExplorer}, name: newVar.name, type: newVar.type, size: '', value: getLocString('DataScience.variableLoadingValue', 'Loading...')}; }); this.setState({ gridRows: newGridRows}); @@ -136,7 +136,19 @@ export class VariableExplorer extends React.Component, React.Component>, verifyCell(rowCells.at(0), targetVariable.name, targetVariable.name); verifyCell(rowCells.at(1), targetVariable.type, targetVariable.name); + + if (targetVariable.shape && targetVariable.shape !== '') { + verifyCell(rowCells.at(2), targetVariable.shape, targetVariable.name); + } else if (targetVariable.count) { + verifyCell(rowCells.at(2), targetVariable.count.toString(), targetVariable.name); + } + verifyCell(rowCells.at(3), targetVariable.value ? targetVariable.value : '', targetVariable.name); }