當前位置: 首頁>>代碼示例>>Python>>正文


Python umath_tests.test_signature方法代碼示例

本文整理匯總了Python中numpy.core.umath_tests.test_signature方法的典型用法代碼示例。如果您正苦於以下問題:Python umath_tests.test_signature方法的具體用法?Python umath_tests.test_signature怎麽用?Python umath_tests.test_signature使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在numpy.core.umath_tests的用法示例。


在下文中一共展示了umath_tests.test_signature方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_signature

# 需要導入模塊: from numpy.core import umath_tests [as 別名]
# 或者: from numpy.core.umath_tests import test_signature [as 別名]
def test_signature(self):
        # the arguments to test_signature are: nin, nout, core_signature
        # pass
        assert_equal(umt.test_signature(2, 1, "(i),(i)->()"), 1)

        # pass. empty core signature; treat as plain ufunc (with trivial core)
        assert_equal(umt.test_signature(2, 1, "(),()->()"), 0)

        # in the following calls, a ValueError should be raised because
        # of error in core signature
        # error: extra parenthesis
        msg = "core_sig: extra parenthesis"
        try:
            ret = umt.test_signature(2, 1, "((i)),(i)->()")
            assert_equal(ret, None, err_msg=msg)
        except ValueError: None
        # error: parenthesis matching
        msg = "core_sig: parenthesis matching"
        try:
            ret = umt.test_signature(2, 1, "(i),)i(->()")
            assert_equal(ret, None, err_msg=msg)
        except ValueError: None
        # error: incomplete signature. letters outside of parenthesis are ignored
        msg = "core_sig: incomplete signature"
        try:
            ret = umt.test_signature(2, 1, "(i),->()")
            assert_equal(ret, None, err_msg=msg)
        except ValueError: None
        # error: incomplete signature. 2 output arguments are specified
        msg = "core_sig: incomplete signature"
        try:
            ret = umt.test_signature(2, 2, "(i),(i)->()")
            assert_equal(ret, None, err_msg=msg)
        except ValueError: None

        # more complicated names for variables
        assert_equal(umt.test_signature(2, 1, "(i1,i2),(J_1)->(_kAB)"), 1) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:39,代碼來源:test_ufunc.py

示例2: test_signature

# 需要導入模塊: from numpy.core import umath_tests [as 別名]
# 或者: from numpy.core.umath_tests import test_signature [as 別名]
def test_signature(self):
        # the arguments to test_signature are: nin, nout, core_signature
        # pass
        assert_equal(umt.test_signature(2, 1, "(i),(i)->()"), 1)

        # pass. empty core signature; treat as plain ufunc (with trivial core)
        assert_equal(umt.test_signature(2, 1, "(),()->()"), 0)

        # in the following calls, a ValueError should be raised because
        # of error in core signature
        # FIXME These should be using assert_raises

        # error: extra parenthesis
        msg = "core_sig: extra parenthesis"
        try:
            ret = umt.test_signature(2, 1, "((i)),(i)->()")
            assert_equal(ret, None, err_msg=msg)
        except ValueError:
            pass

        # error: parenthesis matching
        msg = "core_sig: parenthesis matching"
        try:
            ret = umt.test_signature(2, 1, "(i),)i(->()")
            assert_equal(ret, None, err_msg=msg)
        except ValueError:
            pass

        # error: incomplete signature. letters outside of parenthesis are ignored
        msg = "core_sig: incomplete signature"
        try:
            ret = umt.test_signature(2, 1, "(i),->()")
            assert_equal(ret, None, err_msg=msg)
        except ValueError:
            pass

        # error: incomplete signature. 2 output arguments are specified
        msg = "core_sig: incomplete signature"
        try:
            ret = umt.test_signature(2, 2, "(i),(i)->()")
            assert_equal(ret, None, err_msg=msg)
        except ValueError:
            pass

        # more complicated names for variables
        assert_equal(umt.test_signature(2, 1, "(i1,i2),(J_1)->(_kAB)"), 1) 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:48,代碼來源:test_ufunc.py


注:本文中的numpy.core.umath_tests.test_signature方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。