Skip to content

Commit

Permalink
unnamed functions and exported method return types
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmaLRussell committed Sep 13, 2023
1 parent 1719fb1 commit 7022d03
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 15 deletions.
2 changes: 1 addition & 1 deletion app/static/src/app/store/sensitivity/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const runSensitivity = (
endTime: number,
context: ActionContext<BaseSensitivityState, AppState>,
multiSensitivity = false
) => {
): void => {
const {
rootState, commit, dispatch, getters, rootGetters
} = context;
Expand Down
7 changes: 4 additions & 3 deletions app/static/src/app/store/sensitivity/sensitivity.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import {
SensitivityParameterSettings,
SensitivityPlotExtreme,
SensitivityPlotType,
SensitivityScaleType,
SensitivityState,
SensitivityState, SensitivityUpdateRequiredReasons,
SensitivityVariationType
} from "./state";
import { mutations } from "./mutations";
import { actions } from "./actions";
import { getters } from "./getters";

export const defaultSensitivityParamSettings = () => ({
export const defaultSensitivityParamSettings = (): SensitivityParameterSettings => ({
parameterToVary: null,
scaleType: SensitivityScaleType.Arithmetic,
variationType: SensitivityVariationType.Percentage,
Expand All @@ -20,7 +21,7 @@ export const defaultSensitivityParamSettings = () => ({
customValues: []
});

export const noSensitivityUpdateRequired = () => ({
export const noSensitivityUpdateRequired = (): SensitivityUpdateRequiredReasons => ({
modelChanged: false,
parameterValueChanged: false,
endTimeChanged: false,
Expand Down
13 changes: 7 additions & 6 deletions app/static/src/app/userMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,28 +79,29 @@ export default {
}
},
multiSensitivity: {
runSummary: (solutionCount: number) => `${sensType(true)} run produced ${solutionCount} solutions.`,
runSummary: (solutionCount: number): string => `${sensType(true)} run produced ${solutionCount} solutions.`,
updateReasons: {
prefix: "Status is out of date:"
}
},
sensitivity: {
compileRequiredForOptions: (multiSens: boolean) => "Please compile a valid model in order to set "
compileRequiredForOptions: (multiSens: boolean): string => "Please compile a valid model in order to set "
+ `${sensType(multiSens)} options.`,
compileRequiredForUpdate: (multiSens: boolean) => "Model code has been updated. "
compileRequiredForUpdate: (multiSens: boolean): string => "Model code has been updated. "
+ `Compile code and Run ${sensType(multiSens)} to update.`,
invalidSettings: "Invalid settings",
notRunYet: (multiSens: boolean) => `${sensType(multiSens)} has not been run.`,
notRunYet: (multiSens: boolean): string => `${sensType(multiSens)} has not been run.`,
updateReasons: {
prefix: "Plot is out of date:",
modelChanged: "model code has been recompiled",
parameterValueChanged: "parameters have been changed",
sensitivityOptionsChanged: (multiSens: boolean) => `${sensType(multiSens)} options have been changed`,
sensitivityOptionsChanged:
(multiSens: boolean): string => `${sensType(multiSens)} options have been changed`,
endTimeChanged: "end time has changed",
numberOfReplicatesChanged: "number of replicates has changed",
advancedSettingsChanged: "advanced settings have been changed",
unknown: "unknown reasons, contact the administrator, as this is unexpected",
suffix: (multiSens: boolean) => `Run ${sensType(multiSens)} to update`
suffix: (multiSens: boolean): string => `Run ${sensType(multiSens)} to update`
}
},
sessions: {
Expand Down
9 changes: 4 additions & 5 deletions app/static/src/app/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ export const anyTrue = (x: Dict<boolean>): boolean => {
return Object.values(x).some((el: boolean) => el);
};

export const runPlaceholderMessage = (selectedVariables: string[], sensitivity: boolean) => {
export const runPlaceholderMessage = (selectedVariables: string[], sensitivity: boolean): string => {
const notRunYet = sensitivity ? userMessages.sensitivity.notRunYet(false) : userMessages.run.notRunYet;
return selectedVariables.length ? notRunYet : userMessages.model.noVariablesSelected;
};
Expand All @@ -243,7 +243,8 @@ const extractValuesFromTags = (values: Tag[], paramValues: OdinUserType | null)
return extracted.filter((x) => x !== undefined) as number[];
};

export const convertAdvancedSettingsToOdin = (advancedSettings: AdvancedSettings, paramValues: OdinUserType | null) => {
export const convertAdvancedSettingsToOdin = (advancedSettings: AdvancedSettings,
paramValues: OdinUserType | null): AdvancedSettingsOdin => {
const flattenedObject = Object.fromEntries(Object.entries(advancedSettings)
.map(([key, value]) => {
let cleanVal: number | number[] | null | undefined;
Expand All @@ -259,14 +260,12 @@ export const convertAdvancedSettingsToOdin = (advancedSettings: AdvancedSettings
return [key, cleanVal];
})) as Record<AdvancedOptions, number>;

const advancedSettingsOdin: AdvancedSettingsOdin = {
return {
atol: flattenedObject[AdvancedOptions.tol],
rtol: flattenedObject[AdvancedOptions.tol],
maxSteps: flattenedObject[AdvancedOptions.maxSteps],
stepSizeMax: flattenedObject[AdvancedOptions.stepSizeMax],
stepSizeMin: flattenedObject[AdvancedOptions.stepSizeMin],
tcrit: flattenedObject[AdvancedOptions.tcrit]
};

return advancedSettingsOdin;
};
1 change: 1 addition & 0 deletions app/static/tests/unit/components/basic/basicApp.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Mock the import of third party packages to prevent errors
jest.mock("plotly.js-basic-dist-min", () => ({}));
jest.mock("../../../../src/app/components/help/MarkdownItImport.ts", () => {
// eslint-disable-next-line func-names
return function () {
return {
use: jest.fn().mockReturnValue({
Expand Down
1 change: 1 addition & 0 deletions app/static/tests/unit/components/fit/fitApp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
jest.mock("plotly.js-basic-dist-min", () => ({}));
jest.mock("plotly.js-basic-dist-min", () => ({}));
jest.mock("../../../../src/app/components/help/MarkdownItImport.ts", () => {
// eslint-disable-next-line func-names
return function () {
return {
use: jest.fn().mockReturnValue({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jest.mock("markdown-it-mathjax", () => ({ __esModule: true, default: () => mockM
jest.mock("../../../../src/app/components/help/MarkdownItImport.ts", () => {
// mock constructor - this cannot be an arrow function, see
// https://stackoverflow.com/questions/47402005
// eslint-disable-next-line func-names
return function () {
return {
use: mockMarkdownItUse
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Mock the import of third party packages to prevent errors
jest.mock("../../../../src/app/components/help/MarkdownItImport.ts", () => {
// eslint-disable-next-line func-names
return function () {
return {
use: jest.fn().mockReturnValue({
Expand Down

0 comments on commit 7022d03

Please sign in to comment.