本文整理匯總了Python中numpy.csingle方法的典型用法代碼示例。如果您正苦於以下問題:Python numpy.csingle方法的具體用法?Python numpy.csingle怎麽用?Python numpy.csingle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類numpy
的用法示例。
在下文中一共展示了numpy.csingle方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_array
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import csingle [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)
示例2: test_basic
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import csingle [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)
示例3: assert_almost_equal
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import csingle [as 別名]
def assert_almost_equal(a, b, single_decimal=6, double_decimal=12, **kw):
if asarray(a).dtype.type in (single, csingle):
decimal = single_decimal
else:
decimal = double_decimal
old_assert_almost_equal(a, b, decimal=decimal, **kw)
示例4: get_real_dtype
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import csingle [as 別名]
def get_real_dtype(dtype):
return {single: single, double: double,
csingle: single, cdouble: double}[dtype]
示例5: get_complex_dtype
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import csingle [as 別名]
def get_complex_dtype(dtype):
return {single: csingle, double: cdouble,
csingle: csingle, cdouble: cdouble}[dtype]
示例6: test_precisions_consistent
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import csingle [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)
示例7: test_complex_scalar_warning
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import csingle [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))
示例8: test_complex_scalar_complex_cast
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import csingle [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)
示例9: test_complex_boolean_cast
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import csingle [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:]))
示例10: assert_almost_equal
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import csingle [as 別名]
def assert_almost_equal(a, b, **kw):
if asarray(a).dtype.type in (single, csingle):
decimal = 6
else:
decimal = 12
old_assert_almost_equal(a, b, decimal=decimal, **kw)
示例11: test_types
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import csingle [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