本文整理汇总了Python中math.asinh方法的典型用法代码示例。如果您正苦于以下问题:Python math.asinh方法的具体用法?Python math.asinh怎么用?Python math.asinh使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类math
的用法示例。
在下文中一共展示了math.asinh方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_math_subclass
# 需要导入模块: import math [as 别名]
# 或者: from math import asinh [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 asinh [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 asinh [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: geodetic2isometric_point
# 需要导入模块: import math [as 别名]
# 或者: from math import asinh [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
示例5: compute_radius
# 需要导入模块: import math [as 别名]
# 或者: from math import asinh [as 别名]
def compute_radius(H_p):
return K * math.asinh(math.sqrt(H_p / (2 * math.pi * K * K)))
示例6: testAsinh
# 需要导入模块: import math [as 别名]
# 或者: from math import asinh [as 别名]
def testAsinh(self):
self.assertRaises(TypeError, math.asinh)
self.ftest('asinh(0)', math.asinh(0), 0)
self.ftest('asinh(1)', math.asinh(1), 0.88137358701954305)
self.ftest('asinh(-1)', math.asinh(-1), -0.88137358701954305)
self.assertEqual(math.asinh(INF), INF)
self.assertEqual(math.asinh(NINF), NINF)
self.assertTrue(math.isnan(math.asinh(NAN)))
示例7: test_gh1284
# 需要导入模块: import math [as 别名]
# 或者: from math import asinh [as 别名]
def test_gh1284(self):
import math
self.assertEqual(round(math.asinh(4.),12),round(math.log(math.sqrt(17.)+4.),12))
self.assertEqual(round(math.asinh(.4),12),round(math.log(math.sqrt(1.16)+.4),12))
self.assertEqual(round(math.asinh(-.5),12),round(math.log(math.sqrt(1.25)-.5),12))
self.assertEqual(round(math.asinh(-6.),12),round(math.log(math.sqrt(37.)-6.),12))
示例8: testAsinhFunction
# 需要导入模块: import math [as 别名]
# 或者: from math import asinh [as 别名]
def testAsinhFunction(self):
ma5 = MovingAverage(5, 'close')
holder = Asinh(ma5)
for i, close in enumerate(self.sampleClose):
data = {'close': close}
ma5.push(data)
holder.push(data)
expected = math.asinh(ma5.result())
calculated = holder.result()
self.assertAlmostEqual(calculated, expected, 12, "at index {0:d}\n"
"expected: {1:f}\n"
"calculated: {2:f}".format(i, expected, calculated))
示例9: __call__
# 需要导入模块: import math [as 别名]
# 或者: from math import asinh [as 别名]
def __call__(self, val):
if val < 1.0:
raise ValueError("math domain error")
return __inline_fora(
"""fun(@unnamed_args:(val), *args) {
PyFloat(math.asinh(val.@m))
}"""
)(val)
示例10: test_pure_python_math_module
# 需要导入模块: import math [as 别名]
# 或者: from math import asinh [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 asinh [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: asinh
# 需要导入模块: import math [as 别名]
# 或者: from math import asinh [as 别名]
def asinh(x):
"""
asinh :: Floating a => a -> a
"""
return Floating[x].asinh(x)
示例13: ToolFreq2Bark
# 需要导入模块: import math [as 别名]
# 或者: from math import asinh [as 别名]
def ToolFreq2Bark(fInHz, cModel = 'Schroeder'):
def acaSchroeder_scalar(f):
return 7 * math.asinh(f/650)
def acaTerhardt_scalar(f):
return 13.3 * math.atan(0.75 * f/1000)
def acaZwicker_scalar(f):
return 13 * math.atan(0.76 * f/1000) + 3.5 * math.atan(f/7500)
def acaTraunmuller_scalar(f):
return 26.81/(1+1960./f) - 0.53
f = np.asarray(fInHz)
if f.ndim == 0:
if cModel == 'Terhardt':
return acaTerhardt_scalar(f)
elif cModel == 'Zwicker':
return acaZwicker_scalar(f)
elif cModel == 'Traunmuller':
return acaTraunmuller_scalar(f)
else:
return acaSchroeder_scalar(f)
fBark = np.zeros(f.shape)
if cModel == 'Terhardt':
for k,fi in enumerate(f):
fBark[k] = acaTerhardt_scalar(fi)
elif cModel == 'Zwicker':
for k,fi in enumerate(f):
fBark[k] = acaZwicker_scalar(fi)
elif cModel == 'Traunmuller':
for k,fi in enumerate(f):
fBark[k] = acaTraunmuller_scalar(fi)
else:
for k,fi in enumerate(f):
fBark[k] = acaSchroeder_scalar(fi)
return (fBark)
示例14: asinh
# 需要导入模块: import math [as 别名]
# 或者: from math import asinh [as 别名]
def asinh(x=('FloatPin', 0.0)):
'''Return the inverse hyperbolic sine of x.'''
return math.asinh(x)
示例15: render
# 需要导入模块: import math [as 别名]
# 或者: from math import asinh [as 别名]
def render(self):
# Open US map.
us_map = Image.open(MAP_FILE)
# Convert latitudes to a linear form.
self.lat1 = AreaMap.LAT_MAX - math.asinh(math.tan(math.radians(self.lat1)))
self.lat2 = AreaMap.LAT_MAX - math.asinh(math.tan(math.radians(self.lat2)))
# Calculate x-coords using a ratio of a known location on the map.
x1 = (self.lon1 + 130.781250) * 7162 / 39.34135
x2 = (self.lon2 + 130.781250) * 7162 / 39.34135
# Use another ratio of a known location to find the latitudes.
den = AreaMap.LAT_MAX - AreaMap.REF_LAT
y1 = self.lat1 * 3565 / den
y2 = self.lat2 * 3565 / den
# Crop the map.
cropped = us_map.crop((
int(x1),
int(y1),
int(x2),
int(y2)
))
# Resize to 900x900, convert to right format, and save.
self.map = cropped.resize((900, 900))
self.map = self.map.convert('RGBA')
name = '{0}.png'.format(self.area_id)
self.map.save(os.path.join(MAPS, name))
# Get an area map for the predefined area.