本文整理匯總了Python中numpy.core.umath.hypot方法的典型用法代碼示例。如果您正苦於以下問題:Python umath.hypot方法的具體用法?Python umath.hypot怎麽用?Python umath.hypot使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類numpy.core.umath
的用法示例。
在下文中一共展示了umath.hypot方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_simple
# 需要導入模塊: from numpy.core import umath [as 別名]
# 或者: from numpy.core.umath import hypot [as 別名]
def test_simple(self):
assert_almost_equal(ncu.hypot(1, 1), ncu.sqrt(2))
assert_almost_equal(ncu.hypot(0, 0), 0)
示例2: test_reduce
# 需要導入模塊: from numpy.core import umath [as 別名]
# 或者: from numpy.core.umath import hypot [as 別名]
def test_reduce(self):
assert_almost_equal(ncu.hypot.reduce([3.0, 4.0]), 5.0)
assert_almost_equal(ncu.hypot.reduce([3.0, 4.0, 0]), 5.0)
assert_almost_equal(ncu.hypot.reduce([9.0, 12.0, 20.0]), 25.0)
assert_equal(ncu.hypot.reduce([]), 0.0)
示例3: assert_hypot_isnan
# 需要導入模塊: from numpy.core import umath [as 別名]
# 或者: from numpy.core.umath import hypot [as 別名]
def assert_hypot_isnan(x, y):
with np.errstate(invalid='ignore'):
assert_(np.isnan(ncu.hypot(x, y)),
"hypot(%s, %s) is %s, not nan" % (x, y, ncu.hypot(x, y)))
示例4: assert_hypot_isinf
# 需要導入模塊: from numpy.core import umath [as 別名]
# 或者: from numpy.core.umath import hypot [as 別名]
def assert_hypot_isinf(x, y):
with np.errstate(invalid='ignore'):
assert_(np.isinf(ncu.hypot(x, y)),
"hypot(%s, %s) is %s, not inf" % (x, y, ncu.hypot(x, y)))
示例5: test_no_fpe
# 需要導入模塊: from numpy.core import umath [as 別名]
# 或者: from numpy.core.umath import hypot [as 別名]
def test_no_fpe(self):
assert_no_warnings(ncu.hypot, np.inf, 0)