GeezerVison is showing github.com — swap getsizeof for more relevant values (#5371) · dogyingying/pythonVSCode@fb914e2
File treeExpand file treeCollapse file tree Open diff view settings datascience-ui/history-react
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboard +1Lines changed: 1 addition & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +Swap getsizeof size value for something more sensible in the variable explorer |
Collapse file Copy file name to clipboardExpand all lines: package.nls.json +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 220 | 220 | "LanguageService.reloadVSCodeIfSeachPathHasChanged": "Search paths have changed for this Python interpreter. Please reload the extension to ensure that the IntelliSense works correctly", | 221 | 221 | "DataScience.variableExplorerNameColumn": "Name", | 222 | 222 | "DataScience.variableExplorerTypeColumn": "Type", | 223 | | - "DataScience.variableExplorerSizeColumn": "Size", | | 223 | + "DataScience.variableExplorerSizeColumn": "Count", | 224 | 224 | "DataScience.variableExplorerValueColumn": "Value", | 225 | 225 | "DataScience.showDataExplorerTooltip": "Show variable in data explorer.", | 226 | 226 | "DataScience.dataExplorerInvalidVariableFormat": "'{0}' is not an active variable.", | |
Collapse file Copy file name to clipboardExpand all lines: pythonFiles/datascience/getJupyterVariableValue.py +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 8 | 8 | _VSCODE_evalResult = eval(_VSCODE_targetVariable['name']) | 9 | 9 |
| 10 | 10 | # Find shape and count if available | 11 | | -if _VSCODE_targetVariable['type'] in ['ndarray','DataFrame','Series']: | | 11 | +if (hasattr(_VSCODE_evalResult, 'shape')): | 12 | 12 | _VSCODE_targetVariable['shape'] = str(_VSCODE_evalResult.shape) | 13 | 13 |
| 14 | | -if _VSCODE_targetVariable['type'] in ['tuple', 'str', 'dict', 'list', 'set', 'ndarray','DataFrame','Series']: | | 14 | +if (hasattr(_VSCODE_evalResult, '__len__')): | 15 | 15 | _VSCODE_targetVariable['count'] = len(_VSCODE_evalResult) | 16 | 16 |
| 17 | 17 | # Get the string of the eval result, truncate it as it could be far too long | |
Collapse file Copy file name to clipboardExpand all lines: src/datascience-ui/history-react/variableExplorer.tsx +15-3Lines changed: 15 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -53,7 +53,7 @@ export class VariableExplorer extends React.Component<IVariableExplorerProps, IV | 53 | 53 | const columns = [ | 54 | 54 | {key: 'name', name: getLocString('DataScience.variableExplorerNameColumn', 'Name'), type: 'string', width: 120, formatter: <VariableExplorerCellFormatter cellStyle={CellStyle.variable} />}, | 55 | 55 | {key: 'type', name: getLocString('DataScience.variableExplorerTypeColumn', 'Type'), type: 'string', width: 120}, | 56 | | - {key: 'size', name: getLocString('DataScience.variableExplorerSizeColumn', 'Size'), type: 'number', width: 120, formatter: <VariableExplorerCellFormatter cellStyle={CellStyle.numeric} />}, | | 56 | + {key: 'size', name: getLocString('DataScience.variableExplorerSizeColumn', 'Count'), type: 'string', width: 120, formatter: <VariableExplorerCellFormatter cellStyle={CellStyle.numeric} />}, | 57 | 57 | {key: 'value', name: getLocString('DataScience.variableExplorerValueColumn', 'Value'), type: 'string', width: 300}, | 58 | 58 | {key: 'buttons', name: '', type: 'boolean', width: 34, formatter: <VariableExplorerButtonCellFormatter showDataExplorer={this.props.showDataExplorer} baseTheme={this.props.baseTheme} /> } | 59 | 59 | ]; | @@ -125,7 +125,7 @@ export class VariableExplorer extends React.Component<IVariableExplorerProps, IV | 125 | 125 | // Help to keep us independent of main history window state if we choose to break out the variable explorer | 126 | 126 | public newVariablesData(newVariables: IJupyterVariable[]) { | 127 | 127 | const newGridRows = newVariables.map(newVar => { | 128 | | - return { buttons: {name: newVar.name, supportsDataExplorer: newVar.supportsDataExplorer}, name: newVar.name, type: newVar.type, size: newVar.size, value: getLocString('DataScience.variableLoadingValue', 'Loading...')}; | | 128 | + return { buttons: {name: newVar.name, supportsDataExplorer: newVar.supportsDataExplorer}, name: newVar.name, type: newVar.type, size: '', value: getLocString('DataScience.variableLoadingValue', 'Loading...')}; | 129 | 129 | }); | 130 | 130 |
| 131 | 131 | this.setState({ gridRows: newGridRows}); | @@ -136,7 +136,19 @@ export class VariableExplorer extends React.Component<IVariableExplorerProps, IV | 136 | 136 | const newGridRows = this.state.gridRows.slice(); | 137 | 137 | for (let i = 0; i < newGridRows.length; i = i + 1) { | 138 | 138 | if (newGridRows[i].name === newVariable.name) { | 139 | | - const newGridRow = {...newGridRows[i], value: newVariable.value}; | | 139 | + | | 140 | + // For object with shape, use that for size | | 141 | + // for object with length use that for size | | 142 | + // If it doesn't have either, then just leave it out | | 143 | + let newSize = ''; | | 144 | + if (newVariable.shape && newVariable.shape !== '') { | | 145 | + newSize = newVariable.shape; | | 146 | + } else if (newVariable.count) { | | 147 | + newSize = newVariable.count.toString(); | | 148 | + } | | 149 | + | | 150 | + const newGridRow = {...newGridRows[i], value: newVariable.value, size: newSize}; | | 151 | + | 140 | 152 | newGridRows[i] = newGridRow; | 141 | 153 | } | 142 | 154 | } | |
Collapse file Copy file name to clipboardExpand all lines: src/test/datascience/variableexplorer.functional.test.tsx +7Lines changed: 7 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -268,6 +268,13 @@ function verifyRow(rowWrapper: ReactWrapper<any, Readonly<{}>, React.Component>, | 268 | 268 |
| 269 | 269 | verifyCell(rowCells.at(0), targetVariable.name, targetVariable.name); | 270 | 270 | verifyCell(rowCells.at(1), targetVariable.type, targetVariable.name); | | 271 | + | | 272 | + if (targetVariable.shape && targetVariable.shape !== '') { | | 273 | + verifyCell(rowCells.at(2), targetVariable.shape, targetVariable.name); | | 274 | + } else if (targetVariable.count) { | | 275 | + verifyCell(rowCells.at(2), targetVariable.count.toString(), targetVariable.name); | | 276 | + } | | 277 | + | 271 | 278 | verifyCell(rowCells.at(3), targetVariable.value ? targetVariable.value : '', targetVariable.name); | 272 | 279 | } | 273 | 280 |
| |
|