Skip to content

Commit

Permalink
Display Scalars module if a Model outputs or the Dataset contains a s…
Browse files Browse the repository at this point in the history
…upported type.

PiperOrigin-RevId: 538833425
  • Loading branch information
RyanMullins authored and LIT team committed Jun 8, 2023
1 parent 3f48b10 commit 5f4f7ee
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lit_nlp/client/modules/scalar_module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {ThresholdChange} from '../elements/threshold_slider';
import {colorToRGB, getBrandColor} from '../lib/colors';
import {MulticlassPreds, RegressionScore, Scalar} from '../lib/lit_types';
import {styles as sharedStyles} from '../lib/shared_styles.css';
import {formatForDisplay, IndexedInput, ModelInfoMap} from '../lib/types';
import {formatForDisplay, IndexedInput, ModelInfoMap, Spec} from '../lib/types';
import {doesOutputSpecContain, findSpecKeys, getThresholdFromMargin} from '../lib/utils';
import {CalculatedColumnType, REGRESSION_SOURCE_PREFIX} from '../services/data_service';
import {ClassificationService, ColorService, DataService, FocusService, SelectionService} from '../services/services';
Expand Down Expand Up @@ -104,8 +104,12 @@ export class ScalarModule extends LitModule {
return [sharedStyles, styles];
}

static override shouldDisplayModule(modelSpecs: ModelInfoMap) {
return doesOutputSpecContain(modelSpecs, [Scalar, MulticlassPreds]);
static override shouldDisplayModule(
modelSpecs: ModelInfoMap, datasetSpec: Spec): boolean {
const scalarTypes = [Scalar, MulticlassPreds];
const datasetHasScalars = findSpecKeys(datasetSpec, scalarTypes).length > 0;
const modelsHaveScalars = doesOutputSpecContain(modelSpecs, scalarTypes);
return datasetHasScalars || modelsHaveScalars;
}

private readonly colorService = app.getService(ColorService);
Expand Down

0 comments on commit 5f4f7ee

Please sign in to comment.