Skip to content

Commit

Permalink
324 random bootstrap seed (#1)
Browse files Browse the repository at this point in the history
* set seed on dataset select & add options

* attempt to run tests in cicd

* add PAT

* update coverage reporting

* add coverage report to gitignore

* refactor - only set bootstrap_seed for nested dichotomous

---------

Co-authored-by: Andy Shapiro <[email protected]>
  • Loading branch information
hausman-gdit and shapiromatron committed Feb 12, 2024
1 parent ee3a6e3 commit 31bac6a
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions frontend/src/stores/OptionsStore.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,37 @@
import _ from "lodash";
import {action, computed, observable} from "mobx";

import {MODEL_CONTINUOUS} from "@/constants/mainConstants";
import {MODEL_CONTINUOUS, MODEL_NESTED_DICHOTOMOUS} from "@/constants/mainConstants";
import * as constant from "@/constants/optionsConstants";

const createOption = modelType => {
const option = _.cloneDeep(constant.options[modelType]);
if (modelType == MODEL_NESTED_DICHOTOMOUS) {
// set seed to random number
option.bootstrap_seed = Math.ceil(Math.random() * 1000);
}
return option;
};

class OptionsStore {
constructor(rootStore) {
this.rootStore = rootStore;
}

@observable optionsList = [];

@computed get canEdit() {
return this.rootStore.mainStore.canEdit;
}

@action.bound setDefaultsByDatasetType(force) {
if (this.optionsList.length === 0 || force) {
const option = _.cloneDeep(constant.options[this.getModelType]);
this.optionsList = [option];
this.optionsList = [createOption(this.getModelType)];
}
}

@action.bound addOptions() {
const option = _.cloneDeep(constant.options[this.getModelType]);
this.optionsList.push(option);
this.optionsList.push(createOption(this.getModelType));
this.rootStore.mainStore.setInputsChangedFlag();
}

Expand All @@ -40,6 +48,7 @@ class OptionsStore {
this.optionsList.splice(val, 1);
this.rootStore.mainStore.setInputsChangedFlag();
}

@action.bound setOptions(options) {
this.optionsList = options;
this.setDefaultsByDatasetType();
Expand All @@ -48,13 +57,15 @@ class OptionsStore {
@computed get getModelType() {
return this.rootStore.mainStore.model_type;
}

@computed get maxItems() {
return this.rootStore.mainStore.isDesktop
? 1000
: this.rootStore.mainStore.isMultiTumor
? 3
: 6;
}

@computed get canAddNewOption() {
return this.optionsList.length < this.maxItems;
}
Expand Down

0 comments on commit 31bac6a

Please sign in to comment.