Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix ndarray types to be viewable again (#10093)
* Eliminate variable value when computing data frame info

* Fix ndarrays to work again
Add test to make sure we don't regress this again
  • Loading branch information
rchiodo committed Feb 15, 2020
commit ff3f3a47eff2847f5d0450d4743da686a2ed5ec2
1 change: 1 addition & 0 deletions news/2 Fixes/10074.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixes problem with showing ndarrays in the data viewer.
2 changes: 1 addition & 1 deletion src/client/datascience/jupyter/jupyterVariables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const DocStringRegex = /.*?\[.*?;31mDocstring:.*?\[0m\s+(.*)/;
const CountRegex = /.*?\[.*?;31mLength:.*?\[0m\s+(.*)/;
const ShapeRegex = /^\s+\[(\d+) rows x (\d+) columns\]/m;

const DataViewableTypes: Set<string> = new Set<string>(['DataFrame', 'list', 'dict', 'np.array', 'Series']);
const DataViewableTypes: Set<string> = new Set<string>(['DataFrame', 'list', 'dict', 'ndarray', 'Series']);

interface INotebookState {
currentExecutionCount: number;
Expand Down
31 changes: 21 additions & 10 deletions src/test/datascience/variableexplorer.functional.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -356,18 +356,29 @@ function verifyRow(rowWrapper: ReactWrapper<any, Readonly<{}>, React.Component>,
if (targetVariable.value) {
verifyCell(rowCells.at(3), targetVariable.value, targetVariable.name);
}

verifyCell(rowCells.at(4), targetVariable.supportsDataExplorer, targetVariable.name);
}

// Verify a single cell value against a specific target value
function verifyCell(cellWrapper: ReactWrapper<any, Readonly<{}>, React.Component>, value: string, targetName: string) {
function verifyCell(cellWrapper: ReactWrapper<any, Readonly<{}>, React.Component>, value: string | boolean, targetName: string) {
const cellHTML = parse(cellWrapper.html()) as any;
// tslint:disable-next-line:no-string-literal
const match = /value="([\s\S]+?)"\s+/.exec(cellHTML.innerHTML);
expect(match).to.not.be.equal(null, `${targetName} does not have a value attribute`);

// Eliminate whitespace differences
const actualValueNormalized = match![1].replace(/^\s*|\s(?=\s)|\s*$/g, '').replace(/\r\n/g, '\n');
const expectedValueNormalized = value.replace(/^\s*|\s(?=\s)|\s*$/g, '').replace(/\r\n/g, '\n');

expect(actualValueNormalized).to.be.equal(expectedValueNormalized, `${targetName} has an unexpected value ${cellHTML.innerHTML} in variable explorer cell`);
const innerHTML = cellHTML.innerHTML;
if (typeof value === 'string') {
// tslint:disable-next-line:no-string-literal
const match = /value="([\s\S]+?)"\s+/.exec(innerHTML);
expect(match).to.not.be.equal(null, `${targetName} does not have a value attribute`);

// Eliminate whitespace differences
const actualValueNormalized = match![1].replace(/^\s*|\s(?=\s)|\s*$/g, '').replace(/\r\n/g, '\n');
const expectedValueNormalized = value.replace(/^\s*|\s(?=\s)|\s*$/g, '').replace(/\r\n/g, '\n');

expect(actualValueNormalized).to.be.equal(expectedValueNormalized, `${targetName} has an unexpected value ${innerHTML} in variable explorer cell`);
} else {
if (value) {
expect(innerHTML).to.include('image-button-image', `Image class not found in ${targetName}`);
} else {
expect(innerHTML).to.not.include('image-button-image', `Image class was found ${targetName}`);
}
}
}