本文整理汇总了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)