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


Python numpy.cdouble方法代碼示例

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


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

示例1: do

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import cdouble [as 別名]
def do(self, a, b, tags):
        d = linalg.det(a)
        (s, ld) = linalg.slogdet(a)
        if asarray(a).dtype.type in (single, double):
            ad = asarray(a).astype(double)
        else:
            ad = asarray(a).astype(cdouble)
        ev = linalg.eigvals(ad)
        assert_almost_equal(d, multiply.reduce(ev, axis=-1))
        assert_almost_equal(s * np.exp(ld), multiply.reduce(ev, axis=-1))

        s = np.atleast_1d(s)
        ld = np.atleast_1d(ld)
        m = (s != 0)
        assert_almost_equal(np.abs(s[m]), 1)
        assert_equal(ld[~m], -inf) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:18,代碼來源:test_linalg.py

示例2: do

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import cdouble [as 別名]
def do(self, a, b):
        d = linalg.det(a)
        (s, ld) = linalg.slogdet(a)
        if asarray(a).dtype.type in (single, double):
            ad = asarray(a).astype(double)
        else:
            ad = asarray(a).astype(cdouble)
        ev = linalg.eigvals(ad)
        assert_almost_equal(d, multiply.reduce(ev, axis=-1))
        assert_almost_equal(s * np.exp(ld), multiply.reduce(ev, axis=-1))

        s = np.atleast_1d(s)
        ld = np.atleast_1d(ld)
        m = (s != 0)
        assert_almost_equal(np.abs(s[m]), 1)
        assert_equal(ld[~m], -inf) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:18,代碼來源:test_linalg.py

示例3: test_complex_inf_nan

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import cdouble [as 別名]
def test_complex_inf_nan():
    """Check inf/nan formatting of complex types."""
    TESTS = {
        complex(np.inf, 0): "(inf+0j)",
        complex(0, np.inf): "inf*j",
        complex(-np.inf, 0): "(-inf+0j)",
        complex(0, -np.inf): "-inf*j",
        complex(np.inf, 1): "(inf+1j)",
        complex(1, np.inf): "(1+inf*j)",
        complex(-np.inf, 1): "(-inf+1j)",
        complex(1, -np.inf): "(1-inf*j)",
        complex(np.nan, 0): "(nan+0j)",
        complex(0, np.nan): "nan*j",
        complex(-np.nan, 0): "(nan+0j)",
        complex(0, -np.nan): "nan*j",
        complex(np.nan, 1): "(nan+1j)",
        complex(1, np.nan): "(1+nan*j)",
        complex(-np.nan, 1): "(nan+1j)",
        complex(1, -np.nan): "(1+nan*j)",
    }
    for tp in [np.complex64, np.cdouble, np.clongdouble]:
        for c, s in TESTS.items():
            yield _check_complex_inf_nan, c, s, tp 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:25,代碼來源:test_print.py

示例4: test_complex_inf_nan

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import cdouble [as 別名]
def test_complex_inf_nan():
    """Check inf/nan formatting of complex types."""
    TESTS = {
        complex(np.inf, 0): "(inf+0j)",
        complex(0, np.inf): "infj",
        complex(-np.inf, 0): "(-inf+0j)",
        complex(0, -np.inf): "-infj",
        complex(np.inf, 1): "(inf+1j)",
        complex(1, np.inf): "(1+infj)",
        complex(-np.inf, 1): "(-inf+1j)",
        complex(1, -np.inf): "(1-infj)",
        complex(np.nan, 0): "(nan+0j)",
        complex(0, np.nan): "nanj",
        complex(-np.nan, 0): "(nan+0j)",
        complex(0, -np.nan): "nanj",
        complex(np.nan, 1): "(nan+1j)",
        complex(1, np.nan): "(1+nanj)",
        complex(-np.nan, 1): "(nan+1j)",
        complex(1, -np.nan): "(1+nanj)",
    }
    for tp in [np.complex64, np.cdouble, np.clongdouble]:
        for c, s in TESTS.items():
            yield _check_complex_inf_nan, c, s, tp 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:25,代碼來源:test_print.py

示例5: test_array

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import cdouble [as 別名]
def test_array(self):
        a = np.array([], float)
        self.check_roundtrips(a)

        a = np.array([[1, 2], [3, 4]], float)
        self.check_roundtrips(a)

        a = np.array([[1, 2], [3, 4]], int)
        self.check_roundtrips(a)

        a = np.array([[1 + 5j, 2 + 6j], [3 + 7j, 4 + 8j]], dtype=np.csingle)
        self.check_roundtrips(a)

        a = np.array([[1 + 5j, 2 + 6j], [3 + 7j, 4 + 8j]], dtype=np.cdouble)
        self.check_roundtrips(a) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:17,代碼來源:test_io.py

