Python math.atanh() Examples
The following are 30
code examples of math.atanh().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
math
, or try the search function
.
Example #1
Source File: test_math.py From ironpython2 with Apache License 2.0 | 7 votes |
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)
Example #2
Source File: temporal.py From vidaug with MIT License | 6 votes |
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
Example #3
Source File: macros.py From pyth with MIT License | 6 votes |
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)
Example #4
Source File: latitude.py From pymap3d with BSD 2-Clause "Simplified" License | 6 votes |
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
Example #5
Source File: generator.py From tensor with MIT License | 6 votes |
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)
Example #6
Source File: test_math.py From ironpython3 with Apache License 2.0 | 6 votes |
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)
Example #7
Source File: util.py From hyperbolic with MIT License | 5 votes |
def radialEuclidToPoincare(r): return 2 * math.atanh(r)
Example #8
Source File: test_math.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
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)))
Example #9
Source File: bllgamma.py From flavio with MIT License | 5 votes |
def dG2dsMN(s, par, B, ff, ff0, lep, wc): mlh = par['m_'+lep]/par['m_'+B] bq = meson_quark[B] label = bq+lep+lep pref = 16*prefactor(s, par, B, ff, lep, wc)*(par['f_'+B]/par['m_'+B]*abs(wc['C10_'+label])*mlh)**2/(1-s) return pref*(-8*sqrt(s-4*mlh**2)*sqrt(s)+4*atanh(sqrt(1-4*mlh**2/s))*(1+s-mlh**2*(1-s)**2))
Example #10
Source File: bllgamma.py From flavio with MIT License | 5 votes |
def dG12dsMN(s, par, B, ff, ff0, lep, wc): mlh = par['m_'+lep]/par['m_'+B] pref = 4*prefactor(s, par, B, ff, lep, wc)*par['f_'+B]/par['m_'+B]*(1-s) return pref*atanh(sqrt(1-4*mlh**2/s))*B120(s, par, B, ff, ff0, lep, wc)
Example #11
Source File: test_math.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
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)))
Example #12
Source File: geomath.py From qgis-shapetools-plugin with GNU General Public License v2.0 | 5 votes |
def atanh(x): """atanh(x) (missing from python 2.5.2)""" if sys.version_info > (2, 6): return math.atanh(x) y = abs(x) # Enforce odd parity y = Math.log1p(2 * y/(1 - y))/2 return -y if x < 0 else y
Example #13
Source File: test_math.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
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)))
Example #14
Source File: Hypercycle.py From hyperbolic with MIT License | 5 votes |
def fromHypercycleOffset(cls, hcycle, offset, unit=Circle(0,0,1)): dh = offset #dh = math.asinh(offset/2) if isinstance(hcycle.projShape, Circle): # May throw if bad geometry x1, y1, x2, y2 = intersection.circleCircle(hcycle.projShape, unit) cx, cy = hcycle.projShape.cx, hcycle.projShape.cy r, cw = hcycle.projShape.r, hcycle.projShape.cw if cw: x1, y1, x2, y2 = x2, y2, x1, y1 rc = math.hypot(cx, cy) deMid = rc - r dhMid = 2 * math.atanh(deMid) sign = -1 if cw else 1 t = math.tanh((dhMid + sign*dh)/2) xOff, yOff = t * cx / rc, t * cy / rc else: # May throw if bad geometry x1, y1, x2, y2 = intersection.lineCircle(hcycle.projShape, unit) lineAng = math.atan2(y2-y1, x2-x1) mx, my = (x1+x2)/2, (y1+y2)/2 # Midpoint if util.nearZero(mx) and util.nearZero(my): ang = math.atan2(y2-y1, x2-x1) + math.pi/2 else: ang = math.atan2(my, mx) # Test if the line goes clockwise around the origin cw = (ang - lineAng) % (math.pi*2) < math.pi rm = math.hypot(mx, my) deMid = rm dhMid = 2 * math.atanh(deMid) sign = 1 if cw else -1 t = math.tanh((dhMid + sign*dh)/2) xOff, yOff = t * math.cos(ang), t * math.sin(ang) return cls.fromPoints(x1, y1, x2, y2, xOff, yOff, segment=False, excludeMid=False)
Example #15
Source File: Point.py From hyperbolic with MIT License | 5 votes |
def __init__(self, x, y, hr=None, theta=None): self.x = x self.y = y # Hyperbolic polar coordinates if theta is None: theta = math.atan2(y, x) if hr is None: r = math.hypot(x, y) if self.isIdeal(): hr = float('inf') else: hr = 2 * math.atanh(r) self.theta = theta self.hr = hr
Example #16
Source File: test_math.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
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)))
Example #17
Source File: sugar.py From hyper-engine with Apache License 2.0 | 5 votes |
def atanh(node): return merge([node], math.atanh)
Example #18
Source File: test_math.py From android_universal with MIT License | 5 votes |
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)))
Example #19
Source File: util.py From exposure with MIT License | 5 votes |
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)
Example #20
Source File: corrstats.py From Azimuth with BSD 3-Clause "New" or "Revised" License | 5 votes |
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))
Example #21
Source File: MathLib.py From PyFlow with Apache License 2.0 | 5 votes |
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
Example #22
Source File: test_math.py From ironpython3 with Apache License 2.0 | 5 votes |
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)))
Example #23
Source File: transverse_mercator.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
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
Example #24
Source File: test_math.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
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)))
Example #25
Source File: Num.py From hask with BSD 2-Clause "Simplified" License | 5 votes |
def atanh(x): """ atanh :: Floating a => a -> a """ return Floating[x].atanh(x)
Example #26
Source File: Num.py From hask with BSD 2-Clause "Simplified" License | 5 votes |
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
Example #27
Source File: MathTestCases.py From ufora with Apache License 2.0 | 5 votes |
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))
Example #28
Source File: pure_math.py From ufora with Apache License 2.0 | 5 votes |
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)
Example #29
Source File: test_convert_to_jit.py From fastats with MIT License | 5 votes |
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
Example #30
Source File: test_math.py From oss-ftp with MIT License | 5 votes |
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)))