python类asinh()的实例源码

generator.py 文件源码 项目:duct 作者: ducted 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
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)
bezierTools.py 文件源码 项目:otRebuilder 作者: Pal3love 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def _intSecAtan(x):
    # In : sympy.integrate(sp.sec(sp.atan(x)))
    # Out: x*sqrt(x**2 + 1)/2 + asinh(x)/2
    return x * math.sqrt(x**2 + 1)/2 + math.asinh(x)/2
reciprocal.py 文件源码 项目:PyGLM 作者: Zuzu-Typ 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def acsch(x):
    if type(x) in dtypes:
        return math.asinh(1. / x)

    return functor1(acsch, x)
test_math.py 文件源码 项目:zippy 作者: securesystemslab 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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)))
test_math.py 文件源码 项目:oil 作者: oilshell 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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)))
test_math.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
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)))
test_math.py 文件源码 项目:web_ctp 作者: molebot 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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)))
sugar.py 文件源码 项目:hyper-engine 作者: maxim5 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def asinh(node): return merge([node], math.asinh)
test_math.py 文件源码 项目:pefile.pypy 作者: cloudtracer 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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)))
cmath.py 文件源码 项目:ouroboros 作者: pybee 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def acos(x):
    _acos_special = [
        [3*pi/4+infj, pi+infj, pi+infj, pi-infj, pi-infj, 3*pi/4-infj, nan+infj],
        [pi/2+infj, None, None, None, None, pi/2-infj, nan+nanj],
        [pi/2+infj, None, None, None, None, pi/2-infj, pi/2+nanj],
        [pi/2+infj, None, None, None, None, pi/2-infj, pi/2+nanj],
        [pi/2+infj, None, None, None, None, pi/2-infj, nan+nanj],
        [pi/4+infj, infj, infj, 0.0-infj, 0.0-infj, pi/4-infj, nan+infj],
        [nan+infj, nan+nanj, nan+nanj, nan+nanj, nan+nanj, nan-infj, nan+nanj]
    ]

    z = _make_complex(x)

    if not isfinite(z):
        return _acos_special[_special_type(z.real)][_special_type(z.imag)]

    if abs(z.real) > _LARGE_DOUBLE or abs(z.imag) > _LARGE_DOUBLE:
        if z.real < 0:
            imag = -math.copysign(math.log(math.hypot(z.real/2, z.imag/2)) +
                                  2 * _LOG_2, z.imag)
        else:
            imag = math.copysign(math.log(math.hypot(z.real/2, z.imag/2)) +
                                 2 * _LOG_2, -z.imag)
        return complex(math.atan2(abs(z.imag), z.real), imag)

    s1 = sqrt(complex(1.0 - z.real, -z.imag))
    s2 = sqrt(complex(1.0 + z.real, z.imag))
    return complex(2 * math.atan2(s1.real, s2.real),
                   math.asinh(s2.real*s1.imag - s2.imag*s1.real))
cmath.py 文件源码 项目:ouroboros 作者: pybee 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def asin(x):
    z = _make_complex(x)
    z = asinh(complex(-z.imag, z.real))
    return complex(z.imag, -z.real)
cmath.py 文件源码 项目:ouroboros 作者: pybee 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def acosh(x):
    z = _make_complex(x)

    if abs(z.real) > _LARGE_DOUBLE or abs(z.imag) > _LARGE_DOUBLE:
        return complex(math.log(math.hypot(z.real/2, z.imag/2)) + 2*_LOG_2,
                       math.atan2(z.imag, z.real))

    s1 = sqrt(complex(z.real-1, z.imag))
    s2 = sqrt(complex(z.real+1, z.imag))
    return complex(math.asinh(s1.real*s2.real + s1.imag*s2.imag),
                   2*math.atan2(s1.imag, s2.real))
cmath.py 文件源码 项目:ouroboros 作者: pybee 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def asinh(x):
    _asinh_special = [
        [-inf-1j*pi/4, complex(-float("inf"), -0.0), complex(-float("inf"), -0.0),
            complex(-float("inf"), 0.0), complex(-float("inf"), 0.0), -inf+1j*pi/4, -inf+nanj],
        [-inf-1j*pi/2, None, None, None, None, -inf+1j*pi/2, nan+nanj],
        [-inf-1j*pi/2, None, None, None, None, -inf+1j*pi/2, nan+nanj],
        [inf-1j*pi/2, None, None, None, None, inf+1j*pi/2, nan+nanj],
        [inf-1j*pi/2, None, None, None, None, inf+1j*pi/2, nan+nanj],
        [inf-1j*pi/4, complex(float("inf"), -0.0), complex(float("inf"), -0.0),
            inf, inf, inf+1j*pi/4, inf+nanj],
        [inf+nanj, nan+nanj, complex(float("nan"), -0.0), nan, nan+nanj, inf+nanj, nan+nanj]
    ]

    z = _make_complex(x)

    if not isfinite(z):
        return _asinh_special[_special_type(z.real)][_special_type(z.imag)]

    if abs(z.real) > _LARGE_DOUBLE or abs(z.imag) > _LARGE_DOUBLE:
        if z.imag >= 0:
            real = math.copysign(math.log(math.hypot(z.imag/2, z.real/2)) +
                                 2 * _LOG_2, z.real)
        else:
            real = -math.copysign(math.log(math.hypot(z.imag/2, z.real/2)) +
                                  2 * _LOG_2, -z.real)
        return complex(real, math.atan2(z.imag, abs(z.real)))

    s1 = sqrt(complex(1+z.imag, -z.real))
    s2 = sqrt(complex(1-z.imag, z.real))
    return complex(math.asinh(s1.real*s2.imag-s2.real*s1.imag),
                   math.atan2(z.imag, s1.real*s2.real - s1.imag*s2.imag))