示例6: test_basic

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import cdouble [as 別名]
def test_basic(self):
        ai32 = np.array([[1, 2], [3, 4]], dtype=np.int32)
        af16 = np.array([[1, 2], [3, 4]], dtype=np.float16)
        af32 = np.array([[1, 2], [3, 4]], dtype=np.float32)
        af64 = np.array([[1, 2], [3, 4]], dtype=np.float64)
        acs = np.array([[1+5j, 2+6j], [3+7j, 4+8j]], dtype=np.csingle)
        acd = np.array([[1+5j, 2+6j], [3+7j, 4+8j]], dtype=np.cdouble)
        assert_(common_type(ai32) == np.float64)
        assert_(common_type(af16) == np.float16)
        assert_(common_type(af32) == np.float32)
        assert_(common_type(af64) == np.float64)
        assert_(common_type(acs) == np.csingle)
        assert_(common_type(acd) == np.cdouble) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:15,代碼來源:test_type_check.py

示例7: get_real_dtype

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import cdouble [as 別名]
def get_real_dtype(dtype):
    return {single: single, double: double,
            csingle: single, cdouble: double}[dtype] 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:5,代碼來源:test_linalg.py

示例8: get_complex_dtype

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import cdouble [as 別名]
def get_complex_dtype(dtype):
    return {single: csingle, double: cdouble,
            csingle: csingle, cdouble: cdouble}[dtype] 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:5,代碼來源:test_linalg.py

示例9: test_precisions_consistent

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import cdouble [as 別名]
def test_precisions_consistent(self):
        z = 1 + 1j
        for f in self.funcs:
            fcf = f(np.csingle(z))
            fcd = f(np.cdouble(z))
            fcl = f(np.clongdouble(z))
            assert_almost_equal(fcf, fcd, decimal=6, err_msg='fch-fcd %s' % f)
            assert_almost_equal(fcl, fcd, decimal=15, err_msg='fch-fcl %s' % f) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:10,代碼來源:test_umath.py

示例10: test_complex_scalar_warning

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import cdouble [as 別名]
def test_complex_scalar_warning(self):
        for tp in [np.csingle, np.cdouble, np.clongdouble]:
            x = tp(1+2j)
            assert_warns(np.ComplexWarning, float, x)
            with suppress_warnings() as sup:
                sup.filter(np.ComplexWarning)
                assert_equal(float(x), float(x.real)) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:9,代碼來源:test_regression.py

示例11: test_complex_scalar_complex_cast

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import cdouble [as 別名]
def test_complex_scalar_complex_cast(self):
        for tp in [np.csingle, np.cdouble, np.clongdouble]:
            x = tp(1+2j)
            assert_equal(complex(x), 1+2j) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:6,代碼來源:test_regression.py

示例12: test_complex_boolean_cast

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import cdouble [as 別名]
def test_complex_boolean_cast(self):
        # Ticket #2218
        for tp in [np.csingle, np.cdouble, np.clongdouble]:
            x = np.array([0, 0+0.5j, 0.5+0j], dtype=tp)
            assert_equal(x.astype(bool), np.array([0, 1, 1], dtype=bool))
            assert_(np.any(x))
            assert_(np.all(x[1:])) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:9,代碼來源:test_regression.py

示例13: test_types

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import cdouble [as 別名]
def test_types(self):
        def check(dtype):
            x = np.array([[1, 0.5], [0.5, 1]], dtype=dtype)
            assert_equal(linalg.solve(x, x).dtype, dtype)
        for dtype in [single, double, csingle, cdouble]:
            yield check, dtype 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:8,代碼來源:test_linalg.py

示例14: test_zero

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import cdouble [as 別名]
def test_zero(self):
        assert_equal(linalg.det([[0.0]]), 0.0)
        assert_equal(type(linalg.det([[0.0]])), double)
        assert_equal(linalg.det([[0.0j]]), 0.0)
        assert_equal(type(linalg.det([[0.0j]])), cdouble)

        assert_equal(linalg.slogdet([[0.0]]), (0.0, -inf))
        assert_equal(type(linalg.slogdet([[0.0]])[0]), double)
        assert_equal(type(linalg.slogdet([[0.0]])[1]), double)
        assert_equal(linalg.slogdet([[0.0j]]), (0.0j, -inf))
        assert_equal(type(linalg.slogdet([[0.0j]])[0]), cdouble)
        assert_equal(type(linalg.slogdet([[0.0j]])[1]), double) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:14,代碼來源:test_linalg.py


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