本文整理汇总了Python中numpy.geterrobj方法的典型用法代码示例。如果您正苦于以下问题:Python numpy.geterrobj方法的具体用法?Python numpy.geterrobj怎么用?Python numpy.geterrobj使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类numpy
的用法示例。
在下文中一共展示了numpy.geterrobj方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_errobj_noerrmask
# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import geterrobj [as 别名]
def test_errobj_noerrmask(self):
# errmask = 0 has a special code path for the default
olderrobj = np.geterrobj()
try:
# set errobj to something non default
np.seterrobj([umath.UFUNC_BUFSIZE_DEFAULT,
umath.ERR_DEFAULT + 1, None])
# call a ufunc
np.isnan(np.array([6]))
# same with the default, lots of times to get rid of possible
# pre-existing stack in the code
for i in range(10000):
np.seterrobj([umath.UFUNC_BUFSIZE_DEFAULT, umath.ERR_DEFAULT,
None])
np.isnan(np.array([6]))
finally:
np.seterrobj(olderrobj)
示例2: test_errobj_noerrmask
# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import geterrobj [as 别名]
def test_errobj_noerrmask(self):
# errmask = 0 has a special code path for the default
olderrobj = np.geterrobj()
try:
# set errobj to something non default
np.seterrobj([umath.UFUNC_BUFSIZE_DEFAULT,
umath.ERR_DEFAULT + 1, None])
#call a ufunc
np.isnan(np.array([6]))
# same with the default, lots of times to get rid of possible
# pre-existing stack in the code
for i in range(10000):
np.seterrobj([umath.UFUNC_BUFSIZE_DEFAULT, umath.ERR_DEFAULT,
None])
np.isnan(np.array([6]))
finally:
np.seterrobj(olderrobj)
示例3: test_errobj
# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import geterrobj [as 别名]
def test_errobj(self):
olderrobj = np.geterrobj()
self.called = 0
try:
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
with np.errstate(divide='warn'):
np.seterrobj([20000, 1, None])
np.array([1.]) / np.array([0.])
assert_equal(len(w), 1)
def log_err(*args):
self.called += 1
extobj_err = args
assert_(len(extobj_err) == 2)
assert_("divide" in extobj_err[0])
with np.errstate(divide='ignore'):
np.seterrobj([20000, 3, log_err])
np.array([1.]) / np.array([0.])
assert_equal(self.called, 1)
np.seterrobj(olderrobj)
with np.errstate(divide='ignore'):
np.divide(1., 0., extobj=[20000, 3, log_err])
assert_equal(self.called, 2)
finally:
np.seterrobj(olderrobj)
del self.called
示例4: test_errobj
# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import geterrobj [as 别名]
def test_errobj(self):
olderrobj = np.geterrobj()
self.called = 0
try:
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
with np.errstate(divide='warn'):
np.seterrobj([20000, 1, None])
np.array([1.]) / np.array([0.])
self.assertEqual(len(w), 1)
def log_err(*args):
self.called += 1
extobj_err = args
assert_(len(extobj_err) == 2)
assert_("divide" in extobj_err[0])
with np.errstate(divide='ignore'):
np.seterrobj([20000, 3, log_err])
np.array([1.]) / np.array([0.])
self.assertEqual(self.called, 1)
np.seterrobj(olderrobj)
with np.errstate(divide='ignore'):
np.divide(1., 0., extobj=[20000, 3, log_err])
self.assertEqual(self.called, 2)
finally:
np.seterrobj(olderrobj)
del self.called
示例5: test_errobj
# 需要导入模块: import numpy [as 别名]
# 或者: from numpy import geterrobj [as 别名]
def test_errobj(self):
olderrobj = np.geterrobj()
self.called = 0
try:
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
with errstate(divide='warn'):
np.seterrobj([20000, 1, None])
array([1.]) / array([0.])
self.assertEqual(len(w), 1)
def log_err(*args):
self.called += 1
extobj_err = args
assert (len(extobj_err) == 2)
assert ("divide" in extobj_err[0])
with errstate(divide='ignore'):
np.seterrobj([20000, 3, log_err])
array([1.]) / array([0.])
self.assertEqual(self.called, 1)
np.seterrobj(olderrobj)
with errstate(divide='ignore'):
np.divide(1., 0., extobj=[20000, 3, log_err])
self.assertEqual(self.called, 2)
finally:
np.seterrobj(olderrobj)
del self.called