test_math.py 文件源码 项目:ouroboros 作者: pybee 项目源码 文件源码 阅读 204 收藏 0 点赞 0 评论 0
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)))
test_math.py 文件源码 项目:ndk-python 作者: gittor 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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)))
test_math.py 文件源码 项目:kbe_server 作者: xiaohaoppy 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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)))
test_libstandard.py 文件源码 项目:femtocode 作者: diana-hep 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def test_asinh(self):
        self.assertEqual(session.source("Test", x=real(3.14, 6.5)).type("asinh(x)"), real(math.asinh(3.14), math.asinh(6.5)))
        self.assertEqual(session.source("Test", x=real(3.14, almost(6.5))).type("asinh(x)"), real(math.asinh(3.14), almost(math.asinh(6.5))))
        self.assertEqual(session.source("Test", x=real(3.14, inf)).type("asinh(x)"), real(math.asinh(3.14), inf))
        self.assertEqual(session.source("Test", x=real(3.14, almost(inf))).type("asinh(x)"), real(math.asinh(3.14), almost(inf)))
        self.assertEqual(session.source("Test", x=real).type("asinh(x)"), real)
        self.assertEqual(session.source("Test", x=extended).type("asinh(x)"), extended)
        for entry in numerical.toPython(y = "y", a = "asinh(y)").submit():
            self.assertEqual(entry.a, math.asinh(entry.y))
expr.py 文件源码 项目:pyomo 作者: Pyomo 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def asinh(arg):
    return generate_intrinsic_function_expression(arg, 'asinh', math.asinh)
bgelogic.py 文件源码 项目:bge-logic-nodes-add-on 作者: thepgi 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def __init__(self):
        ParameterCell.__init__(self)
        self.a = None
        self.b = None
        self.c = None
        self.d = None
        self.formula = ""
        self._previous_values = [None, None, None, None]
        self._formula_globals = globals();
        self._formula_locals = {
            "exp":math.exp,
            "pow":math.pow,
            "log":math.log,
            "log10":math.log10,
            "acos":math.acos,
            "asin":math.asin,
            "atan":math.atan,
            "atan2":math.atan2,
            "cos":math.cos,
            "hypot":math.hypot,
            "sin":math.sin,
            "tan":math.tan,
            "degrees":math.degrees,
            "radians":math.radians,
            "acosh":math.acosh,
            "asinh":math.asinh,
            "atanh":math.atanh,
            "cosh":math.cosh,
            "sinh":math.sinh,
            "tanh":math.tanh,
            "pi":math.pi,
            "e":math.e,
            "ceil":math.ceil,
            "sign":ParameterMathFun.signum,
            "abs":math.fabs,
            "floor":math.floor,
            "mod":math.fmod,
            "sqrt":math.sqrt,
            "curt":ParameterMathFun.curt,
            "str":str,
            "int":int,
            "float":float
        }
test_sparse_array.py 文件源码 项目:SparseArray 作者: INGEOTEC 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def test_one():
    from math import sin, cos, tan, asin, acos, atan
    from math import sinh, cosh, tanh, asinh, acosh, atanh
    from math import exp, expm1, log, log10, log1p, sqrt, lgamma
    from math import fabs, ceil, floor, trunc, erf, erfc
    try:
        from math import log2
    except ImportError:
        def log2(x):
            return log(x) / log(2)

    def wrapper(f, v):
        try:
            return f(v)
        except ValueError:
            if f == sqrt:
                return float('nan')
            if v >= 0:
                return float('inf')
            else:
                return -float('inf')

    def compare(a, b):
        if isfinite(a) and isfinite(b):
            return assert_almost_equals(a, b)
        return str(a) == str(b)

    for f in [sin, cos, tan, asin, acos, atan,
              sinh, cosh, tanh, asinh, acosh, atanh,
              exp, expm1, log, log2, log10, log1p, sqrt,
              lgamma,
              fabs, ceil, floor, trunc,
              erf, erfc]:
        for p in [0.5, 1]:
            a = random_lst(p=p)
            b = SparseArray.fromlist(a)
            c = getattr(b, f.__name__)()
            res = [wrapper(f, x) for x in a]
            index = [k for k, v in enumerate(res) if v != 0]
            res = [x for x in res if x != 0]
            print(f, p, c.non_zero, len(res))
            assert c.non_zero == len(res)
            [assert_almost_equals(v, w) for v, w in zip(index,
                                                        c.index)]
            [compare(v, w) for v, w in zip(res,
                                           c.data)]


问题


面经


文章

微信
公众号

扫码关注公众号