Skip to content

Commit

Permalink
Merge pull request #292 from madgik/pairedttest
Browse files Browse the repository at this point in the history
Pairedttest
  • Loading branch information
ThanKarab authored Nov 19, 2020
2 parents 72951e7 + 4dfff46 commit f7fd099
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions Exareme-Docker/src/mip-algorithms/TTEST_PAIRED/local.template.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit f7fd099

Please sign in to comment.