当前位置: 首页>>代码示例>>Python>>正文


Python numpy.geterrobj方法代码示例

本文整理汇总了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) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:19,代码来源:test_numeric.py

示例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) 
开发者ID:pfchai,项目名称:ImageFusion,代码行数:19,代码来源:test_numeric.py

示例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 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:31,代码来源:test_numeric.py

示例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 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:31,代码来源:test_numeric.py

示例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 
开发者ID:pfchai,项目名称:ImageFusion,代码行数:31,代码来源:test_numeric.py


注:本文中的numpy.geterrobj方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。