llvm.org GIT mirror lnt / dc38126
[LNT] Python 3 support: Replace `raise E, V` with `raise E(V)` Summary: Mechanically changed `raise E, V` to `raise E(V)`. Split out from D67535. This patch covers the files found to be affected when running tests (without result submission). Reviewers: cmatthews, thopre, kristof.beyls Reviewed By: thopre Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D67581 git-svn-id: https://llvm.org/svn/llvm-project/lnt/trunk@371946 91177308-0d34-0410-b5e6-96231b3b80d8 Hubert Tong a month ago
1 changed file(s) with 27 addition(s) and 27 deletion(s). Raw diff Collapse all Expand all
246246 for func, types in tuples:
247247 for t in types:
248248 if t in self._dispatch:
249 raise ValueError, "can't have two dispatches on "+str(t)
249 raise ValueError("can't have two dispatches on " + str(t))
250250 self._dispatch[t] = func
251251
252252 def __call__(self, arg1, *args, **kw):
253253 if type(arg1) not in self._dispatch:
254 raise TypeError, "don't know how to dispatch %s arguments" % type(arg1)
254 raise TypeError("don't know how to dispatch %s arguments" % type(arg1))
255255 return apply(self._dispatch[type(arg1)], (arg1,) + args, kw)
256256
257257
598598 if v[j] - mean(nargs[j]) > TINY:
599599 check = 0
600600 if check != 1:
601 raise ValueError, 'Problem in obrientransform.'
601 raise ValueError('Problem in obrientransform.')
602602 else:
603603 return nargs
604604
841841 """
842842 TINY = 1.0e-30
843843 if len(x) != len(y):
844 raise ValueError, 'Input values not paired in pearsonr. Aborting.'
844 raise ValueError('Input values not paired in pearsonr. Aborting.')
845845 n = len(x)
846846 x = map(float,x)
847847 y = map(float,y)
880880 """
881881 TINY = 1e-30
882882 if len(x) != len(y):
883 raise ValueError, 'Input values not paired in spearmanr. Aborting.'
883 raise ValueError('Input values not paired in spearmanr. Aborting.')
884884 n = len(x)
885885 rankx = rankdata(x)
886886 ranky = rankdata(y)
905905 """
906906 TINY = 1e-30
907907 if len(x) != len(y):
908 raise ValueError, 'INPUT VALUES NOT PAIRED IN pointbiserialr. ABORTING.'
908 raise ValueError('INPUT VALUES NOT PAIRED IN pointbiserialr. ABORTING.')
909909 data = pstat.abut(x,y)
910910 categories = pstat.unique(x)
911911 if len(categories) != 2:
912 raise ValueError, "Exactly 2 categories required for pointbiserialr()."
912 raise ValueError("Exactly 2 categories required for pointbiserialr().")
913913 else: # there are 2 categories, continue
914914 codemap = pstat.abut(categories,range(2))
915915 recoded = pstat.recode(data,codemap,0)
970970 """
971971 TINY = 1.0e-20
972972 if len(x) != len(y):
973 raise ValueError, 'Input values not paired in linregress. Aborting.'
973 raise ValueError('Input values not paired in linregress. Aborting.')
974974 n = len(x)
975975 x = map(float,x)
976976 y = map(float,y)
10631063 Returns: t-value, two-tailed prob
10641064 """
10651065 if len(a) != len(b):
1066 raise ValueError, 'Unequal length lists in ttest_rel.'
1066 raise ValueError('Unequal length lists in ttest_rel.')
10671067 x1 = mean(a)
10681068 x2 = mean(b)
10691069 v1 = var(a)
11671167 smallu = min(u1,u2)
11681168 T = math.sqrt(tiecorrect(ranked)) # correction factor for tied scores
11691169 if T == 0:
1170 raise ValueError, 'All numbers are identical in lmannwhitneyu'
1170 raise ValueError('All numbers are identical in lmannwhitneyu')
11711171 sd = math.sqrt(T*n1*n2*(n1+n2+1)/12.0)
11721172 z = abs((bigu-n1*n2/2.0) / sd) # normal approximation for prob calc
11731173 return smallu, 1.0 - zprob(z)
12291229 Returns: a t-statistic, two-tail probability estimate
12301230 """
12311231 if len(x) != len(y):
1232 raise ValueError, 'Unequal N in wilcoxont. Aborting.'
1232 raise ValueError('Unequal N in wilcoxont. Aborting.')
12331233 d=[]
12341234 for i in range(len(x)):
12351235 diff = x[i] - y[i]
12831283 h = 12.0 / (totaln*(totaln+1)) * ssbn - 3*(totaln+1)
12841284 df = len(args) - 1
12851285 if T == 0:
1286 raise ValueError, 'All numbers are identical in lkruskalwallish'
1286 raise ValueError('All numbers are identical in lkruskalwallish')
12871287 h = h / float(T)
12881288 return h, chisqprob(h,df)
12891289
13021302 """
13031303 k = len(args)
13041304 if k < 3:
1305 raise ValueError, 'Less than 3 levels. Friedman test not appropriate.'
1305 raise ValueError('Less than 3 levels. Friedman test not appropriate.')
13061306 n = len(args[0])
13071307 data = apply(pstat.abut,tuple(args))
13081308 for i in range(len(data)):
15371537 Usage: lbetai(a,b,x)
15381538 """
15391539 if (x<0.0 or x>1.0):
1540 raise ValueError, 'Bad x in lbetai'
1540 raise ValueError('Bad x in lbetai')
15411541 if (x==0.0 or x==1.0):
15421542 bt = 0.0
15431543 else:
17111711 Usage: lsummult(list1,list2)
17121712 """
17131713 if len(list1) != len(list2):
1714 raise ValueError, "Lists not equal length in summult."
1714 raise ValueError("Lists not equal length in summult.")
17151715 s = 0
17161716 for item1,item2 in pstat.abut(list1,list2):
17171717 s = s + item1*item2
22342234 if inclusive[1]: upperfcn = N.less_equal
22352235 else: upperfcn = N.less
22362236 if limits[0] > N.maximum.reduce(N.ravel(a)) or limits[1] < N.minimum.reduce(N.ravel(a)):
2237 raise ValueError, "No array values within given limits (atmean)."
2237 raise ValueError("No array values within given limits (atmean).")
22382238 elif limits[0] is None and limits[1] is not None:
22392239 mask = upperfcn(a,limits[1])
22402240 elif limits[0] is not None and limits[1] is None:
22662266 if inclusive[1]: upperfcn = N.less_equal
22672267 else: upperfcn = N.less
22682268 if limits[0] > N.maximum.reduce(N.ravel(a)) or limits[1] < N.minimum.reduce(N.ravel(a)):
2269 raise ValueError, "No array values within given limits (atvar)."
2269 raise ValueError("No array values within given limits (atvar).")
22702270 elif limits[0] is None and limits[1] is not None:
22712271 mask = upperfcn(a,limits[1])
22722272 elif limits[0] is not None and limits[1] is None:
23522352 if inclusive[1]: upperfcn = N.less_equal
23532353 else: upperfcn = N.less
23542354 if limits[0] > N.maximum.reduce(N.ravel(a)) or limits[1] < N.minimum.reduce(N.ravel(a)):
2355 raise ValueError, "No array values within given limits (atsem)."
2355 raise ValueError("No array values within given limits (atsem).")
23562356 elif limits[0] is None and limits[1] is not None:
23572357 mask = upperfcn(a,limits[1])
23582358 elif limits[0] is not None and limits[1] is None:
26972697 if v[j] - mean(nargs[j]) > TINY:
26982698 check = 0
26992699 if check != 1:
2700 raise ValueError, 'Lack of convergence in obrientransform.'
2700 raise ValueError('Lack of convergence in obrientransform.')
27012701 else:
27022702 return N.array(nargs)
27032703
29722972 Returns: covariance matrix of X
29732973 """
29742974 if len(X.shape) != 2:
2975 raise TypeError, "acovariance requires 2D matrices"
2975 raise TypeError("acovariance requires 2D matrices")
29762976 n = X.shape[0]
29772977 mX = amean(X,0)
29782978 return N.dot(N.transpose(X),X) / float(n) - N.multiply.outer(mX,mX)
31693169 categories = pstat.aunique(x)
31703170 data = pstat.aabut(x,y)
31713171 if len(categories) != 2:
3172 raise ValueError, "Exactly 2 categories required (in x) for pointbiserialr()."
3172 raise ValueError("Exactly 2 categories required (in x) for pointbiserialr().")
31733173 else: # there are 2 categories, continue
31743174 codemap = pstat.aabut(categories,N.arange(2))
31753175 recoded = pstat.arecode(data,codemap,0)
34363436 b = N.ravel(b)
34373437 dimension = 0
34383438 if len(a) != len(b):
3439 raise ValueError, 'Unequal length arrays.'
3439 raise ValueError('Unequal length arrays.')
34403440 x1 = amean(a,dimension)
34413441 x2 = amean(b,dimension)
34423442 v1 = avar(a,dimension)
35493549 smallu = min(u1,u2)
35503550 T = math.sqrt(tiecorrect(ranked)) # correction factor for tied scores
35513551 if T == 0:
3552 raise ValueError, 'All numbers are identical in amannwhitneyu'
3552 raise ValueError('All numbers are identical in amannwhitneyu')
35533553 sd = math.sqrt(T*n1*n2*(n1+n2+1)/12.0)
35543554 z = abs((bigu-n1*n2/2.0) / sd) # normal approximation for prob calc
35553555 return smallu, 1.0 - azprob(z)
36113611 Returns: t-statistic, two-tailed p-value
36123612 """
36133613 if len(x) != len(y):
3614 raise ValueError, 'Unequal N in awilcoxont. Aborting.'
3614 raise ValueError('Unequal N in awilcoxont. Aborting.')
36153615 d = x-y
36163616 d = N.compress(N.not_equal(d,0),d) # Keep all non-zero differences
36173617 count = len(d)
36643664 h = 12.0 / (totaln*(totaln+1)) * ssbn - 3*(totaln+1)
36653665 df = len(args) - 1
36663666 if T == 0:
3667 raise ValueError, 'All numbers are identical in akruskalwallish'
3667 raise ValueError('All numbers are identical in akruskalwallish')
36683668 h = h / float(T)
36693669 return h, chisqprob(h,df)
36703670
36833683 """
36843684 k = len(args)
36853685 if k < 3:
3686 raise ValueError, '\nLess than 3 levels. Friedman test not appropriate.\n'
3686 raise ValueError('\nLess than 3 levels. Friedman test not appropriate.\n')
36873687 n = len(args[0])
36883688 data = apply(pstat.aabut,args)
36893689 data = data.astype(N.float_)
39783978 TINY = 1e-15
39793979 if isinstance(a, N.ndarray):
39803980 if asum(N.less(x, 0) + N.greater(x, 1)) != 0:
3981 raise ValueError, 'Bad x in abetai'
3981 raise ValueError('Bad x in abetai')
39823982 x = N.where(N.equal(x,0),TINY,x)
39833983 x = N.where(N.equal(x,1.0),1-TINY,x)
39843984