Skip to content

Commit a1a3b14

Browse files
authored
Embedding Projector: fix bookmark projection state (#6328)
## Motivation for features / changes When a bookmark state of loaded, it will contain data on a certain set of projections for some of points (B). The app also has a different (current) state (A) in terms of which points are projected. We should completely replace the App state (A) with the bookmark state B. ## Technical description of changes store/replace shuffledDataIndices for bookmarks wipe out existing projections in app state ## Screenshots of UI changes N/A ## Detailed steps to verify changes work correctly (as executed by you) 1. Export a bookmark that has a UMAP state 2. Refresh app, open UMAP panel and load in the previous state. 3. Verify only one set of 5k points are shown (as opposed to 10k points) 4. Refresh app, load previous UMAP state and adjust parameters to a new UMAP calc is performed 5. Verify only one set of 5k points are shown (as opposed to 10k points) ## Alternate designs / implementations considered
1 parent 0a8eb15 commit a1a3b14

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

tensorboard/plugins/projector/vz_projector/data.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,8 @@ export class State {
680680
filteredPoints: number[];
681681
/** The indices of selected points. */
682682
selectedPoints: number[] = [];
683+
/** The shuffled indices of points. */
684+
shuffledDataIndices: number[] = [];
683685
/** Camera state (2d/3d, position, target, zoom, etc). */
684686
cameraDef: CameraDef;
685687
/** Color by option. */

tensorboard/plugins/projector/vz_projector/vz-projector-bookmark-panel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ class BookmarkPanel extends LegacyElementMixin(PolymerElement) {
190190
this.notifyPath(path, selected);
191191
}
192192
/**
193-
* Return an event's to their bookmark index.
193+
* Returns the bookmark index of the event.
194194
*/
195195
private getBookmarkIndex(evt: any) {
196196
return evt.model.__data.index;

tensorboard/plugins/projector/vz_projector/vz-projector.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,7 @@ class Projector
650650
state.tSNEIteration = this.dataSet.tSNEIteration;
651651
state.selectedPoints = this.selectedPointIndices;
652652
state.filteredPoints = this.dataSetFilterIndices!;
653+
state.shuffledDataIndices = this.dataSet.shuffledDataIndices;
653654
this.projectorScatterPlotAdapter.populateBookmarkFromUI(state);
654655
state.selectedColorOptionName = this.dataPanel.selectedColorOptionName;
655656
state.forceCategoricalColoring = this.dataPanel.forceCategoricalColoring;
@@ -674,10 +675,14 @@ class Projector
674675
const point = this.dataSet.points[i];
675676
const projection = state.projections[i];
676677
const keys = Object.keys(projection);
678+
point.projections = {};
677679
for (let j = 0; j < keys.length; ++j) {
678680
point.projections[keys[j]] = projection[keys[j]];
679681
}
680682
}
683+
if (state.shuffledDataIndices) {
684+
this.dataSet.shuffledDataIndices = state.shuffledDataIndices;
685+
}
681686
this.dataSet.hasTSNERun = state.selectedProjection === 'tsne';
682687
this.dataSet.tSNEIteration = state.tSNEIteration;
683688
this.projectionsPanel.restoreUIFromBookmark(state);

0 commit comments

Comments
 (0)