python类atanh()的实例源码

generator.py 文件源码 项目:duct 作者: ducted 项目源码 文件源码 阅读 37 收藏 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)
geomath.py 文件源码 项目:qgis-shapetools-plugin 作者: NationalSecurityAgency 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
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
transverse_mercator.py 文件源码 项目:bpy_lambda 作者: bcongdon 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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
reciprocal.py 文件源码 项目:PyGLM 作者: Zuzu-Typ 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def acoth(x):
    if type(x) in dtypes:
        return math.atanh(1. / x)

    return functor1(acoth, x)
test_math.py 文件源码 项目:zippy 作者: securesystemslab 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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)))
test_math.py 文件源码 项目:oil 作者: oilshell 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
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)))
test_math.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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)))
test_math.py 文件源码 项目:web_ctp 作者: molebot 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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)))
sugar.py 文件源码 项目:hyper-engine 作者: maxim5 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def atanh(node): return merge([node], math.atanh)
transverse_mercator.py 文件源码 项目:blender-addons 作者: scorpion81 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
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
corrstats.py 文件源码 项目:biling-survey 作者: shyamupa 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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))
test_math.py 文件源码 项目:pefile.pypy 作者: cloudtracer 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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)))
test_math.py 文件源码 项目:ouroboros 作者: pybee 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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)))
test_math.py 文件源码 项目:ndk-python 作者: gittor 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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)))
test_math.py 文件源码 项目:kbe_server 作者: xiaohaoppy 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
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)))
test_libstandard.py 文件源码 项目:femtocode 作者: diana-hep 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def test_atanh(self):
        self.assertEqual(session.source("Test", x=real(0.1, 0.5)).type("atanh(x)"), real(math.atanh(0.1), math.atanh(0.5)))
        self.assertEqual(session.source("Test", x=real(0.1, almost(0.5))).type("atanh(x)"), real(math.atanh(0.1), almost(math.atanh(0.5))))
        self.assertEqual(session.source("Test", x=real(0.1, 1.0)).type("atanh(x)"), real(math.atanh(0.1), inf))
        self.assertEqual(session.source("Test", x=real(0.1, almost(1.0))).type("atanh(x)"), real(math.atanh(0.1), almost(inf)))
        self.assertEqual(session.source("Test", x=real(-1.0, 0.5)).type("atanh(x)"), real(-inf, math.atanh(0.5)))
        self.assertEqual(session.source("Test", x=real(almost(-1.0), 0.5)).type("atanh(x)"), real(almost(-inf), math.atanh(0.5)))
        self.assertRaises(FemtocodeError, lambda: session.source("Test", x=real(0.1, 1.1)).type("atanh(x)"))
        self.assertRaises(FemtocodeError, lambda: session.source("Test", x=real(0.1, almost(1.1))).type("atanh(x)"))
        self.assertRaises(FemtocodeError, lambda: session.source("Test", x=real(-1.1, 0.5)).type("atanh(x)"))
        self.assertRaises(FemtocodeError, lambda: session.source("Test", x=real(almost(-1.1), 0.5)).type("atanh(x)"))
        for entry in numerical.toPython(ylim2 = "ylim2", a = "atanh(ylim2 / 10)").submit():
            self.assertEqual(entry.a, math.atanh(entry.ylim2 / 10))
expr.py 文件源码 项目:pyomo 作者: Pyomo 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def atanh(arg):
    return generate_intrinsic_function_expression(arg, 'atanh', math.atanh)
task3.py 文件源码 项目:srcsim2017 作者: ZarjRobotics 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def start(self, _=None):
        """ Start the macro """
        anchor = self.fc.assure_anchor("center")
        if anchor is None:
            log('Click on the 2 farthest parts of the side of the table '
                'you want to approach')
            return False

        self.fc.zarj.walk.fix_stance()
        zarj.utils.wait_for_walk(self.fc.zarj)

        r_x = anchor.adjusted[0]
        r_y = anchor.adjusted[1]
        r_a = anchor.angle

        log('Table is {},{} at angle {}'.format(r_x, r_y, r_a))

        off_a = 90 - r_a
        off_x = sin(radians(off_a))*0.75
        off_y = cos(radians(off_a))*0.75

        tgt_x = r_x - off_x
        tgt_y = r_y + off_y

        log('Approach point is {},{}'.format(tgt_x, tgt_y))

        heading = degrees(atanh(tgt_y/tgt_x))
        distance = sqrt(tgt_x**2 + tgt_y**2)

        log('Path has a heading of {} and distance {}m'.format(heading,
                                                               distance))

        self.fc.zarj.walk.turn(heading, snap_to=0.0)
        zarj.utils.wait_for_walk(self.fc.zarj)
        if self.stop:
            return

        self.fc.zarj.walk.forward(distance)
        zarj.utils.wait_for_walk(self.fc.zarj)
        if self.stop:
            return

        turn = r_a + heading

        if abs(turn) > 45:
            self.fc.zarj.walk.turn(-turn/2.0, snap_to=0.0)
            zarj.utils.wait_for_walk(self.fc.zarj)
            if self.stop:
                return
            self.fc.zarj.walk.turn(-turn/2.0, snap_to=0.0)
        else:
            self.fc.zarj.walk.turn(-turn, snap_to=0.0)
        zarj.utils.wait_for_walk(self.fc.zarj)
        if self.stop:
            return

        self.fc.zarj.walk.forward(0.2)
        zarj.utils.wait_for_walk(self.fc.zarj)
bgelogic.py 文件源码 项目:bge-logic-nodes-add-on 作者: thepgi 项目源码 文件源码 阅读 22 收藏 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
        }
astro_tools.py 文件源码 项目:scikit-discovery 作者: MITHaystack 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def nfw(R, norm_constant, Rs, Rcore):
    '''
    2D Navarro-Frenk-White surface radial profile probability density

    See:
    Navarro, J. F., Frenk, C. S., & White, S. D. M. 1996, ApJ, 462, 563
    Bartelmann, M., A&A, 1996, 313, 697
    Rykoff, E.S., et al., ApJ, 746, 178

    @param R: Radius
    @param norm_constant: Normalization constant
    @param Rs: Scale radius
    @param Rcore: Since NFW profile diverges at R=0, the value at the center is held fixed starting at Rcore

    @return probability density of profile at R
    '''

    def compute_nfw(R):
        if R < Rcore:
            R2 = Rcore
        else:
            R2 = R

        if (R2/Rs) < 0.999:
            func = (1 - 2 * math.atanh(math.sqrt((1 - R2/Rs) / (R2/Rs + 1))) / math.sqrt(1 - (R2/Rs)**2)) / ((R2/Rs)**2 - 1)

        # There are some computational issues as R2/Rs -> 1, using taylor expansion of the function
        # around this point
        elif (R2/Rs) < 1.001:
            func = -(20/63)*((R2/Rs)**3 - 1) + (13/35)*((R2/Rs)**2 - 1) - (2/5)*(R2/Rs) + (11/15)

        else:
            func = (1 - 2 * math.atan(math.sqrt((R2/Rs - 1) / (R2/Rs + 1))) / math.sqrt((R2/Rs)**2 - 1)) / ((R2/Rs)**2 - 1)


        return norm_constant * 2 * math.pi * R * func

    if np.isscalar(R):
        return compute_nfw(R)

    else:
        return np.fromiter(map(compute_nfw, R), np.float, count = len(R))
test_sparse_array.py 文件源码 项目:SparseArray 作者: INGEOTEC 项目源码 文件源码 阅读 26 收藏 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)]


问题


面经


文章

微信
公众号

扫码关注公众号