本文整理汇总了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)