本文整理汇总了Python中math.atanh方法的典型用法代码示例。如果您正苦于以下问题:Python math.atanh方法的具体用法?Python math.atanh怎么用?Python math.atanh使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类math
的用法示例。
在下文中一共展示了math.atanh方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_math_subclass
# 需要导入模块: import math [as 别名]
# 或者: from math import atanh [as 别名]
def test_math_subclass(self):
"""verify subtypes of float/long work w/ math functions"""
import math
class myfloat(float): pass
class mylong(long): pass
mf = myfloat(1)
ml = mylong(1)
for x in math.log, math.log10, math.log1p, math.asinh, math.acosh, math.atanh, math.factorial, math.trunc, math.isinf:
try:
resf = x(mf)
except ValueError:
resf = None
try:
resl = x(ml)
except ValueError:
resl = None
self.assertEqual(resf, resl)
示例2: trig
# 需要导入模块: import math [as 别名]
# 或者: from math import atanh [as 别名]
def trig(a, b=' '):
if is_num(a) and isinstance(b, int):
funcs = [math.sin, math.cos, math.tan,
math.asin, math.acos, math.atan,
math.degrees, math.radians,
math.sinh, math.cosh, math.tanh,
math.asinh, math.acosh, math.atanh]
return funcs[b](a)
if is_lst(a):
width = max(len(row) for row in a)
padded_matrix = [list(row) + (width - len(row)) * [b] for row in a]
transpose = list(zip(*padded_matrix))
if all(isinstance(row, str) for row in a) and isinstance(b, str):
normalizer = ''.join
else:
normalizer = list
norm_trans = [normalizer(padded_row) for padded_row in transpose]
return norm_trans
return unknown_types(trig, ".t", a, b)
示例3: get
# 需要导入模块: import math [as 别名]
# 或者: from math import atanh [as 别名]
def get(self):
self.x += self.config.get('dx', 0.1)
val = eval(self.config.get('function', 'sin(x)'), {
'sin': math.sin,
'sinh': math.sinh,
'cos': math.cos,
'cosh': math.cosh,
'tan': math.tan,
'tanh': math.tanh,
'asin': math.asin,
'acos': math.acos,
'atan': math.atan,
'asinh': math.asinh,
'acosh': math.acosh,
'atanh': math.atanh,
'log': math.log,
'abs': abs,
'e': math.e,
'pi': math.pi,
'x': self.x
})
return self.createEvent('ok', 'Sine wave', val)
示例4: _get_distorted_indices
# 需要导入模块: import math [as 别名]
# 或者: from math import atanh [as 别名]
def _get_distorted_indices(self, nb_images):
inverse = random.randint(0, 1)
if inverse:
scale = random.random()
scale *= 0.21
scale += 0.6
else:
scale = random.random()
scale *= 0.6
scale += 0.8
frames_per_clip = nb_images
indices = np.linspace(-scale, scale, frames_per_clip).tolist()
if inverse:
values = [math.atanh(x) for x in indices]
else:
values = [math.tanh(x) for x in indices]
values = [x / values[-1] for x in values]
values = [int(round(((x + 1) / 2) * (frames_per_clip - 1), 0)) for x in values]
return values
示例5: geodetic2isometric_point
# 需要导入模块: import math [as 别名]
# 或者: from math import atanh [as 别名]
def geodetic2isometric_point(geodetic_lat: float, ell: Ellipsoid = None, deg: bool = True) -> float:
geodetic_lat, ell = sanitize(geodetic_lat, ell, deg)
e = ell.eccentricity
if abs(geodetic_lat - pi / 2) <= 1e-9:
isometric_lat = inf
elif abs(-geodetic_lat - pi / 2) <= 1e-9:
isometric_lat = -inf
else:
isometric_lat = asinh(tan(geodetic_lat)) - e * atanh(e * sin(geodetic_lat))
# same results
# a1 = e * sin(geodetic_lat)
# y = (1 - a1) / (1 + a1)
# a2 = pi / 4 + geodetic_lat / 2
# isometric_lat = log(tan(a2) * (y ** (e / 2)))
# isometric_lat = log(tan(a2)) + e/2 * log((1-e*sin(geodetic_lat)) / (1+e*sin(geodetic_lat)))
return degrees(isometric_lat) if deg else isometric_lat
示例6: tanh_range
# 需要导入模块: import math [as 别名]
# 或者: from math import atanh [as 别名]
def tanh_range(l, r, initial=None):
def get_activation(left, right, initial):
def activation(x):
if initial is not None:
bias = math.atanh(2 * (initial - left) / (right - left) - 1)
else:
bias = 0
return tanh01(x + bias) * (right - left) + left
return activation
return get_activation(l, r, initial)
示例7: testAtanh
# 需要导入模块: import math [as 别名]
# 或者: from math import atanh [as 别名]
def testAtanh(self):
self.assertRaises(TypeError, math.atan)
self.ftest('atanh(0)', math.atanh(0), 0)
self.ftest('atanh(0.5)', math.atanh(0.5), 0.54930614433405489)
self.ftest('atanh(-0.5)', math.atanh(-0.5), -0.54930614433405489)
self.assertRaises(ValueError, math.atanh, 1)
self.assertRaises(ValueError, math.atanh, -1)
self.assertRaises(ValueError, math.atanh, INF)
self.assertRaises(ValueError, math.atanh, NINF)
self.assertTrue(math.isnan(math.atanh(NAN)))
示例8: test_does_not_convert_math_builtins
# 需要导入模块: import math [as 别名]
# 或者: from math import atanh [as 别名]
def test_does_not_convert_math_builtins():
for func in (math.atan2, math.atanh, math.degrees, math.exp, math.floor, math.log,
math.sin, math.sinh, math.tan, math.tanh):
assert convert_to_jit(func) is func
示例9: __call__
# 需要导入模块: import math [as 别名]
# 或者: from math import atanh [as 别名]
def __call__(self, val):
if val >= 1:
raise ValueError("math domain error")
return __inline_fora(
"""fun(@unnamed_args:(val), *args) {
PyFloat(math.atanh(val.@m))
}"""
)(val)
示例10: test_pure_python_math_module
# 需要导入模块: import math [as 别名]
# 或者: from math import atanh [as 别名]
def test_pure_python_math_module(self):
vals = [1, -.5, 1.5, 0, 0.0, -2, -2.2, .2]
# not being tested: math.asinh, math.atanh, math.lgamma, math.erfc, math.acos
def f():
functions = [
math.sqrt, math.cos, math.sin, math.tan, math.asin, math.atan,
math.acosh, math.cosh, math.sinh, math.tanh, math.ceil,
math.erf, math.exp, math.expm1, math.factorial, math.floor,
math.log, math.log10, math.log1p
]
tr = []
for idx1 in range(len(vals)):
v1 = vals[idx1]
for funIdx in range(len(functions)):
function = functions[funIdx]
try:
tr = tr + [function(v1)]
except ValueError as ex:
pass
return tr
r1 = self.evaluateWithExecutor(f)
r2 = f()
self.assertGreater(len(r1), 100)
self.assertTrue(numpy.allclose(r1, r2, 1e-6))
示例11: make_instance
# 需要导入模块: import math [as 别名]
# 或者: from math import atanh [as 别名]
def make_instance(typeclass, cls, pi, exp, sqrt, log, pow, logBase, sin,
tan, cos, asin, atan, acos, sinh, tanh, cosh, asinh, atanh, acosh):
attrs = {"pi":pi, "exp":exp, "sqrt":sqrt, "log":log, "pow":pow,
"logBase":logBase, "sin":sin, "tan":tan, "cos":cos,
"asin":asin, "atan":atan, "acos":acos, "sinh":sinh,
"tanh":tanh, "cosh":cosh, "asinh":asinh, "atanh":atanh,
"acosh":acosh}
build_instance(Floating, cls, attrs)
return
示例12: atanh
# 需要导入模块: import math [as 别名]
# 或者: from math import atanh [as 别名]
def atanh(x):
"""
atanh :: Floating a => a -> a
"""
return Floating[x].atanh(x)
示例13: fromGeographic
# 需要导入模块: import math [as 别名]
# 或者: from math import atanh [as 别名]
def fromGeographic(self, lat, lon):
lat_rad = radians(lat)
lon_rad = radians(lon)
B = cos(lat_rad) * sin(lon_rad - self.lon_rad)
x = self.radius * atanh(B)
y = self.radius * (atan(tan(lat_rad) / cos(lon_rad - self.lon_rad)) - self.lat_rad)
return x, y
示例14: atanh
# 需要导入模块: import math [as 别名]
# 或者: from math import atanh [as 别名]
def atanh(x=('FloatPin', 0.0), Result=(REF, ('BoolPin', False))):
'''Return the inverse hyperbolic tangent of `x`.'''
try:
Result(True)
return math.atanh(x)
except:
Result(False)
return -1
示例15: rz_ci
# 需要导入模块: import math [as 别名]
# 或者: from math import atanh [as 别名]
def rz_ci(r, n, conf_level = 0.95):
zr_se = pow(1/(n - 3), .5)
moe = norm.ppf(1 - (1 - conf_level)/float(2)) * zr_se
zu = atanh(r) + moe
zl = atanh(r) - moe
return tanh((zl, zu))