當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。