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; 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"