From 21a839c706ac86e166d1133fc148268c88c24168 Mon Sep 17 00:00:00 2001 From: Eleni Date: Fri, 16 Oct 2020 15:29:16 +0300 Subject: [PATCH 1/2] add error checking: modulo 2 --- .../madis/src/functionslocal/row/errorchecking.py | 10 ++++++++++ .../src/mip-algorithms/TTEST_PAIRED/local.template.sql | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/Exareme-Docker/src/exareme/exareme-tools/madis/src/functionslocal/row/errorchecking.py b/Exareme-Docker/src/exareme/exareme-tools/madis/src/functionslocal/row/errorchecking.py index 922669a29..84e7a8aa5 100644 --- a/Exareme-Docker/src/exareme/exareme-tools/madis/src/functionslocal/row/errorchecking.py +++ b/Exareme-Docker/src/exareme/exareme-tools/madis/src/functionslocal/row/errorchecking.py @@ -95,6 +95,16 @@ def histograms_inputerrorchecking(xisCategorical,bins): histograms_inputerrorchecking.registered = True +def pairedttest_inputerrorchecking(variableNo): + if variableNo%2 == 1: + raise functions.OperatorError("ExaremeError", "The input should be in the form of y1-y2,y3-y4,.. Therefore the number of variables should be modulo 2") + else: + return "OK" + +pairedttest_inputerrorchecking.registered = True + + + if not ('.' in __name__): """ This is needed to be able to test the function, put it at the end of every diff --git a/Exareme-Docker/src/mip-algorithms/TTEST_PAIRED/local.template.sql b/Exareme-Docker/src/mip-algorithms/TTEST_PAIRED/local.template.sql index 174c344d7..b4b18c67e 100644 --- a/Exareme-Docker/src/mip-algorithms/TTEST_PAIRED/local.template.sql +++ b/Exareme-Docker/src/mip-algorithms/TTEST_PAIRED/local.template.sql @@ -12,6 +12,16 @@ var 'xnames' from select group_concat(xname) as xname from (select distinct xname from (select strsplitv(regexpr("\-",'%{x}',"+") ,'delimiter:+') as xname) where xname!=0); + +--Check input: number of variables is modulo 2 +select pairedttest_inputerrorchecking(no) from +(select count(*) as no from +(select strsplitv(xname,'dialect:csv') from +(select group_concat(xname) as xname from +(select distinct xname from (select strsplitv(regexpr("\-",'%{x}',"+") ,'delimiter:+') as xname) where xname!=0)))); + + + --Read dataset and Cast values of columns using cast function. var 'cast_x' from select create_complex_query("","tonumber(?) as ?", "," , "" , '%{xnames}'); drop table if exists localinputtblflat; From 4dfff4622db05098e23729d0f6b55a39bd2c3b6a Mon Sep 17 00:00:00 2001 From: Eleni Date: Tue, 17 Nov 2020 12:36:29 +0200 Subject: [PATCH 2/2] add exareme test for modulo2 --- .../tests/exareme_tests/test_parameters.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Exareme-Docker/src/mip-algorithms/tests/exareme_tests/test_parameters.py b/Exareme-Docker/src/mip-algorithms/tests/exareme_tests/test_parameters.py index f0d969f12..fbd534d60 100644 --- a/Exareme-Docker/src/mip-algorithms/tests/exareme_tests/test_parameters.py +++ b/Exareme-Docker/src/mip-algorithms/tests/exareme_tests/test_parameters.py @@ -8,6 +8,27 @@ from tests import vm_url + +def test_parameter_modulo2(): + + endpointUrl1 = vm_url + "TTEST_PAIRED" + + logging.info("---------- TEST : t-test input parameters throwing error.") + data = [ + {"name": "y", "value": "lefthippocampus-righthippocampus,leftententorhinalarea"}, + {"name": "hypothesis", "value": "different"}, + {"name": "pathology", "value": "dementia"}, + {"name": "dataset", "value": "desd-synthdata"}, + {"name": "filter", "value": ""}, + ] + headers = {"Content-type": "application/json", "Accept": "text/plain"} + r = requests.post(endpointUrl1, data=json.dumps(data), headers=headers) + result = json.loads(r.text) + assert(result["result"][0]["data"]==" The input should be in the form of y1-y2,y3-y4,.. Therefore the number of variables should be modulo 2 ") + assert(result["result"][0]["type"]=="text/plain+user_error") + + + def test_valueEnumerationsParameter(): endpointUrl1 = vm_url + "LINEAR_REGRESSION"