From cf69955af1445726ea3dab6786d0a69de10cc7d5 Mon Sep 17 00:00:00 2001 From: AkselObdrup Date: Thu, 22 Jul 2021 12:35:26 +0200 Subject: [PATCH 1/2] Changed calculateSpace to fix order of discrete and continuous variables --- utility/converters.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/utility/converters.ts b/utility/converters.ts index bbee5f10..e504877d 100644 --- a/utility/converters.ts +++ b/utility/converters.ts @@ -2,10 +2,12 @@ import { ExperimentData } from "../openapi" import { CategoricalVariableType, DataPointType, ExperimentType, ScoreDataPointType, SpaceType, ValueVariableType } from "../types/common" export const calculateSpace = (experiment: ExperimentType): SpaceType => { - const discrete: SpaceType = experiment.valueVariables.filter(v => v.discrete).map(v => { return {type: "discrete", name: v.name, from: Number(v.minVal), to: Number(v.maxVal)} }) - const continuous: SpaceType = experiment.valueVariables.filter(v => !v.discrete).map(v => { return {type: "continuous", name: v.name, from: Number(v.minVal), to: Number(v.maxVal)} }) - const categorial: SpaceType = experiment.categoricalVariables.map((v) => { return {type: "category", name: v.name, categories: v.options} }) - return discrete.concat(continuous, categorial) + + const numerical: SpaceType = experiment.valueVariables.map(v => { if(v.discrete) { + return {type: "discrete", name: v.name, from: Number(v.minVal), to: Number(v.maxVal)}} + else {return {type: "continuous", name: v.name, from: Number(v.minVal), to: Number(v.maxVal)}} }) + const categorical: SpaceType = experiment.categoricalVariables.map((v) => { return {type: "category", name: v.name, categories: v.options} }) + return numerical.concat(categorical) } const numPat = / [0-9] + / From 1fb0330a4bf8a05466b0e2b4022839913fe483f9 Mon Sep 17 00:00:00 2001 From: AkselObdrup Date: Mon, 26 Jul 2021 08:40:22 +0200 Subject: [PATCH 2/2] Small change to the update of calculateSpace --- utility/converters.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/utility/converters.ts b/utility/converters.ts index e504877d..5e999e5d 100644 --- a/utility/converters.ts +++ b/utility/converters.ts @@ -3,9 +3,8 @@ import { CategoricalVariableType, DataPointType, ExperimentType, ScoreDataPointT export const calculateSpace = (experiment: ExperimentType): SpaceType => { - const numerical: SpaceType = experiment.valueVariables.map(v => { if(v.discrete) { - return {type: "discrete", name: v.name, from: Number(v.minVal), to: Number(v.maxVal)}} - else {return {type: "continuous", name: v.name, from: Number(v.minVal), to: Number(v.maxVal)}} }) + const numerical: SpaceType = experiment.valueVariables.map(v => { const type = v.discrete ? "discrete" : "continuous" + return {type, name: v.name, from: Number(v.minVal), to: Number(v.maxVal)}}) const categorical: SpaceType = experiment.categoricalVariables.map((v) => { return {type: "category", name: v.name, categories: v.options} }) return numerical.concat(categorical) }