本文整理匯總了Python中numpy.NZERO屬性的典型用法代碼示例。如果您正苦於以下問題:Python numpy.NZERO屬性的具體用法?Python numpy.NZERO怎麽用?Python numpy.NZERO使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類numpy
的用法示例。
在下文中一共展示了numpy.NZERO屬性的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_constants
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import NZERO [as 別名]
def test_constants():
assert chainerx.Inf is numpy.Inf
assert chainerx.Infinity is numpy.Infinity
assert chainerx.NAN is numpy.NAN
assert chainerx.NINF is numpy.NINF
assert chainerx.NZERO is numpy.NZERO
assert chainerx.NaN is numpy.NaN
assert chainerx.PINF is numpy.PINF
assert chainerx.PZERO is numpy.PZERO
assert chainerx.e is numpy.e
assert chainerx.euler_gamma is numpy.euler_gamma
assert chainerx.inf is numpy.inf
assert chainerx.infty is numpy.infty
assert chainerx.nan is numpy.nan
assert chainerx.newaxis is numpy.newaxis
assert chainerx.pi is numpy.pi
示例2: test_negative_zero
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import NZERO [as 別名]
def test_negative_zero(self):
self._test_not_equal(np.PZERO, np.NZERO)
示例3: test_nan
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import NZERO [as 別名]
def test_nan(self):
# Test that nan is 'far' from small, tiny, inf, max and min
for dt in [np.float32, np.float64]:
if dt == np.float32:
maxulp = 1e6
else:
maxulp = 1e12
inf = np.array([np.inf]).astype(dt)
nan = np.array([np.nan]).astype(dt)
big = np.array([np.finfo(dt).max])
tiny = np.array([np.finfo(dt).tiny])
zero = np.array([np.PZERO]).astype(dt)
nzero = np.array([np.NZERO]).astype(dt)
assert_raises(AssertionError,
lambda: assert_array_max_ulp(nan, inf,
maxulp=maxulp))
assert_raises(AssertionError,
lambda: assert_array_max_ulp(nan, big,
maxulp=maxulp))
assert_raises(AssertionError,
lambda: assert_array_max_ulp(nan, tiny,
maxulp=maxulp))
assert_raises(AssertionError,
lambda: assert_array_max_ulp(nan, zero,
maxulp=maxulp))
assert_raises(AssertionError,
lambda: assert_array_max_ulp(nan, nzero,
maxulp=maxulp))
示例4: test_fabs
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import NZERO [as 別名]
def test_fabs(self):
# Test that np.abs(x +- 0j) == np.abs(x) (as mandated by C99 for cabs)
x = np.array([1+0j], dtype=complex)
assert_array_equal(np.abs(x), np.real(x))
x = np.array([complex(1, np.NZERO)], dtype=complex)
assert_array_equal(np.abs(x), np.real(x))
x = np.array([complex(np.inf, np.NZERO)], dtype=complex)
assert_array_equal(np.abs(x), np.real(x))
x = np.array([complex(np.nan, np.NZERO)], dtype=complex)
assert_array_equal(np.abs(x), np.real(x))
示例5: test_zero
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import NZERO [as 別名]
def test_zero(self):
# carg(-0 +- 0i) returns +- pi
check_real_value(ncu._arg, np.NZERO, np.PZERO, np.pi, False)
check_real_value(ncu._arg, np.NZERO, np.NZERO, -np.pi, False)
# carg(+0 +- 0i) returns +- 0
check_real_value(ncu._arg, np.PZERO, np.PZERO, np.PZERO)
check_real_value(ncu._arg, np.PZERO, np.NZERO, np.NZERO)
# carg(x +- 0i) returns +- 0 for x > 0
check_real_value(ncu._arg, 1, np.PZERO, np.PZERO, False)
check_real_value(ncu._arg, 1, np.NZERO, np.NZERO, False)
# carg(x +- 0i) returns +- pi for x < 0
check_real_value(ncu._arg, -1, np.PZERO, np.pi, False)
check_real_value(ncu._arg, -1, np.NZERO, -np.pi, False)
# carg(+- 0 + yi) returns pi/2 for y > 0
check_real_value(ncu._arg, np.PZERO, 1, 0.5 * np.pi, False)
check_real_value(ncu._arg, np.NZERO, 1, 0.5 * np.pi, False)
# carg(+- 0 + yi) returns -pi/2 for y < 0
check_real_value(ncu._arg, np.PZERO, -1, 0.5 * np.pi, False)
check_real_value(ncu._arg, np.NZERO, -1, -0.5 * np.pi, False)
#def test_branch_cuts(self):
# _check_branch_cut(ncu._arg, -1, 1j, -1, 1)
示例6: test_zero_nzero
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import NZERO [as 別名]
def test_zero_nzero(self):
# atan2(+-0, -0) returns +-pi.
assert_almost_equal(ncu.arctan2(np.PZERO, np.NZERO), np.pi)
assert_almost_equal(ncu.arctan2(np.NZERO, np.NZERO), -np.pi)
示例7: test_zero_pzero
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import NZERO [as 別名]
def test_zero_pzero(self):
# atan2(+-0, +0) returns +-0.
assert_arctan2_ispzero(np.PZERO, np.PZERO)
assert_arctan2_isnzero(np.NZERO, np.PZERO)
示例8: test_zero_negative
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import NZERO [as 別名]
def test_zero_negative(self):
# atan2(+-0, x) returns +-pi for x < 0.
assert_almost_equal(ncu.arctan2(np.PZERO, -1), np.pi)
assert_almost_equal(ncu.arctan2(np.NZERO, -1), -np.pi)
示例9: test_zero_positive
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import NZERO [as 別名]
def test_zero_positive(self):
# atan2(+-0, x) returns +-0 for x > 0.
assert_arctan2_ispzero(np.PZERO, 1)
assert_arctan2_isnzero(np.NZERO, 1)
示例10: test_positive_zero
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import NZERO [as 別名]
def test_positive_zero(self):
# atan2(y, +-0) returns +pi/2 for y > 0.
assert_almost_equal(ncu.arctan2(1, np.PZERO), 0.5 * np.pi)
assert_almost_equal(ncu.arctan2(1, np.NZERO), 0.5 * np.pi)
示例11: test_nan
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import NZERO [as 別名]
def test_nan(self):
# Test that nan is 'far' from small, tiny, inf, max and min
for dt in [np.float32, np.float64]:
if dt == np.float32:
maxulp = 1e6
else:
maxulp = 1e12
inf = np.array([np.inf]).astype(dt)
nan = np.array([np.nan]).astype(dt)
big = np.array([np.finfo(dt).max])
tiny = np.array([np.finfo(dt).tiny])
zero = np.array([np.PZERO]).astype(dt)
nzero = np.array([np.NZERO]).astype(dt)
self.assertRaises(AssertionError,
lambda: assert_array_max_ulp(nan, inf,
maxulp=maxulp))
self.assertRaises(AssertionError,
lambda: assert_array_max_ulp(nan, big,
maxulp=maxulp))
self.assertRaises(AssertionError,
lambda: assert_array_max_ulp(nan, tiny,
maxulp=maxulp))
self.assertRaises(AssertionError,
lambda: assert_array_max_ulp(nan, zero,
maxulp=maxulp))
self.assertRaises(AssertionError,
lambda: assert_array_max_ulp(nan, nzero,
maxulp=maxulp))
示例12: test_fabs
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import NZERO [as 別名]
def test_fabs(self):
# Test that np.abs(x +- 0j) == np.abs(x) (as mandated by C99 for cabs)
x = np.array([1+0j], dtype=np.complex)
assert_array_equal(np.abs(x), np.real(x))
x = np.array([complex(1, np.NZERO)], dtype=np.complex)
assert_array_equal(np.abs(x), np.real(x))
x = np.array([complex(np.inf, np.NZERO)], dtype=np.complex)
assert_array_equal(np.abs(x), np.real(x))
x = np.array([complex(np.nan, np.NZERO)], dtype=np.complex)
assert_array_equal(np.abs(x), np.real(x))
示例13: test_zero
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import NZERO [as 別名]
def test_zero(self):
# carg(-0 +- 0i) returns +- pi
yield check_real_value, ncu._arg, np.NZERO, np.PZERO, np.pi, False
yield check_real_value, ncu._arg, np.NZERO, np.NZERO, -np.pi, False
# carg(+0 +- 0i) returns +- 0
yield check_real_value, ncu._arg, np.PZERO, np.PZERO, np.PZERO
yield check_real_value, ncu._arg, np.PZERO, np.NZERO, np.NZERO
# carg(x +- 0i) returns +- 0 for x > 0
yield check_real_value, ncu._arg, 1, np.PZERO, np.PZERO, False
yield check_real_value, ncu._arg, 1, np.NZERO, np.NZERO, False
# carg(x +- 0i) returns +- pi for x < 0
yield check_real_value, ncu._arg, -1, np.PZERO, np.pi, False
yield check_real_value, ncu._arg, -1, np.NZERO, -np.pi, False
# carg(+- 0 + yi) returns pi/2 for y > 0
yield check_real_value, ncu._arg, np.PZERO, 1, 0.5 * np.pi, False
yield check_real_value, ncu._arg, np.NZERO, 1, 0.5 * np.pi, False
# carg(+- 0 + yi) returns -pi/2 for y < 0
yield check_real_value, ncu._arg, np.PZERO, -1, 0.5 * np.pi, False
yield check_real_value, ncu._arg, np.NZERO, -1, -0.5 * np.pi, False
#def test_branch_cuts(self):
# _check_branch_cut(ncu._arg, -1, 1j, -1, 1)