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


Python umath.sign方法代码示例

本文整理汇总了Python中numpy.core.umath.sign方法的典型用法代码示例。如果您正苦于以下问题:Python umath.sign方法的具体用法?Python umath.sign怎么用?Python umath.sign使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在numpy.core.umath的用法示例。


在下文中一共展示了umath.sign方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_floor_division_signed_zero

# 需要导入模块: from numpy.core import umath [as 别名]
# 或者: from numpy.core.umath import sign [as 别名]
def test_floor_division_signed_zero(self):
        # Check that the sign bit is correctly set when dividing positive and
        # negative zero by one.
        x = np.zeros(10)
        assert_equal(np.signbit(x//1), 0)
        assert_equal(np.signbit((-x)//1), 1) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:8,代码来源:test_umath.py

示例2: test_sign

# 需要导入模块: from numpy.core import umath [as 别名]
# 或者: from numpy.core.umath import sign [as 别名]
def test_sign(self):
        a = np.array([np.inf, -np.inf, np.nan, 0.0, 3.0, -3.0])
        out = np.zeros(a.shape)
        tgt = np.array([1., -1., np.nan, 0.0, 1.0, -1.0])

        with np.errstate(invalid='ignore'):
            res = ncu.sign(a)
            assert_equal(res, tgt)
            res = ncu.sign(a, out)
            assert_equal(res, tgt)
            assert_equal(out, tgt) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:13,代码来源:test_umath.py

示例3: test_sign_dtype_object

# 需要导入模块: from numpy.core import umath [as 别名]
# 或者: from numpy.core.umath import sign [as 别名]
def test_sign_dtype_object(self):
        # In reference to github issue #6229

        foo = np.array([-.1, 0, .1])
        a = np.sign(foo.astype(object))
        b = np.sign(foo)

        assert_array_equal(a, b) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:10,代码来源:test_umath.py

示例4: test_sign_dtype_nan_object

# 需要导入模块: from numpy.core import umath [as 别名]
# 或者: from numpy.core.umath import sign [as 别名]
def test_sign_dtype_nan_object(self):
        # In reference to github issue #6229
        def test_nan():
            foo = np.array([np.nan])
            # FIXME: a not used
            a = np.sign(foo.astype(object))

        assert_raises(TypeError, test_nan) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:10,代码来源:test_umath.py

示例5: test_sign_dtype_object

# 需要导入模块: from numpy.core import umath [as 别名]
# 或者: from numpy.core.umath import sign [as 别名]
def test_sign_dtype_object(self):
        # In reference to github issue #6229

        foo = np.array([-.1, 0, .1])
        a = np.sign(foo.astype(np.object))
        b = np.sign(foo)

        assert_array_equal(a, b) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:10,代码来源:test_umath.py

示例6: test_sign_dtype_nan_object

# 需要导入模块: from numpy.core import umath [as 别名]
# 或者: from numpy.core.umath import sign [as 别名]
def test_sign_dtype_nan_object(self):
        # In reference to github issue #6229
        def test_nan():
            foo = np.array([np.nan])
            a = np.sign(foo.astype(np.object))

        assert_raises(TypeError, test_nan) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:9,代码来源:test_umath.py

示例7: test_sign_dtype_nan_object

# 需要导入模块: from numpy.core import umath [as 别名]
# 或者: from numpy.core.umath import sign [as 别名]
def test_sign_dtype_nan_object(self):
        # In reference to github issue #6229
        def test_nan():
            foo = np.array([np.nan])
            a = np.sign(foo.astype(object))

        assert_raises(TypeError, test_nan) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:9,代码来源:test_umath.py


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