Skip to content

Commit 0b962c1

Browse files
committed
Embedding Projector: fix switching projections
rename params
1 parent 4f0cd50 commit 0b962c1

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

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

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -402,9 +402,8 @@ class ProjectionsPanel extends LegacyElementMixin(PolymerElement) {
402402
this.customSelectedSearchByMetadataOption =
403403
this.searchByMetadataOptions[Math.max(0, searchByMetadataIndex)];
404404
}
405-
public showTab(id: ProjectionType) {
406-
this.currentProjection = id;
407-
const tab = this.$$('.ink-tab[data-tab="' + id + '"]') as HTMLElement;
405+
public showTab(projection: ProjectionType) {
406+
const tab = this.$$('.ink-tab[data-tab="' + projection + '"]') as HTMLElement;
408407
const allTabs = this.root?.querySelectorAll('.ink-tab');
409408
if (allTabs) {
410409
for (let i = 0; i < allTabs.length; i++) {
@@ -419,7 +418,7 @@ class ProjectionsPanel extends LegacyElementMixin(PolymerElement) {
419418
}
420419
}
421420
util.classed(
422-
this.$$('.ink-panel-content[data-panel="' + id + '"]') as HTMLElement,
421+
this.$$('.ink-panel-content[data-panel="' + projection + '"]') as HTMLElement,
423422
'active',
424423
true
425424
);
@@ -432,25 +431,29 @@ class ProjectionsPanel extends LegacyElementMixin(PolymerElement) {
432431
this.style.height = main.clientHeight + 'px';
433432
});
434433
}
435-
this.beginProjection(id);
434+
this.beginProjection(projection);
436435
}
437436
private beginProjection(projection: ProjectionType) {
438437
if (this.polymerChangesTriggerReprojection === false) {
439438
return;
440439
}
441-
if (projection === 'pca') {
440+
if (this.currentProjection !== projection) {
441+
this.currentProjection = projection;
442442
if (this.dataSet != null) {
443-
this.dataSet.stopTSNE();
443+
if (projection === 'tsne') {
444+
this.dataSet.tSNEShouldPause = false;
445+
} else {
446+
this.dataSet.tSNEShouldPause = true;
447+
}
444448
}
449+
}
450+
if (projection === 'pca') {
445451
this.showPCA();
446452
} else if (projection === 'tsne') {
447453
this.showTSNE();
448454
} else if (projection === 'umap') {
449455
this.showUmap();
450456
} else if (projection === 'custom') {
451-
if (this.dataSet != null) {
452-
this.dataSet.stopTSNE();
453-
}
454457
this.computeAllCentroids();
455458
this.reprojectCustom();
456459
}
@@ -493,6 +496,7 @@ class ProjectionsPanel extends LegacyElementMixin(PolymerElement) {
493496
(iteration: number) => {
494497
if (iteration != null) {
495498
this.runTsneButton.disabled = false;
499+
this.pauseTsneButton.innerText = 'Pause';
496500
this.pauseTsneButton.disabled = false;
497501
this.iterationLabelTsne.innerText = '' + iteration;
498502
this.projector.notifyProjectionPositionsUpdated();

0 commit comments

Comments
 (0)