当前位置: 首页>>代码示例>>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;未经允许,请勿转载。