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


Python numpy.clongdouble方法代碼示例

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


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

示例1: test_sum_complex

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import clongdouble [as 別名]
def test_sum_complex(self):
        for dt in (np.complex64, np.complex128, np.clongdouble):
            for v in (0, 1, 2, 7, 8, 9, 15, 16, 19, 127,
                      128, 1024, 1235):
                tgt = dt(v * (v + 1) / 2) - dt((v * (v + 1) / 2) * 1j)
                d = np.empty(v, dtype=dt)
                d.real = np.arange(1, v + 1)
                d.imag = -np.arange(1, v + 1)
                assert_almost_equal(np.sum(d), tgt)
                assert_almost_equal(np.sum(d[::-1]), tgt)

            d = np.ones(500, dtype=dt) + 1j
            assert_almost_equal(np.sum(d[::2]), 250. + 250j)
            assert_almost_equal(np.sum(d[1::2]), 250. + 250j)
            assert_almost_equal(np.sum(d[::3]), 167. + 167j)
            assert_almost_equal(np.sum(d[1::3]), 167. + 167j)
            assert_almost_equal(np.sum(d[::-2]), 250. + 250j)
            assert_almost_equal(np.sum(d[-1::-2]), 250. + 250j)
            assert_almost_equal(np.sum(d[::-3]), 167. + 167j)
            assert_almost_equal(np.sum(d[-1::-3]), 167. + 167j)
            # sum with first reduction entry != 0
            d = np.ones((1,), dtype=dt) + 1j
            d += d
            assert_almost_equal(d, 2. + 2j) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:26,代碼來源:test_ufunc.py

示例2: test_complex_inf_nan

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import clongdouble [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

示例3: test_complex_inf_nan

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import clongdouble [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

示例4: test_complex_inf_nan

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import clongdouble [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():
            _check_complex_inf_nan(c, s, tp) 
開發者ID:Relph1119,項目名稱:GraphicDesignPatternByPython,代碼行數:25,代碼來源:test_print.py

示例5: test_complex_high_ord

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import clongdouble [as 別名]
def test_complex_high_ord(self):
        # gh-4156
        d = np.empty((2,), dtype=np.clongdouble)
        d[0] = 6 + 7j
        d[1] = -6 + 7j
        res = 11.615898132184
        old_assert_almost_equal(np.linalg.norm(d, ord=3), res, decimal=10)
        d = d.astype(np.complex128)
        old_assert_almost_equal(np.linalg.norm(d, ord=3), res, decimal=9)
        d = d.astype(np.complex64)
        old_assert_almost_equal(np.linalg.norm(d, ord=3), res, decimal=5)


# Separate definitions so we can use them for matrix tests. 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:16,代碼來源:test_linalg.py

示例6: test_scalar_format

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import clongdouble [as 別名]
def test_scalar_format():
    """Test the str.format method with NumPy scalar types"""
    tests = [('{0}', True, np.bool_),
            ('{0}', False, np.bool_),
            ('{0:d}', 130, np.uint8),
            ('{0:d}', 50000, np.uint16),
            ('{0:d}', 3000000000, np.uint32),
            ('{0:d}', 15000000000000000000, np.uint64),
            ('{0:d}', -120, np.int8),
            ('{0:d}', -30000, np.int16),
            ('{0:d}', -2000000000, np.int32),
            ('{0:d}', -7000000000000000000, np.int64),
            ('{0:g}', 1.5, np.float16),
            ('{0:g}', 1.5, np.float32),
            ('{0:g}', 1.5, np.float64),
            ('{0:g}', 1.5, np.longdouble),
            ('{0:g}', 1.5+0.5j, np.complex64),
            ('{0:g}', 1.5+0.5j, np.complex128),
            ('{0:g}', 1.5+0.5j, np.clongdouble)]

    for (fmat, val, valtype) in tests:
        try:
            assert_equal(fmat.format(val), fmat.format(valtype(val)),
                    "failed with val %s, type %s" % (val, valtype))
        except ValueError as e:
            assert_(False,
               "format raised exception (fmt='%s', val=%s, type=%s, exc='%s')" %
                            (fmat, repr(val), repr(valtype), str(e)))


#
# Locale tests: scalar types formatting should be independent of the locale
# 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:35,代碼來源:test_print.py

示例7: test_einsum_sums_clongdouble

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import clongdouble [as 別名]
def test_einsum_sums_clongdouble(self):
        self.check_einsum_sums(np.clongdouble) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:4,代碼來源:test_einsum.py

示例8: test_precisions_consistent

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import clongdouble [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

示例9: test_longdouble

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import clongdouble [as 別名]
def test_longdouble(self):
        assert_(np.sctypeDict['f8'] is not np.longdouble)
        assert_(np.sctypeDict['c16'] is not np.clongdouble) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:5,代碼來源:test_numerictypes.py

示例10: test_complex_scalar_warning

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import clongdouble [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 clongdouble [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 clongdouble [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_int_from_infinite_longdouble___int__

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import clongdouble [as 別名]
def test_int_from_infinite_longdouble___int__(self):
        x = np.longdouble(np.inf)
        assert_raises(OverflowError, x.__int__)
        with suppress_warnings() as sup:
            sup.record(np.ComplexWarning)
            x = np.clongdouble(np.inf)
            assert_raises(OverflowError, x.__int__)
            assert_equal(len(sup.log), 1) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:10,代碼來源:test_scalarmath.py

示例14: test_complex_high_ord

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import clongdouble [as 別名]
def test_complex_high_ord(self):
        # gh-4156
        d = np.empty((2,), dtype=np.clongdouble)
        d[0] = 6 + 7j
        d[1] = -6 + 7j
        res = 11.615898132184
        old_assert_almost_equal(np.linalg.norm(d, ord=3), res, decimal=10)
        d = d.astype(np.complex128)
        old_assert_almost_equal(np.linalg.norm(d, ord=3), res, decimal=9)
        d = d.astype(np.complex64)
        old_assert_almost_equal(np.linalg.norm(d, ord=3), res, decimal=5) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:13,代碼來源:test_linalg.py

示例15: test_complex_types

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import clongdouble [as 別名]
def test_complex_types():
    """Check formatting of complex types.

        This is only for the str function, and only for simple types.
        The precision of np.float and np.longdouble aren't the same as the
        python float precision.

    """
    for t in [np.complex64, np.cdouble, np.clongdouble]:
        yield check_complex_type, t 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:12,代碼來源:test_print.py


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