Skip to content

Commit

Permalink
Embedding Projector: fix bookmark projection state
Browse files Browse the repository at this point in the history
  • Loading branch information
alicialics committed Apr 15, 2023
1 parent 963afb7 commit 6436b3b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions tensorboard/plugins/projector/vz_projector/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,8 @@ export class State {
filteredPoints: number[];
/** The indices of selected points. */
selectedPoints: number[] = [];
/** The shuffled indices of points. */
shuffledDataIndices: number[] = [];
/** Camera state (2d/3d, position, target, zoom, etc). */
cameraDef: CameraDef;
/** Color by option. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class BookmarkPanel extends LegacyElementMixin(PolymerElement) {
this.notifyPath(path, selected);
}
/**
* Return an event's to their bookmark index.
* Returns the bookmark index of the event.
*/
private getBookmarkIndex(evt: any) {
return evt.model.__data.index;
Expand Down
5 changes: 5 additions & 0 deletions tensorboard/plugins/projector/vz_projector/vz-projector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,7 @@ class Projector
state.tSNEIteration = this.dataSet.tSNEIteration;
state.selectedPoints = this.selectedPointIndices;
state.filteredPoints = this.dataSetFilterIndices!;
state.shuffledDataIndices = this.dataSet.shuffledDataIndices;
this.projectorScatterPlotAdapter.populateBookmarkFromUI(state);
state.selectedColorOptionName = this.dataPanel.selectedColorOptionName;
state.forceCategoricalColoring = this.dataPanel.forceCategoricalColoring;
Expand All @@ -674,10 +675,14 @@ class Projector
const point = this.dataSet.points[i];
const projection = state.projections[i];
const keys = Object.keys(projection);
point.projections = {};
for (let j = 0; j < keys.length; ++j) {
point.projections[keys[j]] = projection[keys[j]];
}
}
if (state.shuffledDataIndices) {
this.dataSet.shuffledDataIndices = state.shuffledDataIndices;
}
this.dataSet.hasTSNERun = state.selectedProjection === 'tsne';
this.dataSet.tSNEIteration = state.tSNEIteration;
this.projectionsPanel.restoreUIFromBookmark(state);
Expand Down

0 comments on commit 6436b3b

Please sign in to comment.