Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
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 @@ -37,7 +37,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
41 changes: 28 additions & 13 deletions src/test/datascience/variableexplorer.functional.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -539,21 +539,36 @@ 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}`);
}
}
}