Index: lnt/external/stats/pstat.py =================================================================== --- lnt/external/stats/pstat.py +++ lnt/external/stats/pstat.py @@ -130,10 +130,10 @@ 'left', lists in attached consecutively on the 'right' """ - if type(source) not in [ListType,TupleType]: + if type(source) not in [list,tuple]: source = [source] for addon in args: - if type(addon) not in [ListType,TupleType]: + if type(addon) not in [list,tuple]: addon = [addon] if len(addon) < len(source): # is source list longer? if len(source) % len(addon) == 0: # are they integer multiples? @@ -176,21 +176,21 @@ Returns: a list of lists as long as source, with source on the 'left' and addon on the 'right' """ - if type(source) not in [ListType,TupleType]: + if type(source) not in [list,tuple]: source = [source] - if type(addon) not in [ListType,TupleType]: + if type(addon) not in [list,tuple]: addon = [addon] minlen = min(len(source),len(addon)) list = copy.deepcopy(source) # start abut process - if type(source[0]) not in [ListType,TupleType]: - if type(addon[0]) not in [ListType,TupleType]: + if type(source[0]) not in [list,tuple]: + if type(addon[0]) not in [list,tuple]: for i in range(minlen): list[i] = [source[i]] + [addon[i]] # source/addon = column else: for i in range(minlen): list[i] = [source[i]] + addon[i] # addon=list-of-lists else: - if type(addon[0]) not in [ListType,TupleType]: + if type(addon[0]) not in [list,tuple]: for i in range(minlen): list[i] = source[i] + [addon[i]] # source=list-of-lists else: @@ -213,13 +213,13 @@ """ global index column = 0 - if type(cnums) in [ListType,TupleType]: # if multiple columns to get + if type(cnums) in [list,tuple]: # if multiple columns to get index = cnums[0] column = map(lambda x: x[index], listoflists) for col in cnums[1:]: index = col column = abut(column,map(lambda x: x[index], listoflists)) - elif type(cnums) == StringType: # if an 'x[3:]' type expr. + elif type(cnums) == str: # if an 'x[3:]' type expr. evalstring = 'map(lambda x: x'+cnums+', listoflists)' column = eval(evalstring) else: # else it's just 1 col to get @@ -251,9 +251,9 @@ s = s + item return s/float(len(inlist)) - if type(keepcols) not in [ListType,TupleType]: + if type(keepcols) not in [list,tuple]: keepcols = [keepcols] - if type(collapsecols) not in [ListType,TupleType]: + if type(collapsecols) not in [list,tuple]: collapsecols = [collapsecols] if cfcn == None: cfcn = collmean @@ -283,20 +283,20 @@ uniques = unique(values) uniques.sort() newlist = [] - if type(keepcols) not in [ListType,TupleType]: keepcols = [keepcols] + if type(keepcols) not in [list,tuple]: keepcols = [keepcols] for item in uniques: - if type(item) not in [ListType,TupleType]: item =[item] + if type(item) not in [list,tuple]: item =[item] tmprows = linexand(listoflists,keepcols,item) for col in collapsecols: avgcol = colex(tmprows,col) item.append(cfcn(avgcol)) - if fcn1 <> None: + if fcn1 != None: try: test = fcn1(avgcol) except: test = 'N/A' item.append(test) - if fcn2 <> None: + if fcn2 != None: try: test = fcn2(avgcol) except: @@ -344,13 +344,13 @@ Usage: linexand (listoflists,columnlist,valuelist) Returns: the rows of listoflists where columnlist[i]=valuelist[i] for ALL i """ - if type(columnlist) not in [ListType,TupleType]: + if type(columnlist) not in [list,tuple]: columnlist = [columnlist] - if type(valuelist) not in [ListType,TupleType]: + if type(valuelist) not in [list,tuple]: valuelist = [valuelist] criterion = '' for i in range(len(columnlist)): - if type(valuelist[i])==StringType: + if type(valuelist[i])==str: critval = '\'' + valuelist[i] + '\'' else: critval = str(valuelist[i]) @@ -372,15 +372,15 @@ Usage: linexor (listoflists,columnlist,valuelist) Returns: the rows of listoflists where columnlist[i]=valuelist[i] for ANY i """ - if type(columnlist) not in [ListType,TupleType]: + if type(columnlist) not in [list,tuple]: columnlist = [columnlist] - if type(valuelist) not in [ListType,TupleType]: + if type(valuelist) not in [list,tuple]: valuelist = [valuelist] criterion = '' if len(columnlist) == 1 and len(valuelist) > 1: columnlist = columnlist*len(valuelist) for i in range(len(columnlist)): # build an exec string - if type(valuelist[i])==StringType: + if type(valuelist[i])==str: critval = '\'' + valuelist[i] + '\'' else: critval = str(valuelist[i]) @@ -401,7 +401,7 @@ """ outstr = '' for item in inlist: - if type(item) <> StringType: + if type(item) != str: item = str(item) outstr = outstr + item + delimiter outstr = outstr[0:-1] @@ -417,7 +417,7 @@ """ outstr = '' for item in inlist: - if type(item) <> StringType: + if type(item) != str: item = str(item) size = len(item) if size <= colsize: @@ -441,7 +441,7 @@ """ outstr = '' for i in range(len(inlist)): - if type(inlist[i]) <> StringType: + if type(inlist[i]) != str: item = str(inlist[i]) else: item = inlist[i] @@ -482,7 +482,7 @@ def makestr (x): - if type(x) <> StringType: + if type(x) != str: x = str(x) return x @@ -497,7 +497,7 @@ Usage: printcc (lst,extra=2) Returns: None """ - if type(lst[0]) not in [ListType,TupleType]: + if type(lst[0]) not in [list,tuple]: lst = [lst] rowstokill = [] list2print = copy.deepcopy(lst) @@ -567,7 +567,7 @@ """ lst = inlst*1 for i in range(len(lst)): - if type(lst[i]) not in [ListType,TupleType]: + if type(lst[i]) not in [list,tuple]: if lst[i]==oldval: lst[i]=newval else: lst[i] = replace(lst[i],oldval,newval) @@ -585,7 +585,7 @@ """ lst = copy.deepcopy(inlist) if cols != None: - if type(cols) not in [ListType,TupleType]: + if type(cols) not in [list,tuple]: cols = [cols] for col in cols: for row in range(len(lst)): @@ -755,7 +755,7 @@ Usage: acolex (a,indices,axis=1) Returns: the columns of a specified by indices """ - if type(indices) not in [ListType,TupleType,N.ndarray]: + if type(indices) not in [list,tuple,N.ndarray]: indices = [indices] if len(N.shape(a)) == 1: cols = N.resize(a,[a.shape[0],1]) @@ -779,9 +779,9 @@ def acollmean (inarray): return N.sum(N.ravel(inarray)) - if type(keepcols) not in [ListType,TupleType,N.ndarray]: + if type(keepcols) not in [list,tuple,N.ndarray]: keepcols = [keepcols] - if type(collapsecols) not in [ListType,TupleType,N.ndarray]: + if type(collapsecols) not in [list,tuple,N.ndarray]: collapsecols = [collapsecols] if cfcn == None: @@ -789,13 +789,13 @@ if keepcols == []: avgcol = acolex(a,collapsecols) means = N.sum(avgcol)/float(len(avgcol)) - if fcn1<>None: + if fcn1!=None: try: test = fcn1(avgcol) except: test = N.array(['N/A']*len(means)) means = aabut(means,test) - if fcn2<>None: + if fcn2!=None: try: test = fcn2(avgcol) except: @@ -803,26 +803,26 @@ means = aabut(means,test) return means else: - if type(keepcols) not in [ListType,TupleType,N.ndarray]: + if type(keepcols) not in [list,tuple,N.ndarray]: keepcols = [keepcols] values = colex(a,keepcols) # so that "item" can be appended (below) uniques = unique(values) # get a LIST, so .sort keeps rows intact uniques.sort() newlist = [] for item in uniques: - if type(item) not in [ListType,TupleType,N.ndarray]: + if type(item) not in [list,tuple,N.ndarray]: item =[item] tmprows = alinexand(a,keepcols,item) for col in collapsecols: avgcol = acolex(tmprows,col) item.append(acollmean(avgcol)) - if fcn1<>None: + if fcn1!=None: try: test = fcn1(avgcol) except: test = 'N/A' item.append(test) - if fcn2<>None: + if fcn2!=None: try: test = fcn2(avgcol) except: @@ -853,7 +853,7 @@ def isstring(x): - if type(x)==StringType: + if type(x)==str: return 1 else: return 0 @@ -867,13 +867,13 @@ Usage: alinexand (a,columnlist,valuelist) Returns: the rows of a where columnlist[i]=valuelist[i] for ALL i """ - if type(columnlist) not in [ListType,TupleType,N.ndarray]: + if type(columnlist) not in [list,tuple,N.ndarray]: columnlist = [columnlist] - if type(valuelist) not in [ListType,TupleType,N.ndarray]: + if type(valuelist) not in [list,tuple,N.ndarray]: valuelist = [valuelist] criterion = '' for i in range(len(columnlist)): - if type(valuelist[i])==StringType: + if type(valuelist[i])==str: critval = '\'' + valuelist[i] + '\'' else: critval = str(valuelist[i]) @@ -893,9 +893,9 @@ Usage: alinexor (a,columnlist,valuelist) Returns: the rows of a where columnlist[i]=valuelist[i] for ANY i """ - if type(columnlist) not in [ListType,TupleType,N.ndarray]: + if type(columnlist) not in [list,tuple,N.ndarray]: columnlist = [columnlist] - if type(valuelist) not in [ListType,TupleType,N.ndarray]: + if type(valuelist) not in [list,tuple,N.ndarray]: valuelist = [valuelist] criterion = '' if len(columnlist) == 1 and len(valuelist) > 1: @@ -903,7 +903,7 @@ elif len(valuelist) == 1 and len(columnlist) > 1: valuelist = valuelist*len(columnlist) for i in range(len(columnlist)): - if type(valuelist[i])==StringType: + if type(valuelist[i])==str: critval = '\'' + valuelist[i] + '\'' else: critval = str(valuelist[i]) @@ -938,7 +938,7 @@ work = acolex(a,col) work = work.ravel() for pair in listmap: - if type(pair[1]) == StringType or work.dtype.char=='O' or a.dtype.char=='O': + if type(pair[1]) == str or work.dtype.char=='O' or a.dtype.char=='O': work = N.array(work,dtype='O') a = N.array(a,dtype='O') for i in range(len(work)): Index: lnt/external/stats/stats.py =================================================================== --- lnt/external/stats/stats.py +++ lnt/external/stats/stats.py @@ -246,13 +246,13 @@ for func, types in tuples: for t in types: if t in self._dispatch.keys(): - raise ValueError, "can't have two dispatches on "+str(t) + raise ValueError("can't have two dispatches on "+str(t)) self._dispatch[t] = func self._types = self._dispatch.keys() def __call__(self, arg1, *args, **kw): if type(arg1) not in self._types: - raise TypeError, "don't know how to dispatch %s arguments" % type(arg1) + raise TypeError("don't know how to dispatch %s arguments" % type(arg1)) return apply(self._dispatch[type(arg1)], (arg1,) + args, kw) @@ -511,8 +511,8 @@ Usage: lhistogram (inlist, numbins=10, defaultreallimits=None,suppressoutput=0) Returns: list of bin values, lowerreallimit, binsize, extrapoints """ - if (defaultreallimits <> None): - if type(defaultreallimits) not in [ListType,TupleType] or len(defaultreallimits)==1: # only one limit given, assumed to be lower one & upper is calc'd + if (defaultreallimits != None): + if type(defaultreallimits) not in [list,tuple] or len(defaultreallimits)==1: # only one limit given, assumed to be lower one & upper is calc'd lowerreallimit = defaultreallimits upperreallimit = 1.000001 * max(inlist) else: # assume both limits given @@ -598,8 +598,8 @@ for j in range(k): if v[j] - mean(nargs[j]) > TINY: check = 0 - if check <> 1: - raise ValueError, 'Problem in obrientransform.' + if check != 1: + raise ValueError('Problem in obrientransform.') else: return nargs @@ -841,8 +841,8 @@ Returns: Pearson's r value, two-tailed p-value """ TINY = 1.0e-30 - if len(x) <> len(y): - raise ValueError, 'Input values not paired in pearsonr. Aborting.' + if len(x) != len(y): + raise ValueError('Input values not paired in pearsonr. Aborting.') n = len(x) x = map(float,x) y = map(float,y) @@ -880,8 +880,8 @@ Returns: Spearman's r, two-tailed p-value """ TINY = 1e-30 - if len(x) <> len(y): - raise ValueError, 'Input values not paired in spearmanr. Aborting.' + if len(x) != len(y): + raise ValueError('Input values not paired in spearmanr. Aborting.') n = len(x) rankx = rankdata(x) ranky = rankdata(y) @@ -905,12 +905,12 @@ Returns: Point-biserial r, two-tailed p-value """ TINY = 1e-30 - if len(x) <> len(y): - raise ValueError, 'INPUT VALUES NOT PAIRED IN pointbiserialr. ABORTING.' + if len(x) != len(y): + raise ValueError('INPUT VALUES NOT PAIRED IN pointbiserialr. ABORTING.') data = pstat.abut(x,y) categories = pstat.unique(x) - if len(categories) <> 2: - raise ValueError, "Exactly 2 categories required for pointbiserialr()." + if len(categories) != 2: + raise ValueError("Exactly 2 categories required for pointbiserialr().") else: # there are 2 categories, continue codemap = pstat.abut(categories,range(2)) recoded = pstat.recode(data,codemap,0) @@ -970,8 +970,8 @@ Returns: slope, intercept, r, two-tailed prob, sterr-of-estimate """ TINY = 1.0e-20 - if len(x) <> len(y): - raise ValueError, 'Input values not paired in linregress. Aborting.' + if len(x) != len(y): + raise ValueError('Input values not paired in linregress. Aborting.') n = len(x) x = map(float,x) y = map(float,y) @@ -1012,7 +1012,7 @@ t = (x-popmean)/math.sqrt(svar*(1.0/n)) prob = betai(0.5*df,0.5,float(df)/(df+t*t)) - if printit <> 0: + if printit != 0: statname = 'Single-sample T-test.' outputpairedstats(printit,writemode, 'Population','--',popmean,0,0,0, @@ -1043,7 +1043,7 @@ t = (x1-x2)/math.sqrt(svar*(1.0/n1 + 1.0/n2)) prob = betai(0.5*df,0.5,df/(df+t*t)) - if printit <> 0: + if printit != 0: statname = 'Independent samples T-test.' outputpairedstats(printit,writemode, name1,n1,x1,v1,min(a),max(a), @@ -1063,8 +1063,8 @@ Usage: lttest_rel(a,b,printit=0,name1='Sample1',name2='Sample2',writemode='a') Returns: t-value, two-tailed prob """ - if len(a)<>len(b): - raise ValueError, 'Unequal length lists in ttest_rel.' + if len(a)!=len(b): + raise ValueError('Unequal length lists in ttest_rel.') x1 = mean(a) x2 = mean(b) v1 = var(a) @@ -1079,7 +1079,7 @@ t = (x1-x2)/sd prob = betai(0.5*df,0.5,df/(df+t*t)) - if printit <> 0: + if printit != 0: statname = 'Related samples T-test.' outputpairedstats(printit,writemode, name1,n,x1,v1,min(a),max(a), @@ -1168,7 +1168,7 @@ smallu = min(u1,u2) T = math.sqrt(tiecorrect(ranked)) # correction factor for tied scores if T == 0: - raise ValueError, 'All numbers are identical in lmannwhitneyu' + raise ValueError('All numbers are identical in lmannwhitneyu') sd = math.sqrt(T*n1*n2*(n1+n2+1)/12.0) z = abs((bigu-n1*n2/2.0) / sd) # normal approximation for prob calc return smallu, 1.0 - zprob(z) @@ -1229,12 +1229,12 @@ Usage: lwilcoxont(x,y) Returns: a t-statistic, two-tail probability estimate """ - if len(x) <> len(y): - raise ValueError, 'Unequal N in wilcoxont. Aborting.' + if len(x) != len(y): + raise ValueError('Unequal N in wilcoxont. Aborting.') d=[] for i in range(len(x)): diff = x[i] - y[i] - if diff <> 0: + if diff != 0: d.append(diff) count = len(d) absd = map(abs,d) @@ -1284,7 +1284,7 @@ h = 12.0 / (totaln*(totaln+1)) * ssbn - 3*(totaln+1) df = len(args) - 1 if T == 0: - raise ValueError, 'All numbers are identical in lkruskalwallish' + raise ValueError('All numbers are identical in lkruskalwallish') h = h / float(T) return h, chisqprob(h,df) @@ -1303,7 +1303,7 @@ """ k = len(args) if k < 3: - raise ValueError, 'Less than 3 levels. Friedman test not appropriate.' + raise ValueError('Less than 3 levels. Friedman test not appropriate.') n = len(args[0]) data = apply(pstat.abut,tuple(args)) for i in range(len(data)): @@ -1538,7 +1538,7 @@ Usage: lbetai(a,b,x) """ if (x<0.0 or x>1.0): - raise ValueError, 'Bad x in lbetai' + raise ValueError('Bad x in lbetai') if (x==0.0 or x==1.0): bt = 0.0 else: @@ -1617,7 +1617,7 @@ Usage: writecc (listoflists,file,writetype='w',extra=2) Returns: None """ - if type(listoflists[0]) not in [ListType,TupleType]: + if type(listoflists[0]) not in [list,tuple]: listoflists = [listoflists] outfile = open(file,writetype) rowstokill = [] @@ -1711,8 +1711,8 @@ Usage: lsummult(list1,list2) """ - if len(list1) <> len(list2): - raise ValueError, "Lists not equal length in summult." + if len(list1) != len(list2): + raise ValueError("Lists not equal length in summult.") s = 0 for item1,item2 in pstat.abut(list1,list2): s = s + item1*item2 @@ -1787,7 +1787,7 @@ for i in range(n): sumranks = sumranks + i dupcount = dupcount + 1 - if i==n-1 or svec[i] <> svec[i+1]: + if i==n-1 or svec[i] != svec[i+1]: averank = sumranks / float(dupcount) + 1 for j in range(i-dupcount+1,i+1): newlist[ivec[j]] = averank @@ -1820,7 +1820,7 @@ title = [['Name','N','Mean','SD','Min','Max']] lofl = title+[[name1,n1,round(m1,3),round(math.sqrt(se1),3),min1,max1], [name2,n2,round(m2,3),round(math.sqrt(se2),3),min2,max2]] - if type(fname)<>StringType or len(fname)==0: + if type(fname)!=StringType or len(fname)==0: print print statname print @@ -1885,89 +1885,89 @@ ######################################################### ## CENTRAL TENDENCY: -geometricmean = Dispatch ( (lgeometricmean, (ListType, TupleType)), ) -harmonicmean = Dispatch ( (lharmonicmean, (ListType, TupleType)), ) -mean = Dispatch ( (lmean, (ListType, TupleType)), ) -median = Dispatch ( (lmedian, (ListType, TupleType)), ) -medianscore = Dispatch ( (lmedianscore, (ListType, TupleType)), ) -mode = Dispatch ( (lmode, (ListType, TupleType)), ) +geometricmean = Dispatch ( (lgeometricmean, (list, tuple)), ) +harmonicmean = Dispatch ( (lharmonicmean, (list, tuple)), ) +mean = Dispatch ( (lmean, (list, tuple)), ) +median = Dispatch ( (lmedian, (list, tuple)), ) +medianscore = Dispatch ( (lmedianscore, (list, tuple)), ) +mode = Dispatch ( (lmode, (list, tuple)), ) ## MOMENTS: -moment = Dispatch ( (lmoment, (ListType, TupleType)), ) -variation = Dispatch ( (lvariation, (ListType, TupleType)), ) -skew = Dispatch ( (lskew, (ListType, TupleType)), ) -kurtosis = Dispatch ( (lkurtosis, (ListType, TupleType)), ) -describe = Dispatch ( (ldescribe, (ListType, TupleType)), ) +moment = Dispatch ( (lmoment, (list, tuple)), ) +variation = Dispatch ( (lvariation, (list, tuple)), ) +skew = Dispatch ( (lskew, (list, tuple)), ) +kurtosis = Dispatch ( (lkurtosis, (list, tuple)), ) +describe = Dispatch ( (ldescribe, (list, tuple)), ) ## FREQUENCY STATISTICS: -itemfreq = Dispatch ( (litemfreq, (ListType, TupleType)), ) -scoreatpercentile = Dispatch ( (lscoreatpercentile, (ListType, TupleType)), ) -percentileofscore = Dispatch ( (lpercentileofscore, (ListType, TupleType)), ) -histogram = Dispatch ( (lhistogram, (ListType, TupleType)), ) -cumfreq = Dispatch ( (lcumfreq, (ListType, TupleType)), ) -relfreq = Dispatch ( (lrelfreq, (ListType, TupleType)), ) +itemfreq = Dispatch ( (litemfreq, (list, tuple)), ) +scoreatpercentile = Dispatch ( (lscoreatpercentile, (list, tuple)), ) +percentileofscore = Dispatch ( (lpercentileofscore, (list, tuple)), ) +histogram = Dispatch ( (lhistogram, (list, tuple)), ) +cumfreq = Dispatch ( (lcumfreq, (list, tuple)), ) +relfreq = Dispatch ( (lrelfreq, (list, tuple)), ) ## VARIABILITY: -obrientransform = Dispatch ( (lobrientransform, (ListType, TupleType)), ) -samplevar = Dispatch ( (lsamplevar, (ListType, TupleType)), ) -samplestdev = Dispatch ( (lsamplestdev, (ListType, TupleType)), ) -var = Dispatch ( (lvar, (ListType, TupleType)), ) -stdev = Dispatch ( (lstdev, (ListType, TupleType)), ) -sterr = Dispatch ( (lsterr, (ListType, TupleType)), ) -sem = Dispatch ( (lsem, (ListType, TupleType)), ) -z = Dispatch ( (lz, (ListType, TupleType)), ) -zs = Dispatch ( (lzs, (ListType, TupleType)), ) +obrientransform = Dispatch ( (lobrientransform, (list, tuple)), ) +samplevar = Dispatch ( (lsamplevar, (list, tuple)), ) +samplestdev = Dispatch ( (lsamplestdev, (list, tuple)), ) +var = Dispatch ( (lvar, (list, tuple)), ) +stdev = Dispatch ( (lstdev, (list, tuple)), ) +sterr = Dispatch ( (lsterr, (list, tuple)), ) +sem = Dispatch ( (lsem, (list, tuple)), ) +z = Dispatch ( (lz, (list, tuple)), ) +zs = Dispatch ( (lzs, (list, tuple)), ) ## TRIMMING FCNS: -trimboth = Dispatch ( (ltrimboth, (ListType, TupleType)), ) -trim1 = Dispatch ( (ltrim1, (ListType, TupleType)), ) +trimboth = Dispatch ( (ltrimboth, (list, tuple)), ) +trim1 = Dispatch ( (ltrim1, (list, tuple)), ) ## CORRELATION FCNS: -paired = Dispatch ( (lpaired, (ListType, TupleType)), ) -pearsonr = Dispatch ( (lpearsonr, (ListType, TupleType)), ) -spearmanr = Dispatch ( (lspearmanr, (ListType, TupleType)), ) -pointbiserialr = Dispatch ( (lpointbiserialr, (ListType, TupleType)), ) -kendalltau = Dispatch ( (lkendalltau, (ListType, TupleType)), ) -linregress = Dispatch ( (llinregress, (ListType, TupleType)), ) +paired = Dispatch ( (lpaired, (list, tuple)), ) +pearsonr = Dispatch ( (lpearsonr, (list, tuple)), ) +spearmanr = Dispatch ( (lspearmanr, (list, tuple)), ) +pointbiserialr = Dispatch ( (lpointbiserialr, (list, tuple)), ) +kendalltau = Dispatch ( (lkendalltau, (list, tuple)), ) +linregress = Dispatch ( (llinregress, (list, tuple)), ) ## INFERENTIAL STATS: -ttest_1samp = Dispatch ( (lttest_1samp, (ListType, TupleType)), ) -ttest_ind = Dispatch ( (lttest_ind, (ListType, TupleType)), ) -ttest_rel = Dispatch ( (lttest_rel, (ListType, TupleType)), ) -chisquare = Dispatch ( (lchisquare, (ListType, TupleType)), ) -ks_2samp = Dispatch ( (lks_2samp, (ListType, TupleType)), ) -mannwhitneyu = Dispatch ( (lmannwhitneyu, (ListType, TupleType)), ) -ranksums = Dispatch ( (lranksums, (ListType, TupleType)), ) -tiecorrect = Dispatch ( (ltiecorrect, (ListType, TupleType)), ) -wilcoxont = Dispatch ( (lwilcoxont, (ListType, TupleType)), ) -kruskalwallish = Dispatch ( (lkruskalwallish, (ListType, TupleType)), ) -friedmanchisquare = Dispatch ( (lfriedmanchisquare, (ListType, TupleType)), ) +ttest_1samp = Dispatch ( (lttest_1samp, (list, tuple)), ) +ttest_ind = Dispatch ( (lttest_ind, (list, tuple)), ) +ttest_rel = Dispatch ( (lttest_rel, (list, tuple)), ) +chisquare = Dispatch ( (lchisquare, (list, tuple)), ) +ks_2samp = Dispatch ( (lks_2samp, (list, tuple)), ) +mannwhitneyu = Dispatch ( (lmannwhitneyu, (list, tuple)), ) +ranksums = Dispatch ( (lranksums, (list, tuple)), ) +tiecorrect = Dispatch ( (ltiecorrect, (list, tuple)), ) +wilcoxont = Dispatch ( (lwilcoxont, (list, tuple)), ) +kruskalwallish = Dispatch ( (lkruskalwallish, (list, tuple)), ) +friedmanchisquare = Dispatch ( (lfriedmanchisquare, (list, tuple)), ) ## PROBABILITY CALCS: -chisqprob = Dispatch ( (lchisqprob, (IntType, FloatType)), ) -zprob = Dispatch ( (lzprob, (IntType, FloatType)), ) -ksprob = Dispatch ( (lksprob, (IntType, FloatType)), ) -fprob = Dispatch ( (lfprob, (IntType, FloatType)), ) -betacf = Dispatch ( (lbetacf, (IntType, FloatType)), ) -betai = Dispatch ( (lbetai, (IntType, FloatType)), ) -erfcc = Dispatch ( (lerfcc, (IntType, FloatType)), ) -gammln = Dispatch ( (lgammln, (IntType, FloatType)), ) +chisqprob = Dispatch ( (lchisqprob, (int, float)), ) +zprob = Dispatch ( (lzprob, (int, float)), ) +ksprob = Dispatch ( (lksprob, (int, float)), ) +fprob = Dispatch ( (lfprob, (int, float)), ) +betacf = Dispatch ( (lbetacf, (int, float)), ) +betai = Dispatch ( (lbetai, (int, float)), ) +erfcc = Dispatch ( (lerfcc, (int, float)), ) +gammln = Dispatch ( (lgammln, (int, float)), ) ## ANOVA FUNCTIONS: -F_oneway = Dispatch ( (lF_oneway, (ListType, TupleType)), ) -F_value = Dispatch ( (lF_value, (ListType, TupleType)), ) +F_oneway = Dispatch ( (lF_oneway, (list, tuple)), ) +F_value = Dispatch ( (lF_value, (list, tuple)), ) ## SUPPORT FUNCTIONS: -incr = Dispatch ( (lincr, (ListType, TupleType)), ) -sum = Dispatch ( (lsum, (ListType, TupleType)), ) -cumsum = Dispatch ( (lcumsum, (ListType, TupleType)), ) -ss = Dispatch ( (lss, (ListType, TupleType)), ) -summult = Dispatch ( (lsummult, (ListType, TupleType)), ) -square_of_sums = Dispatch ( (lsquare_of_sums, (ListType, TupleType)), ) -sumdiffsquared = Dispatch ( (lsumdiffsquared, (ListType, TupleType)), ) -shellsort = Dispatch ( (lshellsort, (ListType, TupleType)), ) -rankdata = Dispatch ( (lrankdata, (ListType, TupleType)), ) -findwithin = Dispatch ( (lfindwithin, (ListType, TupleType)), ) +incr = Dispatch ( (lincr, (list, tuple)), ) +sum = Dispatch ( (lsum, (list, tuple)), ) +cumsum = Dispatch ( (lcumsum, (list, tuple)), ) +ss = Dispatch ( (lss, (list, tuple)), ) +summult = Dispatch ( (lsummult, (list, tuple)), ) +square_of_sums = Dispatch ( (lsquare_of_sums, (list, tuple)), ) +sumdiffsquared = Dispatch ( (lsumdiffsquared, (list, tuple)), ) +shellsort = Dispatch ( (lshellsort, (list, tuple)), ) +rankdata = Dispatch ( (lrankdata, (list, tuple)), ) +findwithin = Dispatch ( (lfindwithin, (list, tuple)), ) #============= THE ARRAY-VERSION OF THE STATS FUNCTIONS =============== @@ -2018,7 +2018,7 @@ size = len(inarray) mult = N.power(inarray,1.0/size) mult = N.multiply.reduce(mult) - elif type(dimension) in [IntType,FloatType]: + elif type(dimension) in [int,float]: size = inarray.shape[dimension] mult = N.power(inarray,1.0/size) mult = N.multiply.reduce(mult,dimension) @@ -2060,7 +2060,7 @@ inarray = N.ravel(inarray) size = len(inarray) s = N.add.reduce(1.0 / inarray) - elif type(dimension) in [IntType,FloatType]: + elif type(dimension) in [int,float]: size = float(inarray.shape[dimension]) s = N.add.reduce(1.0/inarray, dimension) if keepdims == 1: @@ -2085,7 +2085,7 @@ idx[0] = -1 loopcap = N.array(tinarray.shape[0:len(nondims)]) -1 s = N.zeros(loopcap+1,N.float_) - while incr(idx,loopcap) <> -1: + while incr(idx,loopcap) != -1: s[idx] = asum(1.0/tinarray[idx]) size = N.multiply.reduce(N.take(inarray.shape,dims)) if keepdims == 1: @@ -2115,7 +2115,7 @@ inarray = N.ravel(inarray) sum = N.add.reduce(inarray) denom = float(len(inarray)) - elif type(dimension) in [IntType,FloatType]: + elif type(dimension) in [int,float]: sum = asum(inarray,dimension) denom = float(inarray.shape[dimension]) if keepdims == 1: @@ -2229,18 +2229,18 @@ a = a.astype(N.float_) if limits == None: return mean(a) - assert type(limits) in [ListType,TupleType,N.ndarray], "Wrong type for limits in atmean" + assert type(limits) in [list,tuple,N.ndarray], "Wrong type for limits in atmean" if inclusive[0]: lowerfcn = N.greater_equal else: lowerfcn = N.greater if inclusive[1]: upperfcn = N.less_equal else: upperfcn = N.less if limits[0] > N.maximum.reduce(N.ravel(a)) or limits[1] < N.minimum.reduce(N.ravel(a)): - raise ValueError, "No array values within given limits (atmean)." - elif limits[0]==None and limits[1]<>None: + raise ValueError("No array values within given limits (atmean).") + elif limits[0]==None and limits[1]!=None: mask = upperfcn(a,limits[1]) - elif limits[0]<>None and limits[1]==None: + elif limits[0]!=None and limits[1]==None: mask = lowerfcn(a,limits[0]) - elif limits[0]<>None and limits[1]<>None: + elif limits[0]!=None and limits[1]!=None: mask = lowerfcn(a,limits[0])*upperfcn(a,limits[1]) s = float(N.add.reduce(N.ravel(a*mask))) n = float(N.add.reduce(N.ravel(mask))) @@ -2261,18 +2261,18 @@ a = a.astype(N.float_) if limits == None or limits == [None,None]: return avar(a) - assert type(limits) in [ListType,TupleType,N.ndarray], "Wrong type for limits in atvar" + assert type(limits) in [list,tuple,N.ndarray], "Wrong type for limits in atvar" if inclusive[0]: lowerfcn = N.greater_equal else: lowerfcn = N.greater if inclusive[1]: upperfcn = N.less_equal else: upperfcn = N.less if limits[0] > N.maximum.reduce(N.ravel(a)) or limits[1] < N.minimum.reduce(N.ravel(a)): - raise ValueError, "No array values within given limits (atvar)." - elif limits[0]==None and limits[1]<>None: + raise ValueError("No array values within given limits (atvar).") + elif limits[0]==None and limits[1]!=None: mask = upperfcn(a,limits[1]) - elif limits[0]<>None and limits[1]==None: + elif limits[0]!=None and limits[1]==None: mask = lowerfcn(a,limits[0]) - elif limits[0]<>None and limits[1]<>None: + elif limits[0]!=None and limits[1]!=None: mask = lowerfcn(a,limits[0])*upperfcn(a,limits[1]) a = N.compress(mask,a) # squish out excluded values @@ -2347,18 +2347,18 @@ if limits == None or limits == [None,None]: n = float(len(N.ravel(a))) limits = [min(a)-1, max(a)+1] - assert type(limits) in [ListType,TupleType,N.ndarray], "Wrong type for limits in atsem" + assert type(limits) in [list,tuple,N.ndarray], "Wrong type for limits in atsem" if inclusive[0]: lowerfcn = N.greater_equal else: lowerfcn = N.greater if inclusive[1]: upperfcn = N.less_equal else: upperfcn = N.less if limits[0] > N.maximum.reduce(N.ravel(a)) or limits[1] < N.minimum.reduce(N.ravel(a)): - raise ValueError, "No array values within given limits (atsem)." - elif limits[0]==None and limits[1]<>None: + raise ValueError("No array values within given limits (atsem).") + elif limits[0]==None and limits[1]!=None: mask = upperfcn(a,limits[1]) - elif limits[0]<>None and limits[1]==None: + elif limits[0]!=None and limits[1]==None: mask = lowerfcn(a,limits[0]) - elif limits[0]<>None and limits[1]<>None: + elif limits[0]!=None and limits[1]!=None: mask = lowerfcn(a,limits[0])*upperfcn(a,limits[1]) term1 = N.add.reduce(N.ravel(a*a*mask)) n = float(N.add.reduce(N.ravel(mask))) @@ -2416,7 +2416,7 @@ """ denom = N.power(amoment(a,2,dimension),1.5) zero = N.equal(denom,0) - if type(denom) == N.ndarray and asum(zero) <> 0: + if type(denom) == N.ndarray and asum(zero) != 0: print "Number of zeros in askew: ",asum(zero) denom = denom + zero # prevent divide-by-zero return N.where(zero, 0, amoment(a,3,dimension)/denom) @@ -2435,7 +2435,7 @@ """ denom = N.power(amoment(a,2,dimension),2) zero = N.equal(denom,0) - if type(denom) == N.ndarray and asum(zero) <> 0: + if type(denom) == N.ndarray and asum(zero) != 0: print "Number of zeros in akurtosis: ",asum(zero) denom = denom + zero # prevent divide-by-zero return N.where(zero,0,amoment(a,4,dimension)/denom) @@ -2607,7 +2607,7 @@ Returns: (array of bin counts, bin-minimum, min-width, #-points-outside-range) """ inarray = N.ravel(inarray) # flatten any >1D arrays - if (defaultlimits <> None): + if (defaultlimits != None): lowerreallimit = defaultlimits[0] upperreallimit = defaultlimits[1] binsize = (upperreallimit-lowerreallimit) / float(numbins) @@ -2697,8 +2697,8 @@ for j in range(k): if v[j] - mean(nargs[j]) > TINY: check = 0 - if check <> 1: - raise ValueError, 'Lack of convergence in obrientransform.' + if check != 1: + raise ValueError('Lack of convergence in obrientransform.') else: return N.array(nargs) @@ -2721,7 +2721,7 @@ else: mn = amean(inarray,dimension,keepdims=1) deviations = inarray - mn - if type(dimension) == ListType: + if type(dimension) == list: n = 1 for d in dimension: n = n*inarray.shape[d] @@ -2777,7 +2777,7 @@ xdeviations = x - xmn ymn = amean(y,dimension,1) # keepdims ydeviations = y - ymn - if type(dimension) == ListType: + if type(dimension) == list: n = 1 for d in dimension: n = n*x.shape[d] @@ -2802,7 +2802,7 @@ dimension = 0 mn = amean(inarray,dimension,1) deviations = inarray - mn - if type(dimension) == ListType: + if type(dimension) == list: n = 1 for d in dimension: n = n*inarray.shape[d] @@ -2854,7 +2854,7 @@ if dimension == None: inarray = N.ravel(inarray) dimension = 0 - if type(dimension) == ListType: + if type(dimension) == list: n = 1 for d in dimension: n = n*inarray.shape[d] @@ -2917,9 +2917,9 @@ Returns: a, with values threshmax replaced with newval """ mask = N.zeros(a.shape) - if threshmin <> None: + if threshmin != None: mask = mask + N.where(a None: + if threshmax != None: mask = mask + N.where(a>threshmax,1,0) mask = N.clip(mask,0,1) return N.where(mask,newval,a) @@ -2972,8 +2972,8 @@ Usage: acovariance(X) Returns: covariance matrix of X """ - if len(X.shape) <> 2: - raise TypeError, "acovariance requires 2D matrices" + if len(X.shape) != 2: + raise TypeError("acovariance requires 2D matrices") n = X.shape[0] mX = amean(X,0) return N.dot(N.transpose(X),X) / float(n) - N.multiply.outer(mX,mX) @@ -3169,8 +3169,8 @@ TINY = 1e-30 categories = pstat.aunique(x) data = pstat.aabut(x,y) - if len(categories) <> 2: - raise ValueError, "Exactly 2 categories required (in x) for pointbiserialr()." + if len(categories) != 2: + raise ValueError("Exactly 2 categories required (in x) for pointbiserialr().") else: # there are 2 categories, continue codemap = pstat.aabut(categories,N.arange(2)) recoded = pstat.arecode(data,codemap,0) @@ -3328,7 +3328,7 @@ t = (x-popmean)/math.sqrt(svar*(1.0/n)) prob = abetai(0.5*df,0.5,df/(df+t*t)) - if printit <> 0: + if printit != 0: statname = 'Single-sample T-test.' outputpairedstats(printit,writemode, 'Population','--',popmean,0,0,0, @@ -3374,7 +3374,7 @@ if probs.shape == (1,): probs = probs[0] - if printit <> 0: + if printit != 0: if type(t) == N.ndarray: t = t[0] if type(probs) == N.ndarray: @@ -3436,8 +3436,8 @@ a = N.ravel(a) b = N.ravel(b) dimension = 0 - if len(a)<>len(b): - raise ValueError, 'Unequal length arrays.' + if len(a)!=len(b): + raise ValueError('Unequal length arrays.') x1 = amean(a,dimension) x2 = amean(b,dimension) v1 = avar(a,dimension) @@ -3457,7 +3457,7 @@ if probs.shape == (1,): probs = probs[0] - if printit <> 0: + if printit != 0: statname = 'Related samples T-test.' outputpairedstats(printit,writemode, name1,n,x1,v1,N.minimum.reduce(N.ravel(a)), @@ -3550,7 +3550,7 @@ smallu = min(u1,u2) T = math.sqrt(tiecorrect(ranked)) # correction factor for tied scores if T == 0: - raise ValueError, 'All numbers are identical in amannwhitneyu' + raise ValueError('All numbers are identical in amannwhitneyu') sd = math.sqrt(T*n1*n2*(n1+n2+1)/12.0) z = abs((bigu-n1*n2/2.0) / sd) # normal approximation for prob calc return smallu, 1.0 - azprob(z) @@ -3611,8 +3611,8 @@ Usage: awilcoxont(x,y) where x,y are equal-length arrays for 2 conditions Returns: t-statistic, two-tailed p-value """ - if len(x) <> len(y): - raise ValueError, 'Unequal N in awilcoxont. Aborting.' + if len(x) != len(y): + raise ValueError('Unequal N in awilcoxont. Aborting.') d = x-y d = N.compress(N.not_equal(d,0),d) # Keep all non-zero differences count = len(d) @@ -3665,7 +3665,7 @@ h = 12.0 / (totaln*(totaln+1)) * ssbn - 3*(totaln+1) df = len(args) - 1 if T == 0: - raise ValueError, 'All numbers are identical in akruskalwallish' + raise ValueError('All numbers are identical in akruskalwallish') h = h / float(T) return h, chisqprob(h,df) @@ -3684,7 +3684,7 @@ """ k = len(args) if k < 3: - raise ValueError, '\nLess than 3 levels. Friedman test not appropriate.\n' + raise ValueError('\nLess than 3 levels. Friedman test not appropriate.\n') n = len(args[0]) data = apply(pstat.aabut,args) data = data.astype(N.float_) @@ -3748,7 +3748,7 @@ a_big = N.greater(a,BIG) a_big_frozen = -1 *N.ones(probs.shape,N.float_) totalelements = N.multiply.reduce(N.array(probs.shape)) - while asum(mask)<>totalelements: + while asum(mask)!=totalelements: e = N.log(z) + e s = s + ex(c*z-a-e) z = z + 1.0 @@ -3765,7 +3765,7 @@ c = 0.0 mask = N.zeros(probs.shape) a_notbig_frozen = -1 *N.ones(probs.shape,N.float_) - while asum(mask)<>totalelements: + while asum(mask)!=totalelements: e = e * (a/z.astype(N.float_)) c = c + e z = z + 1.0 @@ -3934,7 +3934,7 @@ frozen = N.where(newmask*N.equal(mask,0), az, frozen) mask = N.clip(mask+newmask,0,1) noconverge = asum(N.equal(frozen,-1)) - if noconverge <> 0 and verbose: + if noconverge != 0 and verbose: print 'a or b too big, or ITMAX too small in Betacf for ',noconverge,' elements' if arrayflag: return frozen @@ -3978,8 +3978,8 @@ """ TINY = 1e-15 if type(a) == N.ndarray: - if asum(N.less(x,0)+N.greater(x,1)) <> 0: - raise ValueError, 'Bad x in abetai' + if asum(N.less(x,0)+N.greater(x,1)) != 0: + raise ValueError('Bad x in abetai') x = N.where(N.equal(x,0),TINY,x) x = N.where(N.equal(x,1.0),1-TINY,x) @@ -4019,7 +4019,7 @@ Usage: aglm(data,para) Returns: statistic, p-value ??? """ - if len(para) <> len(data): + if len(para) != len(data): print "data and para must be same length in aglm" return n = len(para) @@ -4115,9 +4115,9 @@ dfF = degrees of freedom associated with the Restricted model where ER and EF are matrices from a multivariate F calculation. """ - if type(ER) in [IntType, FloatType]: + if type(ER) in [int, float]: ER = N.array([[ER]]) - if type(EF) in [IntType, FloatType]: + if type(EF) in [int, float]: EF = N.array([[EF]]) n_um = (LA.det(ER) - LA.det(EF)) / float(dfnum) d_en = LA.det(EF) / float(dfden) @@ -4157,7 +4157,7 @@ a = a.astype(N.float_) if dimension == None: s = N.sum(N.ravel(a)) - elif type(dimension) in [IntType,FloatType]: + elif type(dimension) in [int,float]: s = N.add.reduce(a, dimension) if keepdims == 1: shp = list(a.shape) @@ -4190,7 +4190,7 @@ if dimension == None: a = N.ravel(a) dimension = 0 - if type(dimension) in [ListType, TupleType, N.ndarray]: + if type(dimension) in [list, tuple, N.ndarray]: dimension = list(dimension) dimension.sort() dimension.reverse() @@ -4316,7 +4316,7 @@ for i in range(n): sumranks = sumranks + i dupcount = dupcount + 1 - if i==n-1 or svec[i] <> svec[i+1]: + if i==n-1 or svec[i] != svec[i+1]: averank = sumranks / float(dupcount) + 1 for j in range(i-dupcount+1,i+1): newarray[ivec[j]] = averank @@ -4349,17 +4349,17 @@ ######################################################### ## CENTRAL TENDENCY: - geometricmean = Dispatch ( (lgeometricmean, (ListType, TupleType)), + geometricmean = Dispatch ( (lgeometricmean, (list, tuple)), (ageometricmean, (N.ndarray,)) ) - harmonicmean = Dispatch ( (lharmonicmean, (ListType, TupleType)), + harmonicmean = Dispatch ( (lharmonicmean, (list, tuple)), (aharmonicmean, (N.ndarray,)) ) - mean = Dispatch ( (lmean, (ListType, TupleType)), + mean = Dispatch ( (lmean, (list, tuple)), (amean, (N.ndarray,)) ) - median = Dispatch ( (lmedian, (ListType, TupleType)), + median = Dispatch ( (lmedian, (list, tuple)), (amedian, (N.ndarray,)) ) - medianscore = Dispatch ( (lmedianscore, (ListType, TupleType)), + medianscore = Dispatch ( (lmedianscore, (list, tuple)), (amedianscore, (N.ndarray,)) ) - mode = Dispatch ( (lmode, (ListType, TupleType)), + mode = Dispatch ( (lmode, (list, tuple)), (amode, (N.ndarray,)) ) tmean = Dispatch ( (atmean, (N.ndarray,)) ) tvar = Dispatch ( (atvar, (N.ndarray,)) ) @@ -4367,151 +4367,151 @@ tsem = Dispatch ( (atsem, (N.ndarray,)) ) ## VARIATION: - moment = Dispatch ( (lmoment, (ListType, TupleType)), + moment = Dispatch ( (lmoment, (list, tuple)), (amoment, (N.ndarray,)) ) - variation = Dispatch ( (lvariation, (ListType, TupleType)), + variation = Dispatch ( (lvariation, (list, tuple)), (avariation, (N.ndarray,)) ) - skew = Dispatch ( (lskew, (ListType, TupleType)), + skew = Dispatch ( (lskew, (list, tuple)), (askew, (N.ndarray,)) ) - kurtosis = Dispatch ( (lkurtosis, (ListType, TupleType)), + kurtosis = Dispatch ( (lkurtosis, (list, tuple)), (akurtosis, (N.ndarray,)) ) - describe = Dispatch ( (ldescribe, (ListType, TupleType)), + describe = Dispatch ( (ldescribe, (list, tuple)), (adescribe, (N.ndarray,)) ) ## DISTRIBUTION TESTS - skewtest = Dispatch ( (askewtest, (ListType, TupleType)), + skewtest = Dispatch ( (askewtest, (list, tuple)), (askewtest, (N.ndarray,)) ) - kurtosistest = Dispatch ( (akurtosistest, (ListType, TupleType)), + kurtosistest = Dispatch ( (akurtosistest, (list, tuple)), (akurtosistest, (N.ndarray,)) ) - normaltest = Dispatch ( (anormaltest, (ListType, TupleType)), + normaltest = Dispatch ( (anormaltest, (list, tuple)), (anormaltest, (N.ndarray,)) ) ## FREQUENCY STATS: - itemfreq = Dispatch ( (litemfreq, (ListType, TupleType)), + itemfreq = Dispatch ( (litemfreq, (list, tuple)), (aitemfreq, (N.ndarray,)) ) - scoreatpercentile = Dispatch ( (lscoreatpercentile, (ListType, TupleType)), + scoreatpercentile = Dispatch ( (lscoreatpercentile, (list, tuple)), (ascoreatpercentile, (N.ndarray,)) ) - percentileofscore = Dispatch ( (lpercentileofscore, (ListType, TupleType)), + percentileofscore = Dispatch ( (lpercentileofscore, (list, tuple)), (apercentileofscore, (N.ndarray,)) ) - histogram = Dispatch ( (lhistogram, (ListType, TupleType)), + histogram = Dispatch ( (lhistogram, (list, tuple)), (ahistogram, (N.ndarray,)) ) - cumfreq = Dispatch ( (lcumfreq, (ListType, TupleType)), + cumfreq = Dispatch ( (lcumfreq, (list, tuple)), (acumfreq, (N.ndarray,)) ) - relfreq = Dispatch ( (lrelfreq, (ListType, TupleType)), + relfreq = Dispatch ( (lrelfreq, (list, tuple)), (arelfreq, (N.ndarray,)) ) ## VARIABILITY: - obrientransform = Dispatch ( (lobrientransform, (ListType, TupleType)), + obrientransform = Dispatch ( (lobrientransform, (list, tuple)), (aobrientransform, (N.ndarray,)) ) - samplevar = Dispatch ( (lsamplevar, (ListType, TupleType)), + samplevar = Dispatch ( (lsamplevar, (list, tuple)), (asamplevar, (N.ndarray,)) ) - samplestdev = Dispatch ( (lsamplestdev, (ListType, TupleType)), + samplestdev = Dispatch ( (lsamplestdev, (list, tuple)), (asamplestdev, (N.ndarray,)) ) signaltonoise = Dispatch( (asignaltonoise, (N.ndarray,)),) - var = Dispatch ( (lvar, (ListType, TupleType)), + var = Dispatch ( (lvar, (list, tuple)), (avar, (N.ndarray,)) ) - stdev = Dispatch ( (lstdev, (ListType, TupleType)), + stdev = Dispatch ( (lstdev, (list, tuple)), (astdev, (N.ndarray,)) ) - sterr = Dispatch ( (lsterr, (ListType, TupleType)), + sterr = Dispatch ( (lsterr, (list, tuple)), (asterr, (N.ndarray,)) ) - sem = Dispatch ( (lsem, (ListType, TupleType)), + sem = Dispatch ( (lsem, (list, tuple)), (asem, (N.ndarray,)) ) - z = Dispatch ( (lz, (ListType, TupleType)), + z = Dispatch ( (lz, (list, tuple)), (az, (N.ndarray,)) ) - zs = Dispatch ( (lzs, (ListType, TupleType)), + zs = Dispatch ( (lzs, (list, tuple)), (azs, (N.ndarray,)) ) ## TRIMMING FCNS: threshold = Dispatch( (athreshold, (N.ndarray,)),) - trimboth = Dispatch ( (ltrimboth, (ListType, TupleType)), + trimboth = Dispatch ( (ltrimboth, (list, tuple)), (atrimboth, (N.ndarray,)) ) - trim1 = Dispatch ( (ltrim1, (ListType, TupleType)), + trim1 = Dispatch ( (ltrim1, (list, tuple)), (atrim1, (N.ndarray,)) ) ## CORRELATION FCNS: - paired = Dispatch ( (lpaired, (ListType, TupleType)), + paired = Dispatch ( (lpaired, (list, tuple)), (apaired, (N.ndarray,)) ) - lincc = Dispatch ( (llincc, (ListType, TupleType)), + lincc = Dispatch ( (llincc, (list, tuple)), (alincc, (N.ndarray,)) ) - pearsonr = Dispatch ( (lpearsonr, (ListType, TupleType)), + pearsonr = Dispatch ( (lpearsonr, (list, tuple)), (apearsonr, (N.ndarray,)) ) - spearmanr = Dispatch ( (lspearmanr, (ListType, TupleType)), + spearmanr = Dispatch ( (lspearmanr, (list, tuple)), (aspearmanr, (N.ndarray,)) ) - pointbiserialr = Dispatch ( (lpointbiserialr, (ListType, TupleType)), + pointbiserialr = Dispatch ( (lpointbiserialr, (list, tuple)), (apointbiserialr, (N.ndarray,)) ) - kendalltau = Dispatch ( (lkendalltau, (ListType, TupleType)), + kendalltau = Dispatch ( (lkendalltau, (list, tuple)), (akendalltau, (N.ndarray,)) ) - linregress = Dispatch ( (llinregress, (ListType, TupleType)), + linregress = Dispatch ( (llinregress, (list, tuple)), (alinregress, (N.ndarray,)) ) ## INFERENTIAL STATS: - ttest_1samp = Dispatch ( (lttest_1samp, (ListType, TupleType)), + ttest_1samp = Dispatch ( (lttest_1samp, (list, tuple)), (attest_1samp, (N.ndarray,)) ) - ttest_ind = Dispatch ( (lttest_ind, (ListType, TupleType)), + ttest_ind = Dispatch ( (lttest_ind, (list, tuple)), (attest_ind, (N.ndarray,)) ) - ttest_rel = Dispatch ( (lttest_rel, (ListType, TupleType)), + ttest_rel = Dispatch ( (lttest_rel, (list, tuple)), (attest_rel, (N.ndarray,)) ) - chisquare = Dispatch ( (lchisquare, (ListType, TupleType)), + chisquare = Dispatch ( (lchisquare, (list, tuple)), (achisquare, (N.ndarray,)) ) - ks_2samp = Dispatch ( (lks_2samp, (ListType, TupleType)), + ks_2samp = Dispatch ( (lks_2samp, (list, tuple)), (aks_2samp, (N.ndarray,)) ) - mannwhitneyu = Dispatch ( (lmannwhitneyu, (ListType, TupleType)), + mannwhitneyu = Dispatch ( (lmannwhitneyu, (list, tuple)), (amannwhitneyu, (N.ndarray,)) ) - tiecorrect = Dispatch ( (ltiecorrect, (ListType, TupleType)), + tiecorrect = Dispatch ( (ltiecorrect, (list, tuple)), (atiecorrect, (N.ndarray,)) ) - ranksums = Dispatch ( (lranksums, (ListType, TupleType)), + ranksums = Dispatch ( (lranksums, (list, tuple)), (aranksums, (N.ndarray,)) ) - wilcoxont = Dispatch ( (lwilcoxont, (ListType, TupleType)), + wilcoxont = Dispatch ( (lwilcoxont, (list, tuple)), (awilcoxont, (N.ndarray,)) ) - kruskalwallish = Dispatch ( (lkruskalwallish, (ListType, TupleType)), + kruskalwallish = Dispatch ( (lkruskalwallish, (list, tuple)), (akruskalwallish, (N.ndarray,)) ) - friedmanchisquare = Dispatch ( (lfriedmanchisquare, (ListType, TupleType)), + friedmanchisquare = Dispatch ( (lfriedmanchisquare, (list, tuple)), (afriedmanchisquare, (N.ndarray,)) ) ## PROBABILITY CALCS: - chisqprob = Dispatch ( (lchisqprob, (IntType, FloatType)), + chisqprob = Dispatch ( (lchisqprob, (int, float)), (achisqprob, (N.ndarray,)) ) - zprob = Dispatch ( (lzprob, (IntType, FloatType)), + zprob = Dispatch ( (lzprob, (int, float)), (azprob, (N.ndarray,)) ) - ksprob = Dispatch ( (lksprob, (IntType, FloatType)), + ksprob = Dispatch ( (lksprob, (int, float)), (aksprob, (N.ndarray,)) ) - fprob = Dispatch ( (lfprob, (IntType, FloatType)), + fprob = Dispatch ( (lfprob, (int, float)), (afprob, (N.ndarray,)) ) - betacf = Dispatch ( (lbetacf, (IntType, FloatType)), + betacf = Dispatch ( (lbetacf, (int, float)), (abetacf, (N.ndarray,)) ) - betai = Dispatch ( (lbetai, (IntType, FloatType)), + betai = Dispatch ( (lbetai, (int, float)), (abetai, (N.ndarray,)) ) - erfcc = Dispatch ( (lerfcc, (IntType, FloatType)), + erfcc = Dispatch ( (lerfcc, (int, float)), (aerfcc, (N.ndarray,)) ) - gammln = Dispatch ( (lgammln, (IntType, FloatType)), + gammln = Dispatch ( (lgammln, (int, float)), (agammln, (N.ndarray,)) ) ## ANOVA FUNCTIONS: - F_oneway = Dispatch ( (lF_oneway, (ListType, TupleType)), + F_oneway = Dispatch ( (lF_oneway, (list, tuple)), (aF_oneway, (N.ndarray,)) ) - F_value = Dispatch ( (lF_value, (ListType, TupleType)), + F_value = Dispatch ( (lF_value, (list, tuple)), (aF_value, (N.ndarray,)) ) ## SUPPORT FUNCTIONS: - incr = Dispatch ( (lincr, (ListType, TupleType, N.ndarray)), ) - sum = Dispatch ( (lsum, (ListType, TupleType)), + incr = Dispatch ( (lincr, (list, tuple, N.ndarray)), ) + sum = Dispatch ( (lsum, (list, tuple)), (asum, (N.ndarray,)) ) - cumsum = Dispatch ( (lcumsum, (ListType, TupleType)), + cumsum = Dispatch ( (lcumsum, (list, tuple)), (acumsum, (N.ndarray,)) ) - ss = Dispatch ( (lss, (ListType, TupleType)), + ss = Dispatch ( (lss, (list, tuple)), (ass, (N.ndarray,)) ) - summult = Dispatch ( (lsummult, (ListType, TupleType)), + summult = Dispatch ( (lsummult, (list, tuple)), (asummult, (N.ndarray,)) ) - square_of_sums = Dispatch ( (lsquare_of_sums, (ListType, TupleType)), + square_of_sums = Dispatch ( (lsquare_of_sums, (list, tuple)), (asquare_of_sums, (N.ndarray,)) ) - sumdiffsquared = Dispatch ( (lsumdiffsquared, (ListType, TupleType)), + sumdiffsquared = Dispatch ( (lsumdiffsquared, (list, tuple)), (asumdiffsquared, (N.ndarray,)) ) - shellsort = Dispatch ( (lshellsort, (ListType, TupleType)), + shellsort = Dispatch ( (lshellsort, (list, tuple)), (ashellsort, (N.ndarray,)) ) - rankdata = Dispatch ( (lrankdata, (ListType, TupleType)), + rankdata = Dispatch ( (lrankdata, (list, tuple)), (arankdata, (N.ndarray,)) ) - findwithin = Dispatch ( (lfindwithin, (ListType, TupleType)), + findwithin = Dispatch ( (lfindwithin, (list, tuple)), (afindwithin, (N.ndarray,)) ) ###################### END OF NUMERIC FUNCTION BLOCK ##################### Index: lnt/server/reporting/runs.py =================================================================== --- lnt/server/reporting/runs.py +++ lnt/server/reporting/runs.py @@ -123,7 +123,7 @@ if not bucket or bucket_name == 'Unchanged Test' or not show_perf: return bucket else: - return sorted(bucket, key=lambda (_, cr, __): -abs(cr.pct_delta)) + return sorted(bucket, key=(lambda _, cr, __: -abs(cr.pct_delta))) def prioritize_buckets(test_results): prioritized = [(priority, field, bucket_name, Index: lnt/server/ui/views.py =================================================================== --- lnt/server/ui/views.py +++ lnt/server/ui/views.py @@ -830,7 +830,7 @@ graph_parameters.append((machine, test, field, field_index)) # Order the plots by machine name, test name and then field. - graph_parameters.sort(key=lambda (m, t, f, _): (m.name, t.name, f.name, _)) + graph_parameters.sort(key=(lambda m, t, f, _: (m.name, t.name, f.name, _))) # Extract requested mean trend. mean_parameter = None