llvm.org GIT mirror lnt / 1497cdd
Subject: [LNT] Python 3 support: Update type comparisons and type names Summary: This patch is split out from D67535, updating type names (or, in one case, `type(1.4)`-style goodness) and updating type comparisons with use of `isinstance`. Additionally, changed a dictionary key lookup for a type mapping. As requested by reviewers in D67535, spaces are added after commas in what are now tuples of types. Reviewers: cmatthews, thopre, kristof.beyls Reviewed By: thopre Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D67587 git-svn-id: https://llvm.org/svn/llvm-project/lnt/trunk@371944 91177308-0d34-0410-b5e6-96231b3b80d8 Hubert Tong a month ago
6 changed file(s) with 216 addition(s) and 217 deletion(s). Raw diff Collapse all Expand all
130130 'left', lists in attached consecutively on the 'right'
131131 """
132132
133 if type(source) not in [ListType,TupleType]:
133 if not isinstance(source, (list, tuple)):
134134 source = [source]
135135 for addon in args:
136 if type(addon) not in [ListType,TupleType]:
136 if not isinstance(addon, (list, tuple)):
137137 addon = [addon]
138138 if len(addon) < len(source): # is source list longer?
139139 if len(source) % len(addon) == 0: # are they integer multiples?
176176 Returns: a list of lists as long as source, with source on the 'left' and
177177 addon on the 'right'
178178 """
179 if type(source) not in [ListType,TupleType]:
179 if not isinstance(source, (list, tuple)):
180180 source = [source]
181 if type(addon) not in [ListType,TupleType]:
181 if not isinstance(addon, (list, tuple)):
182182 addon = [addon]
183183 minlen = min(len(source),len(addon))
184184 list = copy.deepcopy(source) # start abut process
185 if type(source[0]) not in [ListType,TupleType]:
186 if type(addon[0]) not in [ListType,TupleType]:
185 if not isinstance(source[0], (list, tuple)):
186 if not isinstance(addon[0], (list, tuple)):
187187 for i in range(minlen):
188188 list[i] = [source[i]] + [addon[i]] # source/addon = column
189189 else:
190190 for i in range(minlen):
191191 list[i] = [source[i]] + addon[i] # addon=list-of-lists
192192 else:
193 if type(addon[0]) not in [ListType,TupleType]:
193 if not isinstance(addon[0], (list, tuple)):
194194 for i in range(minlen):
195195 list[i] = source[i] + [addon[i]] # source=list-of-lists
196196 else:
213213 """
214214 global index
215215 column = 0
216 if type(cnums) in [ListType,TupleType]: # if multiple columns to get
216 if isinstance(cnums, (list, tuple)): # if multiple columns to get
217217 index = cnums[0]
218218 column = map(lambda x: x[index], listoflists)
219219 for col in cnums[1:]:
220220 index = col
221221 column = abut(column,map(lambda x: x[index], listoflists))
222 elif type(cnums) == StringType: # if an 'x[3:]' type expr.
222 elif isinstance(cnums, str): # if an 'x[3:]' type expr.
223223 evalstring = 'map(lambda x: x'+cnums+', listoflists)'
224224 column = eval(evalstring)
225225 else: # else it's just 1 col to get
251251 s = s + item
252252 return s/float(len(inlist))
253253
254 if type(keepcols) not in [ListType,TupleType]:
254 if not isinstance(keepcols, (list, tuple)):
255255 keepcols = [keepcols]
256 if type(collapsecols) not in [ListType,TupleType]:
256 if not isinstance(collapsecols, (list, tuple)):
257257 collapsecols = [collapsecols]
258258 if cfcn == None:
259259 cfcn = collmean
283283 uniques = unique(values)
284284 uniques.sort()
285285 newlist = []
286 if type(keepcols) not in [ListType,TupleType]: keepcols = [keepcols]
286 if not isinstance(keepcols, (list, tuple)): keepcols = [keepcols]
287287 for item in uniques:
288 if type(item) not in [ListType,TupleType]: item =[item]
288 if not isinstance(item, (list, tuple)): item =[item]
289289 tmprows = linexand(listoflists,keepcols,item)
290290 for col in collapsecols:
291291 avgcol = colex(tmprows,col)
344344 Usage: linexand (listoflists,columnlist,valuelist)
345345 Returns: the rows of listoflists where columnlist[i]=valuelist[i] for ALL i
346346 """
347 if type(columnlist) not in [ListType,TupleType]:
347 if not isinstance(columnlist, (list, tuple)):
348348 columnlist = [columnlist]
349 if type(valuelist) not in [ListType,TupleType]:
349 if not isinstance(valuelist, (list, tuple)):
350350 valuelist = [valuelist]
351351 criterion = ''
352352 for i in range(len(columnlist)):
353 if type(valuelist[i])==StringType:
353 if isinstance(valuelist[i], str):
354354 critval = '\'' + valuelist[i] + '\''
355355 else:
356356 critval = str(valuelist[i])
372372 Usage: linexor (listoflists,columnlist,valuelist)
373373 Returns: the rows of listoflists where columnlist[i]=valuelist[i] for ANY i
374374 """
375 if type(columnlist) not in [ListType,TupleType]:
375 if not isinstance(columnlist, (list, tuple)):
376376 columnlist = [columnlist]
377 if type(valuelist) not in [ListType,TupleType]:
377 if not isinstance(valuelist, (list, tuple)):
378378 valuelist = [valuelist]
379379 criterion = ''
380380 if len(columnlist) == 1 and len(valuelist) > 1:
381381 columnlist = columnlist*len(valuelist)
382382 for i in range(len(columnlist)): # build an exec string
383 if type(valuelist[i])==StringType:
383 if isinstance(valuelist[i], str):
384384 critval = '\'' + valuelist[i] + '\''
385385 else:
386386 critval = str(valuelist[i])
401401 """
402402 outstr = ''
403403 for item in inlist:
404 if type(item) <> StringType:
404 if not isinstance(item, str):
405405 item = str(item)
406406 outstr = outstr + item + delimiter
407407 outstr = outstr[0:-1]
417417 """
418418 outstr = ''
419419 for item in inlist:
420 if type(item) <> StringType:
420 if not isinstance(item, str):
421421 item = str(item)
422422 size = len(item)
423423 if size <= colsize:
441441 """
442442 outstr = ''
443443 for i in range(len(inlist)):
444 if type(inlist[i]) <> StringType:
444 if not isinstance(inlist[i], str):
445445 item = str(inlist[i])
446446 else:
447447 item = inlist[i]
482482
483483
484484 def makestr (x):
485 if type(x) <> StringType:
485 if not isinstance(x, str):
486486 x = str(x)
487487 return x
488488
497497 Usage: printcc (lst,extra=2)
498498 Returns: None
499499 """
500 if type(lst[0]) not in [ListType,TupleType]:
500 if not isinstance(lst[0], (list, tuple)):
501501 lst = [lst]
502502 rowstokill = []
503503 list2print = copy.deepcopy(lst)
567567 """
568568 lst = inlst*1
569569 for i in range(len(lst)):
570 if type(lst[i]) not in [ListType,TupleType]:
570 if not isinstance(lst[i], (list, tuple)):
571571 if lst[i]==oldval: lst[i]=newval
572572 else:
573573 lst[i] = replace(lst[i],oldval,newval)
585585 """
586586 lst = copy.deepcopy(inlist)
587587 if cols != None:
588 if type(cols) not in [ListType,TupleType]:
588 if not isinstance(cols, (list, tuple)):
589589 cols = [cols]
590590 for col in cols:
591591 for row in range(len(lst)):
622622 def roundlist (inlist,digits):
623623 """
624624 Goes through each element in a 1D or 2D inlist, and applies the following
625 function to all elements of FloatType ... round(element,digits).
625 function to all elements of float ... round(element,digits).
626626
627627 Usage: roundlist(inlist,digits)
628628 Returns: list with rounded floats
629629 """
630 if type(inlist[0]) in [IntType, FloatType]:
630 if isinstance(inlist[0], (int, float)):
631631 inlist = [inlist]
632632 l = inlist*1
633633 for i in range(len(l)):
634634 for j in range(len(l[i])):
635 if type(l[i][j])==FloatType:
635 if isinstance(l[i][j], float):
636636 l[i][j] = round(l[i][j],digits)
637637 return l
638638
755755 Usage: acolex (a,indices,axis=1)
756756 Returns: the columns of a specified by indices
757757 """
758 if type(indices) not in [ListType,TupleType,N.ndarray]:
758 if not isinstance(indices, (list, tuple, N.ndarray)):
759759 indices = [indices]
760760 if len(N.shape(a)) == 1:
761761 cols = N.resize(a,[a.shape[0],1])
779779 def acollmean (inarray):
780780 return N.sum(N.ravel(inarray))
781781
782 if type(keepcols) not in [ListType,TupleType,N.ndarray]:
782 if not isinstance(keepcols, (list, tuple, N.ndarray)):
783783 keepcols = [keepcols]
784 if type(collapsecols) not in [ListType,TupleType,N.ndarray]:
784 if not isinstance(collapsecols, (list, tuple, N.ndarray)):
785785 collapsecols = [collapsecols]
786786
787787 if cfcn == None:
803803 means = aabut(means,test)
804804 return means
805805 else:
806 if type(keepcols) not in [ListType,TupleType,N.ndarray]:
806 if not isinstance(keepcols, (list, tuple, N.ndarray)):
807807 keepcols = [keepcols]
808808 values = colex(a,keepcols) # so that "item" can be appended (below)
809809 uniques = unique(values) # get a LIST, so .sort keeps rows intact
810810 uniques.sort()
811811 newlist = []
812812 for item in uniques:
813 if type(item) not in [ListType,TupleType,N.ndarray]:
813 if not isinstance(item, (list, tuple, N.ndarray)):
814814 item =[item]
815815 tmprows = alinexand(a,keepcols,item)
816816 for col in collapsecols:
853853
854854
855855 def isstring(x):
856 if type(x)==StringType:
856 if isinstance(x, str):
857857 return 1
858858 else:
859859 return 0
867867 Usage: alinexand (a,columnlist,valuelist)
868868 Returns: the rows of a where columnlist[i]=valuelist[i] for ALL i
869869 """
870 if type(columnlist) not in [ListType,TupleType,N.ndarray]:
870 if not isinstance(columnlist, (list, tuple, N.ndarray)):
871871 columnlist = [columnlist]
872 if type(valuelist) not in [ListType,TupleType,N.ndarray]:
872 if not isinstance(valuelist, (list, tuple, N.ndarray)):
873873 valuelist = [valuelist]
874874 criterion = ''
875875 for i in range(len(columnlist)):
876 if type(valuelist[i])==StringType:
876 if isinstance(valuelist[i], str):
877877 critval = '\'' + valuelist[i] + '\''
878878 else:
879879 critval = str(valuelist[i])
893893 Usage: alinexor (a,columnlist,valuelist)
894894 Returns: the rows of a where columnlist[i]=valuelist[i] for ANY i
895895 """
896 if type(columnlist) not in [ListType,TupleType,N.ndarray]:
896 if not isinstance(columnlist, (list, tuple, N.ndarray)):
897897 columnlist = [columnlist]
898 if type(valuelist) not in [ListType,TupleType,N.ndarray]:
898 if not isinstance(valuelist, (list, tuple, N.ndarray)):
899899 valuelist = [valuelist]
900900 criterion = ''
901901 if len(columnlist) == 1 and len(valuelist) > 1:
903903 elif len(valuelist) == 1 and len(columnlist) > 1:
904904 valuelist = valuelist*len(columnlist)
905905 for i in range(len(columnlist)):
906 if type(valuelist[i])==StringType:
906 if isinstance(valuelist[i], str):
907907 critval = '\'' + valuelist[i] + '\''
908908 else:
909909 critval = str(valuelist[i])
938938 work = acolex(a,col)
939939 work = work.ravel()
940940 for pair in listmap:
941 if type(pair[1]) == StringType or work.dtype.char=='O' or a.dtype.char=='O':
941 if isinstance(pair[1], str) or work.dtype.char == 'O' or a.dtype.char == 'O':
942942 work = N.array(work,dtype='O')
943943 a = N.array(a,dtype='O')
944944 for i in range(len(work)):
245245 self._dispatch = {}
246246 for func, types in tuples:
247247 for t in types:
248 if t in self._dispatch.keys():
248 if t in self._dispatch:
249249 raise ValueError, "can't have two dispatches on "+str(t)
250250 self._dispatch[t] = func
251 self._types = self._dispatch.keys()
252251
253252 def __call__(self, arg1, *args, **kw):
254 if type(arg1) not in self._types:
253 if type(arg1) not in self._dispatch:
255254 raise TypeError, "don't know how to dispatch %s arguments" % type(arg1)
256255 return apply(self._dispatch[type(arg1)], (arg1,) + args, kw)
257256
512511 Returns: list of bin values, lowerreallimit, binsize, extrapoints
513512 """
514513 if (defaultreallimits <> None):
515 if type(defaultreallimits) not in [ListType,TupleType] or len(defaultreallimits)==1: # only one limit given, assumed to be lower one & upper is calc'd
514 if not isinstance(defaultreallimits, (list, tuple)) or len(defaultreallimits) == 1: # only one limit given, assumed to be lower one & upper is calc'd
516515 lowerreallimit = defaultreallimits
517516 upperreallimit = 1.000001 * max(inlist)
518517 else: # assume both limits given
16171616 Usage: writecc (listoflists,file,writetype='w',extra=2)
16181617 Returns: None
16191618 """
1620 if type(listoflists[0]) not in [ListType,TupleType]:
1619 if not isinstance(listoflists[0], (list, tuple)):
16211620 listoflists = [listoflists]
16221621 outfile = open(file,writetype)
16231622 rowstokill = []
18201819 title = [['Name','N','Mean','SD','Min','Max']]
18211820 lofl = title+[[name1,n1,round(m1,3),round(math.sqrt(se1),3),min1,max1],
18221821 [name2,n2,round(m2,3),round(math.sqrt(se2),3),min2,max2]]
1823 if type(fname)<>StringType or len(fname)==0:
1822 if not isinstance(fname, str) or len(fname) == 0:
18241823 print()
18251824 print(statname)
18261825 print()
18851884 #########################################################
18861885
18871886 ## CENTRAL TENDENCY:
1888 geometricmean = Dispatch ( (lgeometricmean, (ListType, TupleType)), )
1889 harmonicmean = Dispatch ( (lharmonicmean, (ListType, TupleType)), )
1890 mean = Dispatch ( (lmean, (ListType, TupleType)), )
1891 median = Dispatch ( (lmedian, (ListType, TupleType)), )
1892 medianscore = Dispatch ( (lmedianscore, (ListType, TupleType)), )
1893 mode = Dispatch ( (lmode, (ListType, TupleType)), )
1887 geometricmean = Dispatch ( (lgeometricmean, (list, tuple)), )
1888 harmonicmean = Dispatch ( (lharmonicmean, (list, tuple)), )
1889 mean = Dispatch ( (lmean, (list, tuple)), )
1890 median = Dispatch ( (lmedian, (list, tuple)), )
1891 medianscore = Dispatch ( (lmedianscore, (list, tuple)), )
1892 mode = Dispatch ( (lmode, (list, tuple)), )
18941893
18951894 ## MOMENTS:
1896 moment = Dispatch ( (lmoment, (ListType, TupleType)), )
1897 variation = Dispatch ( (lvariation, (ListType, TupleType)), )
1898 skew = Dispatch ( (lskew, (ListType, TupleType)), )
1899 kurtosis = Dispatch ( (lkurtosis, (ListType, TupleType)), )
1900 describe = Dispatch ( (ldescribe, (ListType, TupleType)), )
1895 moment = Dispatch ( (lmoment, (list, tuple)), )
1896 variation = Dispatch ( (lvariation, (list, tuple)), )
1897 skew = Dispatch ( (lskew, (list, tuple)), )
1898 kurtosis = Dispatch ( (lkurtosis, (list, tuple)), )
1899 describe = Dispatch ( (ldescribe, (list, tuple)), )
19011900
19021901 ## FREQUENCY STATISTICS:
1903 itemfreq = Dispatch ( (litemfreq, (ListType, TupleType)), )
1904 scoreatpercentile = Dispatch ( (lscoreatpercentile, (ListType, TupleType)), )
1905 percentileofscore = Dispatch ( (lpercentileofscore, (ListType, TupleType)), )
1906 histogram = Dispatch ( (lhistogram, (ListType, TupleType)), )
1907 cumfreq = Dispatch ( (lcumfreq, (ListType, TupleType)), )
1908 relfreq = Dispatch ( (lrelfreq, (ListType, TupleType)), )
1902 itemfreq = Dispatch ( (litemfreq, (list, tuple)), )
1903 scoreatpercentile = Dispatch ( (lscoreatpercentile, (list, tuple)), )
1904 percentileofscore = Dispatch ( (lpercentileofscore, (list, tuple)), )
1905 histogram = Dispatch ( (lhistogram, (list, tuple)), )
1906 cumfreq = Dispatch ( (lcumfreq, (list, tuple)), )
1907 relfreq = Dispatch ( (lrelfreq, (list, tuple)), )
19091908
19101909 ## VARIABILITY:
1911 obrientransform = Dispatch ( (lobrientransform, (ListType, TupleType)), )
1912 samplevar = Dispatch ( (lsamplevar, (ListType, TupleType)), )
1913 samplestdev = Dispatch ( (lsamplestdev, (ListType, TupleType)), )
1914 var = Dispatch ( (lvar, (ListType, TupleType)), )
1915 stdev = Dispatch ( (lstdev, (ListType, TupleType)), )
1916 sterr = Dispatch ( (lsterr, (ListType, TupleType)), )
1917 sem = Dispatch ( (lsem, (ListType, TupleType)), )
1918 z = Dispatch ( (lz, (ListType, TupleType)), )
1919 zs = Dispatch ( (lzs, (ListType, TupleType)), )
1910 obrientransform = Dispatch ( (lobrientransform, (list, tuple)), )
1911 samplevar = Dispatch ( (lsamplevar, (list, tuple)), )
1912 samplestdev = Dispatch ( (lsamplestdev, (list, tuple)), )
1913 var = Dispatch ( (lvar, (list, tuple)), )
1914 stdev = Dispatch ( (lstdev, (list, tuple)), )
1915 sterr = Dispatch ( (lsterr, (list, tuple)), )
1916 sem = Dispatch ( (lsem, (list, tuple)), )
1917 z = Dispatch ( (lz, (list, tuple)), )
1918 zs = Dispatch ( (lzs, (list, tuple)), )
19201919
19211920 ## TRIMMING FCNS:
1922 trimboth = Dispatch ( (ltrimboth, (ListType, TupleType)), )
1923 trim1 = Dispatch ( (ltrim1, (ListType, TupleType)), )
1921 trimboth = Dispatch ( (ltrimboth, (list, tuple)), )
1922 trim1 = Dispatch ( (ltrim1, (list, tuple)), )
19241923
19251924 ## CORRELATION FCNS:
1926 paired = Dispatch ( (lpaired, (ListType, TupleType)), )
1927 pearsonr = Dispatch ( (lpearsonr, (ListType, TupleType)), )
1928 spearmanr = Dispatch ( (lspearmanr, (ListType, TupleType)), )
1929 pointbiserialr = Dispatch ( (lpointbiserialr, (ListType, TupleType)), )
1930 kendalltau = Dispatch ( (lkendalltau, (ListType, TupleType)), )
1931 linregress = Dispatch ( (llinregress, (ListType, TupleType)), )
1925 paired = Dispatch ( (lpaired, (list, tuple)), )
1926 pearsonr = Dispatch ( (lpearsonr, (list, tuple)), )
1927 spearmanr = Dispatch ( (lspearmanr, (list, tuple)), )
1928 pointbiserialr = Dispatch ( (lpointbiserialr, (list, tuple)), )
1929 kendalltau = Dispatch ( (lkendalltau, (list, tuple)), )
1930 linregress = Dispatch ( (llinregress, (list, tuple)), )
19321931
19331932 ## INFERENTIAL STATS:
1934 ttest_1samp = Dispatch ( (lttest_1samp, (ListType, TupleType)), )
1935 ttest_ind = Dispatch ( (lttest_ind, (ListType, TupleType)), )
1936 ttest_rel = Dispatch ( (lttest_rel, (ListType, TupleType)), )
1937 chisquare = Dispatch ( (lchisquare, (ListType, TupleType)), )
1938 ks_2samp = Dispatch ( (lks_2samp, (ListType, TupleType)), )
1939 mannwhitneyu = Dispatch ( (lmannwhitneyu, (ListType, TupleType)), )
1940 ranksums = Dispatch ( (lranksums, (ListType, TupleType)), )
1941 tiecorrect = Dispatch ( (ltiecorrect, (ListType, TupleType)), )
1942 wilcoxont = Dispatch ( (lwilcoxont, (ListType, TupleType)), )
1943 kruskalwallish = Dispatch ( (lkruskalwallish, (ListType, TupleType)), )
1944 friedmanchisquare = Dispatch ( (lfriedmanchisquare, (ListType, TupleType)), )
1933 ttest_1samp = Dispatch ( (lttest_1samp, (list, tuple)), )
1934 ttest_ind = Dispatch ( (lttest_ind, (list, tuple)), )
1935 ttest_rel = Dispatch ( (lttest_rel, (list, tuple)), )
1936 chisquare = Dispatch ( (lchisquare, (list, tuple)), )
1937 ks_2samp = Dispatch ( (lks_2samp, (list, tuple)), )
1938 mannwhitneyu = Dispatch ( (lmannwhitneyu, (list, tuple)), )
1939 ranksums = Dispatch ( (lranksums, (list, tuple)), )
1940 tiecorrect = Dispatch ( (ltiecorrect, (list, tuple)), )
1941 wilcoxont = Dispatch ( (lwilcoxont, (list, tuple)), )
1942 kruskalwallish = Dispatch ( (lkruskalwallish, (list, tuple)), )
1943 friedmanchisquare = Dispatch ( (lfriedmanchisquare, (list, tuple)), )
19451944
19461945 ## PROBABILITY CALCS:
1947 chisqprob = Dispatch ( (lchisqprob, (IntType, FloatType)), )
1948 zprob = Dispatch ( (lzprob, (IntType, FloatType)), )
1949 ksprob = Dispatch ( (lksprob, (IntType, FloatType)), )
1950 fprob = Dispatch ( (lfprob, (IntType, FloatType)), )
1951 betacf = Dispatch ( (lbetacf, (IntType, FloatType)), )
1952 betai = Dispatch ( (lbetai, (IntType, FloatType)), )
1953 erfcc = Dispatch ( (lerfcc, (IntType, FloatType)), )
1954 gammln = Dispatch ( (lgammln, (IntType, FloatType)), )
1946 chisqprob = Dispatch ( (lchisqprob, (int, float)), )
1947 zprob = Dispatch ( (lzprob, (int, float)), )
1948 ksprob = Dispatch ( (lksprob, (int, float)), )
1949 fprob = Dispatch ( (lfprob, (int, float)), )
1950 betacf = Dispatch ( (lbetacf, (int, float)), )
1951 betai = Dispatch ( (lbetai, (int, float)), )
1952 erfcc = Dispatch ( (lerfcc, (int, float)), )
1953 gammln = Dispatch ( (lgammln, (int, float)), )
19551954
19561955 ## ANOVA FUNCTIONS:
1957 F_oneway = Dispatch ( (lF_oneway, (ListType, TupleType)), )
1958 F_value = Dispatch ( (lF_value, (ListType, TupleType)), )
1956 F_oneway = Dispatch ( (lF_oneway, (list, tuple)), )
1957 F_value = Dispatch ( (lF_value, (list, tuple)), )
19591958
19601959 ## SUPPORT FUNCTIONS:
1961 incr = Dispatch ( (lincr, (ListType, TupleType)), )
1962 sum = Dispatch ( (lsum, (ListType, TupleType)), )
1963 cumsum = Dispatch ( (lcumsum, (ListType, TupleType)), )
1964 ss = Dispatch ( (lss, (ListType, TupleType)), )
1965 summult = Dispatch ( (lsummult, (ListType, TupleType)), )
1966 square_of_sums = Dispatch ( (lsquare_of_sums, (ListType, TupleType)), )
1967 sumdiffsquared = Dispatch ( (lsumdiffsquared, (ListType, TupleType)), )
1968 shellsort = Dispatch ( (lshellsort, (ListType, TupleType)), )
1969 rankdata = Dispatch ( (lrankdata, (ListType, TupleType)), )
1970 findwithin = Dispatch ( (lfindwithin, (ListType, TupleType)), )
1960 incr = Dispatch ( (lincr, (list, tuple)), )
1961 sum = Dispatch ( (lsum, (list, tuple)), )
1962 cumsum = Dispatch ( (lcumsum, (list, tuple)), )
1963 ss = Dispatch ( (lss, (list, tuple)), )
1964 summult = Dispatch ( (lsummult, (list, tuple)), )
1965 square_of_sums = Dispatch ( (lsquare_of_sums, (list, tuple)), )
1966 sumdiffsquared = Dispatch ( (lsumdiffsquared, (list, tuple)), )
1967 shellsort = Dispatch ( (lshellsort, (list, tuple)), )
1968 rankdata = Dispatch ( (lrankdata, (list, tuple)), )
1969 findwithin = Dispatch ( (lfindwithin, (list, tuple)), )
19711970
19721971
19731972 #============= THE ARRAY-VERSION OF THE STATS FUNCTIONS ===============
20182017 size = len(inarray)
20192018 mult = N.power(inarray,1.0/size)
20202019 mult = N.multiply.reduce(mult)
2021 elif type(dimension) in [IntType,FloatType]:
2020 elif isinstance(dimension, (int, float)):
20222021 size = inarray.shape[dimension]
20232022 mult = N.power(inarray,1.0/size)
20242023 mult = N.multiply.reduce(mult,dimension)
20602059 inarray = N.ravel(inarray)
20612060 size = len(inarray)
20622061 s = N.add.reduce(1.0 / inarray)
2063 elif type(dimension) in [IntType,FloatType]:
2062 elif isinstance(dimension, (int, float)):
20642063 size = float(inarray.shape[dimension])
20652064 s = N.add.reduce(1.0/inarray, dimension)
20662065 if keepdims == 1:
21152114 inarray = N.ravel(inarray)
21162115 sum = N.add.reduce(inarray)
21172116 denom = float(len(inarray))
2118 elif type(dimension) in [IntType,FloatType]:
2117 elif isinstance(dimension, (int, float)):
21192118 sum = asum(inarray,dimension)
21202119 denom = float(inarray.shape[dimension])
21212120 if keepdims == 1:
22292228 a = a.astype(N.float_)
22302229 if limits == None:
22312230 return mean(a)
2232 assert type(limits) in [ListType,TupleType,N.ndarray], "Wrong type for limits in atmean"
2231 assert isinstance(limits, (list, tuple, N.ndarray)), "Wrong type for limits in atmean"
22332232 if inclusive[0]: lowerfcn = N.greater_equal
22342233 else: lowerfcn = N.greater
22352234 if inclusive[1]: upperfcn = N.less_equal
22612260 a = a.astype(N.float_)
22622261 if limits == None or limits == [None,None]:
22632262 return avar(a)
2264 assert type(limits) in [ListType,TupleType,N.ndarray], "Wrong type for limits in atvar"
2263 assert isinstance(limits, (list, tuple, N.ndarray)), "Wrong type for limits in atvar"
22652264 if inclusive[0]: lowerfcn = N.greater_equal
22662265 else: lowerfcn = N.greater
22672266 if inclusive[1]: upperfcn = N.less_equal
23472346 if limits == None or limits == [None,None]:
23482347 n = float(len(N.ravel(a)))
23492348 limits = [min(a)-1, max(a)+1]
2350 assert type(limits) in [ListType,TupleType,N.ndarray], "Wrong type for limits in atsem"
2349 assert isinstance(limits, (list, tuple, N.ndarray)), "Wrong type for limits in atsem"
23512350 if inclusive[0]: lowerfcn = N.greater_equal
23522351 else: lowerfcn = N.greater
23532352 if inclusive[1]: upperfcn = N.less_equal
24162415 """
24172416 denom = N.power(amoment(a,2,dimension),1.5)
24182417 zero = N.equal(denom,0)
2419 if type(denom) == N.ndarray and asum(zero) <> 0:
2418 if isinstance(denom, N.ndarray) and asum(zero) <> 0:
24202419 print("Number of zeros in askew: ", asum(zero))
24212420 denom = denom + zero # prevent divide-by-zero
24222421 return N.where(zero, 0, amoment(a,3,dimension)/denom)
24352434 """
24362435 denom = N.power(amoment(a,2,dimension),2)
24372436 zero = N.equal(denom,0)
2438 if type(denom) == N.ndarray and asum(zero) <> 0:
2437 if isinstance(denom, N.ndarray) and asum(zero) <> 0:
24392438 print("Number of zeros in akurtosis: ", asum(zero))
24402439 denom = denom + zero # prevent divide-by-zero
24412440 return N.where(zero,0,amoment(a,4,dimension)/denom)
27212720 else:
27222721 mn = amean(inarray,dimension,keepdims=1)
27232722 deviations = inarray - mn
2724 if type(dimension) == ListType:
2723 if isinstance(dimension, list):
27252724 n = 1
27262725 for d in dimension:
27272726 n = n*inarray.shape[d]
27772776 xdeviations = x - xmn
27782777 ymn = amean(y,dimension,1) # keepdims
27792778 ydeviations = y - ymn
2780 if type(dimension) == ListType:
2779 if isinstance(dimension, list):
27812780 n = 1
27822781 for d in dimension:
27832782 n = n*x.shape[d]
28022801 dimension = 0
28032802 mn = amean(inarray,dimension,1)
28042803 deviations = inarray - mn
2805 if type(dimension) == ListType:
2804 if isinstance(dimension, list):
28062805 n = 1
28072806 for d in dimension:
28082807 n = n*inarray.shape[d]
28542853 if dimension == None:
28552854 inarray = N.ravel(inarray)
28562855 dimension = 0
2857 if type(dimension) == ListType:
2856 if isinstance(dimension, list):
28582857 n = 1
28592858 for d in dimension:
28602859 n = n*inarray.shape[d]
33183317 Usage: attest_1samp(a,popmean,Name='Sample',printit=0,writemode='a')
33193318 Returns: t-value, two-tailed prob
33203319 """
3321 if type(a) != N.ndarray:
3320 if not isinstance(a, N.ndarray):
33223321 a = N.array(a)
33233322 x = amean(a)
33243323 v = avar(a)
33693368 t = N.where(zerodivproblem,1.0,t) # replace NaN/wrong t-values with 1.0
33703369 probs = abetai(0.5*df,0.5,float(df)/(df+t*t))
33713370
3372 if type(t) == N.ndarray:
3371 if isinstance(t, N.ndarray):
33733372 probs = N.reshape(probs,t.shape)
33743373 if probs.shape == (1,):
33753374 probs = probs[0]
33763375
33773376 if printit <> 0:
3378 if type(t) == N.ndarray:
3377 if isinstance(t, N.ndarray):
33793378 t = t[0]
3380 if type(probs) == N.ndarray:
3379 if isinstance(probs, N.ndarray):
33813380 probs = probs[0]
33823381 statname = 'Independent samples T-test.'
33833382 outputpairedstats(printit,writemode,
34523451 t = N.add.reduce(d,dimension) / denom # N-D COMPUTATION HERE!!!!!!
34533452 t = N.where(zerodivproblem,1.0,t) # replace NaN/wrong t-values with 1.0
34543453 probs = abetai(0.5*df,0.5,float(df)/(df+t*t))
3455 if type(t) == N.ndarray:
3454 if isinstance(t, N.ndarray):
34563455 probs = N.reshape(probs,t.shape)
34573456 if probs.shape == (1,):
34583457 probs = probs[0]
37133712 exponents = N.where(N.less(x,-BIG),-BIG,x)
37143713 return N.exp(exponents)
37153714
3716 if type(chisq) == N.ndarray:
3715 if isinstance(chisq, N.ndarray):
37173716 arrayflag = 1
37183717 else:
37193718 arrayflag = 0
38413840
38423841 Usage: aksprob(alam)
38433842 """
3844 if type(alam) == N.ndarray:
3843 if isinstance(alam, N.ndarray):
38453844 frozen = -1 *N.ones(alam.shape,N.float64)
38463845 alam = alam.astype(N.float64)
38473846 arrayflag = 1
38843883
38853884 Usage: afprob(dfnum, dfden, F) where usually dfnum=dfbn, dfden=dfwn
38863885 """
3887 if type(F) == N.ndarray:
3886 if isinstance(F, N.ndarray):
38883887 return abetai(0.5*dfden, 0.5*dfnum, dfden/(1.0*dfden+dfnum*F))
38893888 else:
38903889 return abetai(0.5*dfden, 0.5*dfnum, dfden/float(dfden+dfnum*F))
39023901 EPS = 3.0e-7
39033902
39043903 arrayflag = 1
3905 if type(x) == N.ndarray:
3904 if isinstance(x, N.ndarray):
39063905 frozen = N.ones(x.shape,N.float_) *-1 #start out w/ -1s, should replace all
39073906 else:
39083907 arrayflag = 0
39773976 Usage: abetai(a,b,x,verbose=1)
39783977 """
39793978 TINY = 1e-15
3980 if type(a) == N.ndarray:
3979 if isinstance(a, N.ndarray):
39813980 if asum(N.less(x,0)+N.greater(x,1)) <> 0:
39823981 raise ValueError, 'Bad x in abetai'
39833982 x = N.where(N.equal(x,0),TINY,x)
39893988 # 746 (below) is the MAX POSSIBLE BEFORE OVERFLOW
39903989 exponents = N.where(N.less(exponents,-740),-740,exponents)
39913990 bt = N.exp(exponents)
3992 if type(x) == N.ndarray:
3991 if isinstance(x, N.ndarray):
39933992 ans = N.where(N.less(x,(a+1)/(a+b+2.0)),
39943993 bt*abetacf(a,b,x,verbose)/float(a),
39953994 1.0-bt*abetacf(b,a,1.0-x,verbose)/float(b))
41154114 dfF = degrees of freedom associated with the Restricted model
41164115 where ER and EF are matrices from a multivariate F calculation.
41174116 """
4118 if type(ER) in [IntType, FloatType]:
4117 if isinstance(ER, (int, float)):
41194118 ER = N.array([[ER]])
4120 if type(EF) in [IntType, FloatType]:
4119 if isinstance(EF, (int, float)):
41214120 EF = N.array([[EF]])
41224121 n_um = (LA.det(ER) - LA.det(EF)) / float(dfnum)
41234122 d_en = LA.det(EF) / float(dfden)
41344133 Returns: array shape of a, with -1 where a<0 and +1 where a>=0
41354134 """
41364135 a = N.asarray(a)
4137 if ((type(a) == type(1.4)) or (type(a) == type(1))):
4136 if isinstance(a, (int, float)):
41384137 return a-a-N.less(a,0)+N.greater(a,0)
41394138 else:
41404139 return N.zeros(N.shape(a))-N.less(a,0)+N.greater(a,0)
41534152 Usage: asum(a, dimension=None, keepdims=0)
41544153 Returns: array summed along 'dimension'(s), same _number_ of dims if keepdims=1
41554154 """
4156 if type(a) == N.ndarray and a.dtype in [N.int_, N.short, N.ubyte]:
4155 if isinstance(a, N.ndarray) and a.dtype in [N.int_, N.short, N.ubyte]:
41574156 a = a.astype(N.float_)
41584157 if dimension == None:
41594158 s = N.sum(N.ravel(a))
4160 elif type(dimension) in [IntType,FloatType]:
4159 elif isinstance(dimension, (int, float)):
41614160 s = N.add.reduce(a, dimension)
41624161 if keepdims == 1:
41634162 shp = list(a.shape)
41904189 if dimension == None:
41914190 a = N.ravel(a)
41924191 dimension = 0
4193 if type(dimension) in [ListType, TupleType, N.ndarray]:
4192 if isinstance(dimension, (list, tuple, N.ndarray)):
41944193 dimension = list(dimension)
41954194 dimension.sort()
41964195 dimension.reverse()
42514250 inarray = N.ravel(inarray)
42524251 dimension = 0
42534252 s = asum(inarray,dimension,keepdims)
4254 if type(s) == N.ndarray:
4253 if isinstance(s, N.ndarray):
42554254 return s.astype(N.float_)*s
42564255 else:
42574256 return float(s)*s
43494348 #########################################################
43504349
43514350 ## CENTRAL TENDENCY:
4352 geometricmean = Dispatch ( (lgeometricmean, (ListType, TupleType)),
4351 geometricmean = Dispatch ( (lgeometricmean, (list, tuple)),
43534352 (ageometricmean, (N.ndarray,)) )
4354 harmonicmean = Dispatch ( (lharmonicmean, (ListType, TupleType)),
4353 harmonicmean = Dispatch ( (lharmonicmean, (list, tuple)),
43554354 (aharmonicmean, (N.ndarray,)) )
4356 mean = Dispatch ( (lmean, (ListType, TupleType)),
4355 mean = Dispatch ( (lmean, (list, tuple)),
43574356 (amean, (N.ndarray,)) )
4358 median = Dispatch ( (lmedian, (ListType, TupleType)),
4357 median = Dispatch ( (lmedian, (list, tuple)),
43594358 (amedian, (N.ndarray,)) )
4360 medianscore = Dispatch ( (lmedianscore, (ListType, TupleType)),
4359 medianscore = Dispatch ( (lmedianscore, (list, tuple)),
43614360 (amedianscore, (N.ndarray,)) )
4362 mode = Dispatch ( (lmode, (ListType, TupleType)),
4361 mode = Dispatch ( (lmode, (list, tuple)),
43634362 (amode, (N.ndarray,)) )
43644363 tmean = Dispatch ( (atmean, (N.ndarray,)) )
43654364 tvar = Dispatch ( (atvar, (N.ndarray,)) )
43674366 tsem = Dispatch ( (atsem, (N.ndarray,)) )
43684367
43694368 ## VARIATION:
4370 moment = Dispatch ( (lmoment, (ListType, TupleType)),
4369 moment = Dispatch ( (lmoment, (list, tuple)),
43714370 (amoment, (N.ndarray,)) )
4372 variation = Dispatch ( (lvariation, (ListType, TupleType)),
4371 variation = Dispatch ( (lvariation, (list, tuple)),
43734372 (avariation, (N.ndarray,)) )
4374 skew = Dispatch ( (lskew, (ListType, TupleType)),
4373 skew = Dispatch ( (lskew, (list, tuple)),
43754374 (askew, (N.ndarray,)) )
4376 kurtosis = Dispatch ( (lkurtosis, (ListType, TupleType)),
4375 kurtosis = Dispatch ( (lkurtosis, (list, tuple)),
43774376 (akurtosis, (N.ndarray,)) )
4378 describe = Dispatch ( (ldescribe, (ListType, TupleType)),
4377 describe = Dispatch ( (ldescribe, (list, tuple)),
43794378 (adescribe, (N.ndarray,)) )
43804379
43814380 ## DISTRIBUTION TESTS
43824381
4383 skewtest = Dispatch ( (askewtest, (ListType, TupleType)),
4382 skewtest = Dispatch ( (askewtest, (list, tuple)),
43844383 (askewtest, (N.ndarray,)) )
4385 kurtosistest = Dispatch ( (akurtosistest, (ListType, TupleType)),
4384 kurtosistest = Dispatch ( (akurtosistest, (list, tuple)),
43864385 (akurtosistest, (N.ndarray,)) )
4387 normaltest = Dispatch ( (anormaltest, (ListType, TupleType)),
4386 normaltest = Dispatch ( (anormaltest, (list, tuple)),
43884387 (anormaltest, (N.ndarray,)) )
43894388
43904389 ## FREQUENCY STATS:
4391 itemfreq = Dispatch ( (litemfreq, (ListType, TupleType)),
4390 itemfreq = Dispatch ( (litemfreq, (list, tuple)),
43924391 (aitemfreq, (N.ndarray,)) )
4393 scoreatpercentile = Dispatch ( (lscoreatpercentile, (ListType, TupleType)),
4392 scoreatpercentile = Dispatch ( (lscoreatpercentile, (list, tuple)),
43944393 (ascoreatpercentile, (N.ndarray,)) )
4395 percentileofscore = Dispatch ( (lpercentileofscore, (ListType, TupleType)),
4394 percentileofscore = Dispatch ( (lpercentileofscore, (list, tuple)),
43964395 (apercentileofscore, (N.ndarray,)) )
4397 histogram = Dispatch ( (lhistogram, (ListType, TupleType)),
4396 histogram = Dispatch ( (lhistogram, (list, tuple)),
43984397 (ahistogram, (N.ndarray,)) )
4399 cumfreq = Dispatch ( (lcumfreq, (ListType, TupleType)),
4398 cumfreq = Dispatch ( (lcumfreq, (list, tuple)),
44004399 (acumfreq, (N.ndarray,)) )
4401 relfreq = Dispatch ( (lrelfreq, (ListType, TupleType)),
4400 relfreq = Dispatch ( (lrelfreq, (list, tuple)),
44024401 (arelfreq, (N.ndarray,)) )
44034402
44044403 ## VARIABILITY:
4405 obrientransform = Dispatch ( (lobrientransform, (ListType, TupleType)),
4404 obrientransform = Dispatch ( (lobrientransform, (list, tuple)),
44064405 (aobrientransform, (N.ndarray,)) )
4407 samplevar = Dispatch ( (lsamplevar, (ListType, TupleType)),
4406 samplevar = Dispatch ( (lsamplevar, (list, tuple)),
44084407 (asamplevar, (N.ndarray,)) )
4409 samplestdev = Dispatch ( (lsamplestdev, (ListType, TupleType)),
4408 samplestdev = Dispatch ( (lsamplestdev, (list, tuple)),
44104409 (asamplestdev, (N.ndarray,)) )
44114410 signaltonoise = Dispatch( (asignaltonoise, (N.ndarray,)),)
4412 var = Dispatch ( (lvar, (ListType, TupleType)),
4411 var = Dispatch ( (lvar, (list, tuple)),
44134412 (avar, (N.ndarray,)) )
4414 stdev = Dispatch ( (lstdev, (ListType, TupleType)),
4413 stdev = Dispatch ( (lstdev, (list, tuple)),
44154414 (astdev, (N.ndarray,)) )
4416 sterr = Dispatch ( (lsterr, (ListType, TupleType)),
4415 sterr = Dispatch ( (lsterr, (list, tuple)),
44174416 (asterr, (N.ndarray,)) )
4418 sem = Dispatch ( (lsem, (ListType, TupleType)),
4417 sem = Dispatch ( (lsem, (list, tuple)),
44194418 (asem, (N.ndarray,)) )
4420 z = Dispatch ( (lz, (ListType, TupleType)),
4419 z = Dispatch ( (lz, (list, tuple)),
44214420 (az, (N.ndarray,)) )
4422 zs = Dispatch ( (lzs, (ListType, TupleType)),
4421 zs = Dispatch ( (lzs, (list, tuple)),
44234422 (azs, (N.ndarray,)) )
44244423
44254424 ## TRIMMING FCNS:
44264425 threshold = Dispatch( (athreshold, (N.ndarray,)),)
4427 trimboth = Dispatch ( (ltrimboth, (ListType, TupleType)),
4426 trimboth = Dispatch ( (ltrimboth, (list, tuple)),
44284427 (atrimboth, (N.ndarray,)) )
4429 trim1 = Dispatch ( (ltrim1, (ListType, TupleType)),
4428 trim1 = Dispatch ( (ltrim1, (list, tuple)),
44304429 (atrim1, (N.ndarray,)) )
44314430
44324431 ## CORRELATION FCNS:
4433 paired = Dispatch ( (lpaired, (ListType, TupleType)),
4432 paired = Dispatch ( (lpaired, (list, tuple)),
44344433 (apaired, (N.ndarray,)) )
4435 lincc = Dispatch ( (llincc, (ListType, TupleType)),
4434 lincc = Dispatch ( (llincc, (list, tuple)),
44364435 (alincc, (N.ndarray,)) )
4437 pearsonr = Dispatch ( (lpearsonr, (ListType, TupleType)),
4436 pearsonr = Dispatch ( (lpearsonr, (list, tuple)),
44384437 (apearsonr, (N.ndarray,)) )
4439 spearmanr = Dispatch ( (lspearmanr, (ListType, TupleType)),
4438 spearmanr = Dispatch ( (lspearmanr, (list, tuple)),
44404439 (aspearmanr, (N.ndarray,)) )
4441 pointbiserialr = Dispatch ( (lpointbiserialr, (ListType, TupleType)),
4440 pointbiserialr = Dispatch ( (lpointbiserialr, (list, tuple)),
44424441 (apointbiserialr, (N.ndarray,)) )
4443 kendalltau = Dispatch ( (lkendalltau, (ListType, TupleType)),
4442 kendalltau = Dispatch ( (lkendalltau, (list, tuple)),
44444443 (akendalltau, (N.ndarray,)) )
4445 linregress = Dispatch ( (llinregress, (ListType, TupleType)),
4444 linregress = Dispatch ( (llinregress, (list, tuple)),
44464445 (alinregress, (N.ndarray,)) )
44474446
44484447 ## INFERENTIAL STATS:
4449 ttest_1samp = Dispatch ( (lttest_1samp, (ListType, TupleType)),
4448 ttest_1samp = Dispatch ( (lttest_1samp, (list, tuple)),
44504449 (attest_1samp, (N.ndarray,)) )
4451 ttest_ind = Dispatch ( (lttest_ind, (ListType, TupleType)),
4450 ttest_ind = Dispatch ( (lttest_ind, (list, tuple)),
44524451 (attest_ind, (N.ndarray,)) )
4453 ttest_rel = Dispatch ( (lttest_rel, (ListType, TupleType)),
4452 ttest_rel = Dispatch ( (lttest_rel, (list, tuple)),
44544453 (attest_rel, (N.ndarray,)) )
4455 chisquare = Dispatch ( (lchisquare, (ListType, TupleType)),
4454 chisquare = Dispatch ( (lchisquare, (list, tuple)),
44564455 (achisquare, (N.ndarray,)) )
4457 ks_2samp = Dispatch ( (lks_2samp, (ListType, TupleType)),
4456 ks_2samp = Dispatch ( (lks_2samp, (list, tuple)),
44584457 (aks_2samp, (N.ndarray,)) )
4459 mannwhitneyu = Dispatch ( (lmannwhitneyu, (ListType, TupleType)),
4458 mannwhitneyu = Dispatch ( (lmannwhitneyu, (list, tuple)),
44604459 (amannwhitneyu, (N.ndarray,)) )
4461 tiecorrect = Dispatch ( (ltiecorrect, (ListType, TupleType)),
4460 tiecorrect = Dispatch ( (ltiecorrect, (list, tuple)),
44624461 (atiecorrect, (N.ndarray,)) )
4463 ranksums = Dispatch ( (lranksums, (ListType, TupleType)),
4462 ranksums = Dispatch ( (lranksums, (list, tuple)),
44644463 (aranksums, (N.ndarray,)) )
4465 wilcoxont = Dispatch ( (lwilcoxont, (ListType, TupleType)),
4464 wilcoxont = Dispatch ( (lwilcoxont, (list, tuple)),
44664465 (awilcoxont, (N.ndarray,)) )
4467 kruskalwallish = Dispatch ( (lkruskalwallish, (ListType, TupleType)),
4466 kruskalwallish = Dispatch ( (lkruskalwallish, (list, tuple)),
44684467 (akruskalwallish, (N.ndarray,)) )
4469 friedmanchisquare = Dispatch ( (lfriedmanchisquare, (ListType, TupleType)),
4468 friedmanchisquare = Dispatch ( (lfriedmanchisquare, (list, tuple)),
44704469 (afriedmanchisquare, (N.ndarray,)) )
44714470
44724471 ## PROBABILITY CALCS:
4473 chisqprob = Dispatch ( (lchisqprob, (IntType, FloatType)),
4472 chisqprob = Dispatch ( (lchisqprob, (int, float)),
44744473 (achisqprob, (N.ndarray,)) )
4475 zprob = Dispatch ( (lzprob, (IntType, FloatType)),
4474 zprob = Dispatch ( (lzprob, (int, float)),
44764475 (azprob, (N.ndarray,)) )
4477 ksprob = Dispatch ( (lksprob, (IntType, FloatType)),
4476 ksprob = Dispatch ( (lksprob, (int, float)),
44784477 (aksprob, (N.ndarray,)) )
4479 fprob = Dispatch ( (lfprob, (IntType, FloatType)),
4478 fprob = Dispatch ( (lfprob, (int, float)),
44804479 (afprob, (N.ndarray,)) )
4481 betacf = Dispatch ( (lbetacf, (IntType, FloatType)),
4480 betacf = Dispatch ( (lbetacf, (int, float)),
44824481 (abetacf, (N.ndarray,)) )
4483 betai = Dispatch ( (lbetai, (IntType, FloatType)),
4482 betai = Dispatch ( (lbetai, (int, float)),
44844483 (abetai, (N.ndarray,)) )
4485 erfcc = Dispatch ( (lerfcc, (IntType, FloatType)),
4484 erfcc = Dispatch ( (lerfcc, (int, float)),
44864485 (aerfcc, (N.ndarray,)) )
4487 gammln = Dispatch ( (lgammln, (IntType, FloatType)),
4486 gammln = Dispatch ( (lgammln, (int, float)),
44884487 (agammln, (N.ndarray,)) )
44894488
44904489 ## ANOVA FUNCTIONS:
4491 F_oneway = Dispatch ( (lF_oneway, (ListType, TupleType)),
4490 F_oneway = Dispatch ( (lF_oneway, (list, tuple)),
44924491 (aF_oneway, (N.ndarray,)) )
4493 F_value = Dispatch ( (lF_value, (ListType, TupleType)),
4492 F_value = Dispatch ( (lF_value, (list, tuple)),
44944493 (aF_value, (N.ndarray,)) )
44954494
44964495 ## SUPPORT FUNCTIONS:
4497 incr = Dispatch ( (lincr, (ListType, TupleType, N.ndarray)), )
4498 sum = Dispatch ( (lsum, (ListType, TupleType)),
4496 incr = Dispatch ( (lincr, (list, tuple, N.ndarray)), )
4497 sum = Dispatch ( (lsum, (list, tuple)),
44994498 (asum, (N.ndarray,)) )
4500 cumsum = Dispatch ( (lcumsum, (ListType, TupleType)),
4499 cumsum = Dispatch ( (lcumsum, (list, tuple)),
45014500 (acumsum, (N.ndarray,)) )
4502 ss = Dispatch ( (lss, (ListType, TupleType)),
4501 ss = Dispatch ( (lss, (list, tuple)),
45034502 (ass, (N.ndarray,)) )
4504 summult = Dispatch ( (lsummult, (ListType, TupleType)),
4503 summult = Dispatch ( (lsummult, (list, tuple)),
45054504 (asummult, (N.ndarray,)) )
4506 square_of_sums = Dispatch ( (lsquare_of_sums, (ListType, TupleType)),
4505 square_of_sums = Dispatch ( (lsquare_of_sums, (list, tuple)),
45074506 (asquare_of_sums, (N.ndarray,)) )
4508 sumdiffsquared = Dispatch ( (lsumdiffsquared, (ListType, TupleType)),
4507 sumdiffsquared = Dispatch ( (lsumdiffsquared, (list, tuple)),
45094508 (asumdiffsquared, (N.ndarray,)) )
4510 shellsort = Dispatch ( (lshellsort, (ListType, TupleType)),
4509 shellsort = Dispatch ( (lshellsort, (list, tuple)),
45114510 (ashellsort, (N.ndarray,)) )
4512 rankdata = Dispatch ( (lrankdata, (ListType, TupleType)),
4511 rankdata = Dispatch ( (lrankdata, (list, tuple)),
45134512 (arankdata, (N.ndarray,)) )
4514 findwithin = Dispatch ( (lfindwithin, (ListType, TupleType)),
4513 findwithin = Dispatch ( (lfindwithin, (list, tuple)),
45154514 (afindwithin, (N.ndarray,)) )
45164515
45174516 ###################### END OF NUMERIC FUNCTION BLOCK #####################
4646 session.add(regression)
4747 new_ris = []
4848 for fc_id in field_changes:
49 if type(fc_id) == int:
49 if isinstance(fc_id, int):
5050 fc = get_fieldchange(session, ts, fc_id)
5151 else:
5252 fc = fc_id
2929 def with_ts(obj):
3030 """For Url type fields to work, the objects we return must have a test-suite
3131 and database attribute set, the function attempts to set them."""
32 if type(obj) == list:
32 if isinstance(obj, list):
3333 # For lists, set them on all elements.
3434 return [with_ts(x) for x in obj]
35 if type(obj) == dict:
35 if isinstance(obj, dict):
3636 # If already a dict, just add the fields.
3737 new_obj = obj
3838 else:
5656 def default(self, obj):
5757 if hasattr(obj, '__json__'):
5858 return obj.__json__()
59 if type(obj) is datetime.datetime:
59 if isinstance(obj, datetime.datetime):
6060 return obj.isoformat()
6161 if isinstance(obj.__class__, DeclarativeMeta):
6262 fields = {}
9999 opts -- the command line options object
100100 start_time -- the time the program was invoked as a string
101101 """
102 assert type(opts) == dict, "Options must be a dict."
102 assert isinstance(opts, dict), "Options must be a dict."
103103 self.opts = opts
104104 self.__dict__.update(opts)
105105 self.start_time = start_time