本文整理匯總了Python中numpy.core.umath.sign方法的典型用法代碼示例。如果您正苦於以下問題:Python umath.sign方法的具體用法?Python umath.sign怎麽用?Python umath.sign使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類numpy.core.umath
的用法示例。
在下文中一共展示了umath.sign方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_floor_division_signed_zero
# 需要導入模塊: from numpy.core import umath [as 別名]
# 或者: from numpy.core.umath import sign [as 別名]
def test_floor_division_signed_zero(self):
# Check that the sign bit is correctly set when dividing positive and
# negative zero by one.
x = np.zeros(10)
assert_equal(np.signbit(x//1), 0)
assert_equal(np.signbit((-x)//1), 1)
示例2: test_sign
# 需要導入模塊: from numpy.core import umath [as 別名]
# 或者: from numpy.core.umath import sign [as 別名]
def test_sign(self):
a = np.array([np.inf, -np.inf, np.nan, 0.0, 3.0, -3.0])
out = np.zeros(a.shape)
tgt = np.array([1., -1., np.nan, 0.0, 1.0, -1.0])
with np.errstate(invalid='ignore'):
res = ncu.sign(a)
assert_equal(res, tgt)
res = ncu.sign(a, out)
assert_equal(res, tgt)
assert_equal(out, tgt)
示例3: test_sign_dtype_object
# 需要導入模塊: from numpy.core import umath [as 別名]
# 或者: from numpy.core.umath import sign [as 別名]
def test_sign_dtype_object(self):
# In reference to github issue #6229
foo = np.array([-.1, 0, .1])
a = np.sign(foo.astype(object))
b = np.sign(foo)
assert_array_equal(a, b)
示例4: test_sign_dtype_nan_object
# 需要導入模塊: from numpy.core import umath [as 別名]
# 或者: from numpy.core.umath import sign [as 別名]
def test_sign_dtype_nan_object(self):
# In reference to github issue #6229
def test_nan():
foo = np.array([np.nan])
# FIXME: a not used
a = np.sign(foo.astype(object))
assert_raises(TypeError, test_nan)
示例5: test_sign_dtype_object
# 需要導入模塊: from numpy.core import umath [as 別名]
# 或者: from numpy.core.umath import sign [as 別名]
def test_sign_dtype_object(self):
# In reference to github issue #6229
foo = np.array([-.1, 0, .1])
a = np.sign(foo.astype(np.object))
b = np.sign(foo)
assert_array_equal(a, b)
示例6: test_sign_dtype_nan_object
# 需要導入模塊: from numpy.core import umath [as 別名]
# 或者: from numpy.core.umath import sign [as 別名]
def test_sign_dtype_nan_object(self):
# In reference to github issue #6229
def test_nan():
foo = np.array([np.nan])
a = np.sign(foo.astype(np.object))
assert_raises(TypeError, test_nan)
示例7: test_sign_dtype_nan_object
# 需要導入模塊: from numpy.core import umath [as 別名]
# 或者: from numpy.core.umath import sign [as 別名]
def test_sign_dtype_nan_object(self):
# In reference to github issue #6229
def test_nan():
foo = np.array([np.nan])
a = np.sign(foo.astype(object))
assert_raises(TypeError, test_nan)