Skip to content

Commit 4542238

Browse files
author
Googler
committed
Automated Code Change
PiperOrigin-RevId: 772786015
1 parent f34ab60 commit 4542238

File tree

3 files changed

+29
-12
lines changed

3 files changed

+29
-12
lines changed

lit_nlp/client/modules/annotated_text_module.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@ import {customElement} from 'lit/decorators.js';
1919
import {makeObservable, observable} from 'mobx';
2020

2121
import {LitModule} from '../core/lit_module';
22-
import {type AnnotationGroups, TextSegments} from '../elements/annotated_text_vis';
22+
import {type AnnotationGroups, type AnnotationSpec, type SegmentSpec, TextSegments} from '../elements/annotated_text_vis';
2323
import {MultiSegmentAnnotations, TextSegment} from '../lib/lit_types';
2424
import {styles as sharedStyles} from '../lib/shared_styles.css';
2525
import {type IndexedInput, ModelInfoMap, Spec} from '../lib/types';
2626
import {doesOutputSpecContain, filterToKeys, findSpecKeys} from '../lib/utils';
2727

28+
// This should be removed.
29+
type AnyDuringMigration = any;
30+
2831
/** LIT module for model output. */
2932
@customElement('annotated-text-gold-module')
3033
export class AnnotatedTextGoldModule extends LitModule {
@@ -53,13 +56,15 @@ export class AnnotatedTextGoldModule extends LitModule {
5356
// Text segment fields
5457
const segmentNames = findSpecKeys(dataSpec, TextSegment);
5558
const segments: TextSegments = filterToKeys(input.data, segmentNames);
56-
const segmentSpec = filterToKeys(dataSpec, segmentNames);
59+
const segmentSpec: SegmentSpec =
60+
filterToKeys(dataSpec, segmentNames) as AnyDuringMigration;
5761

5862
// Annotation fields
5963
const annotationNames = findSpecKeys(dataSpec, MultiSegmentAnnotations);
6064
const annotations: AnnotationGroups =
6165
filterToKeys(input.data, annotationNames);
62-
const annotationSpec = filterToKeys(dataSpec, annotationNames);
66+
const annotationSpec: AnnotationSpec =
67+
filterToKeys(dataSpec, annotationNames) as AnyDuringMigration;
6368

6469
// If more than one model is selected, AnnotatedTextModule will be offset
6570
// vertically due to the model name header, while this one won't be.
@@ -149,12 +154,15 @@ export class AnnotatedTextModule extends LitModule {
149154
findSpecKeys(this.appState.currentDatasetSpec, TextSegment);
150155
const segments: TextSegments =
151156
filterToKeys(this.currentData.data, segmentNames);
152-
const segmentSpec =
153-
filterToKeys(this.appState.currentDatasetSpec, segmentNames);
157+
const segmentSpec: SegmentSpec =
158+
filterToKeys(this.appState.currentDatasetSpec, segmentNames) as
159+
AnyDuringMigration;
154160

155161
const outputSpec = this.appState.getModelSpec(this.model).output;
156-
const annotationSpec = filterToKeys(
157-
outputSpec, findSpecKeys(outputSpec, MultiSegmentAnnotations));
162+
const annotationSpec: AnnotationSpec =
163+
filterToKeys(
164+
outputSpec, findSpecKeys(outputSpec, MultiSegmentAnnotations)) as
165+
AnyDuringMigration;
158166
// clang-format off
159167
return html`
160168
<annotated-text-vis .segments=${segments}

lit_nlp/client/modules/feature_attribution_module.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ import {LegendType} from '../elements/color_legend';
3030
import {InterpreterClick, InterpreterSettings} from '../elements/interpreter_controls';
3131
import {SortableTemplateResult, TableData} from '../elements/table';
3232
import {FeatureSalience as FeatureSalienceLitType, LitTypeWithVocab, SingleFieldMatcher} from '../lib/lit_types';
33-
import {IndexedInput, ModelInfoMap} from '../lib/types';
33+
import {styles as sharedStyles} from '../lib/shared_styles.css';
34+
import {type D3Scale, IndexedInput, ModelInfoMap} from '../lib/types';
3435
import * as utils from '../lib/utils';
3536
import {findSpecKeys} from '../lib/utils';
3637
import {SignedSalienceCmap} from '../services/color_service';
3738
import {type NumericFeatureBins} from '../services/group_service';
3839
import {AppState, GroupService} from '../services/services';
3940

40-
import {styles as sharedStyles} from '../lib/shared_styles.css';
4141
import {styles} from './feature_attribution_module.css';
4242

4343
const ALL_DATA = 'Entire Dataset';
@@ -75,6 +75,9 @@ interface VisToggles {
7575
[name: string]: boolean;
7676
}
7777

78+
// This should be removed.
79+
type AnyDuringMigration = any;
80+
7881
/** Aggregate feature attribution for tabular ML models. */
7982
@customElement('feature-attribution-module')
8083
export class FeatureAttributionModule extends LitModule {
@@ -440,7 +443,8 @@ export class FeatureAttributionModule extends LitModule {
440443
}
441444

442445
override renderImpl() {
443-
const scale = (val: number) => this.colorMap.bgCmap(val);
446+
const scale: D3Scale =
447+
((val: number) => this.colorMap.bgCmap(val)) as AnyDuringMigration;
444448
scale.domain = () => this.colorMap.colorScale.domain();
445449

446450
// clang-format off

lit_nlp/client/modules/pdp_module.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ interface AllPdpInfo {
4444
// Data for bar or line charts.
4545
type ChartInfo = Map<string|number, number>;
4646

47+
// This should be removed.
48+
type AnyDuringMigration = any;
49+
4750
/**
4851
* A LIT module that renders regression results.
4952
*/
@@ -172,14 +175,16 @@ export class PdpModule extends LitModule {
172175
const yRange = isClassification ? [0, 1] : [];
173176
const renderChart = (chartData: ChartInfo) => {
174177
if (isNumeric) {
178+
const chartMap: Map<number, number> = chartData as AnyDuringMigration;
175179
return html`
176180
<line-chart height=150 width=300
177-
.scores=${chartData} .yScale=${yRange}>
181+
.scores=${chartMap} .yScale=${yRange}>
178182
</line-chart>`;
179183
} else {
184+
const chartMap: Map<string, number> = chartData as AnyDuringMigration;
180185
return html`
181186
<bar-chart height=150 width=300
182-
.scores=${chartData} .yScale=${yRange}>
187+
.scores=${chartMap} .yScale=${yRange}>
183188
</bar-chart>`;
184189
}
185190

0 commit comments

Comments
 (0)