本文整理匯總了Python中numpy.testing.dec.knownfailureif方法的典型用法代碼示例。如果您正苦於以下問題:Python dec.knownfailureif方法的具體用法?Python dec.knownfailureif怎麽用?Python dec.knownfailureif使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類numpy.testing.dec
的用法示例。
在下文中一共展示了dec.knownfailureif方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: knownfailure_overridable
# 需要導入模塊: from numpy.testing import dec [as 別名]
# 或者: from numpy.testing.dec import knownfailureif [as 別名]
def knownfailure_overridable(msg=None):
if not msg:
msg = "Undiagnosed issues (corner cases, wrong comparison values, or otherwise)"
msg = msg + " [Set environment variable SCIPY_XFAIL=1 to run this test nevertheless.]"
def deco(func):
try:
if bool(os.environ['SCIPY_XFAIL']):
return func
except (ValueError, KeyError):
pass
return dec.knownfailureif(True, msg)(func)
return deco
示例2: check_cont_fit
# 需要導入模塊: from numpy.testing import dec [as 別名]
# 或者: from numpy.testing.dec import knownfailureif [as 別名]
def check_cont_fit(distname,arg):
if distname in failing_fits:
# Skip failing fits unless overridden
xfail = True
try:
xfail = not int(os.environ['SCIPY_XFAIL'])
except:
pass
if xfail:
msg = "Fitting %s doesn't work reliably yet" % distname
msg += " [Set environment variable SCIPY_XFAIL=1 to run this test nevertheless.]"
dec.knownfailureif(True, msg)(lambda: None)()
distfn = getattr(stats, distname)
truearg = np.hstack([arg,[0.0,1.0]])
diffthreshold = np.max(np.vstack([truearg*thresh_percent,
np.ones(distfn.numargs+2)*thresh_min]),0)
for fit_size in fit_sizes:
# Note that if a fit succeeds, the other fit_sizes are skipped
np.random.seed(1234)
with np.errstate(all='ignore'):
rvs = distfn.rvs(size=fit_size, *arg)
est = distfn.fit(rvs) # start with default values
diff = est - truearg
# threshold for location
diffthreshold[-2] = np.max([np.abs(rvs.mean())*thresh_percent,thresh_min])
if np.any(np.isnan(est)):
raise AssertionError('nan returned in fit')
else:
if np.all(np.abs(diff) <= diffthreshold):
break
else:
txt = 'parameter: %s\n' % str(truearg)
txt += 'estimated: %s\n' % str(est)
txt += 'diff : %s\n' % str(diff)
raise AssertionError('fit not very good in %s\n' % distfn.name + txt)