Python cmath 模块,e() 实例源码

我们从Python开源项目中,提取了以下18个代码示例,用于说明如何使用cmath.e()

项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def test_constants(self):
        e_expected = 2.71828182845904523536
        pi_expected = 3.14159265358979323846
        self.assertAlmostEqual(cmath.pi, pi_expected, places=9,
            msg="cmath.pi is {}; should be {}".format(cmath.pi, pi_expected))
        self.assertAlmostEqual(cmath.e, e_expected, places=9,
            msg="cmath.e is {}; should be {}".format(cmath.e, e_expected))
项目:antlang4python    作者:AntLang-Software    | 项目源码 | 文件源码
def _else(maybe_false_if, if_exception):
    try: return maybe_false_if()
    except ConditionalException as e: return if_exception(str(e))
项目:antlang4python    作者:AntLang-Software    | 项目源码 | 文件源码
def _except(maybe_exception, if_exception):
    try: return maybe_exception()
    except Exception as e: return if_exception(str(e))
项目:antlang4python    作者:AntLang-Software    | 项目源码 | 文件源码
def main(args = sys.argv):
    if len(sys.argv) == 3 and sys.argv[1] == '-f':
        try:
            open_script(sys.argv[2])
        except Exception as e:
            print(e)
    elif len(sys.argv) == 4 and sys.argv[1] == '-f':
        try:
            include(*sys.argv[2:])
        except Exception as e:
            print(e)
    elif len(sys.argv) >= 3 and sys.argv[1] == '-bundle':
        bundle(sys.argv[2], *sys.argv[3:])
    elif len(sys.argv) == 3 and sys.argv[1] == '-e':
        evaluate(sys.argv[2])
    else:
        try: import readline
        except ImportError: pass
        while True:
            try:
                if len(sys.argv) > 1 and sys.argv[1] == '-np':
                    line = input('')
                else:
                    line = input('--> ')
                print(evaluate(line))
            except (EOFError):
                quit()
            except Exception as e:
                print(e)
            except:
                pass

# PyAntLang compatible interface
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def test_constants(self):
        e_expected = 2.71828182845904523536
        pi_expected = 3.14159265358979323846
        self.assertAlmostEqual(cmath.pi, pi_expected, places=9,
            msg="cmath.pi is {}; should be {}".format(cmath.pi, pi_expected))
        self.assertAlmostEqual(cmath.e, e_expected, places=9,
            msg="cmath.e is {}; should be {}".format(cmath.e, e_expected))
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def check_polar(self, func):
        def check(arg, expected):
            got = func(arg)
            for e, g in zip(expected, got):
                self.rAssertAlmostEqual(e, g)
        check(0, (0., 0.))
        check(1, (1., 0.))
        check(-1, (1., pi))
        check(1j, (1., pi / 2))
        check(-3j, (3., -pi / 2))
        inf = float('inf')
        check(complex(inf, 0), (inf, 0.))
        check(complex(-inf, 0), (inf, pi))
        check(complex(3, inf), (inf, pi / 2))
        check(complex(5, -inf), (inf, -pi / 2))
        check(complex(inf, inf), (inf, pi / 4))
        check(complex(inf, -inf), (inf, -pi / 4))
        check(complex(-inf, inf), (inf, 3 * pi / 4))
        check(complex(-inf, -inf), (inf, -3 * pi / 4))
        nan = float('nan')
        check(complex(nan, 0), (nan, nan))
        check(complex(0, nan), (nan, nan))
        check(complex(nan, nan), (nan, nan))
        check(complex(inf, nan), (inf, nan))
        check(complex(-inf, nan), (inf, nan))
        check(complex(nan, inf), (inf, nan))
        check(complex(nan, -inf), (inf, nan))
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def test_constants(self):
        e_expected = 2.71828182845904523536
        pi_expected = 3.14159265358979323846
        self.assertAlmostEqual(cmath.pi, pi_expected, places=9,
            msg="cmath.pi is {}; should be {}".format(cmath.pi, pi_expected))
        self.assertAlmostEqual(cmath.e, e_expected, places=9,
            msg="cmath.e is {}; should be {}".format(cmath.e, e_expected))
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def check_polar(self, func):
        def check(arg, expected):
            got = func(arg)
            for e, g in zip(expected, got):
                self.rAssertAlmostEqual(e, g)
        check(0, (0., 0.))
        check(1, (1., 0.))
        check(-1, (1., pi))
        check(1j, (1., pi / 2))
        check(-3j, (3., -pi / 2))
        inf = float('inf')
        check(complex(inf, 0), (inf, 0.))
        check(complex(-inf, 0), (inf, pi))
        check(complex(3, inf), (inf, pi / 2))
        check(complex(5, -inf), (inf, -pi / 2))
        check(complex(inf, inf), (inf, pi / 4))
        check(complex(inf, -inf), (inf, -pi / 4))
        check(complex(-inf, inf), (inf, 3 * pi / 4))
        check(complex(-inf, -inf), (inf, -3 * pi / 4))
        nan = float('nan')
        check(complex(nan, 0), (nan, nan))
        check(complex(0, nan), (nan, nan))
        check(complex(nan, nan), (nan, nan))
        check(complex(inf, nan), (inf, nan))
        check(complex(-inf, nan), (inf, nan))
        check(complex(nan, inf), (inf, nan))
        check(complex(nan, -inf), (inf, nan))
项目:web_ctp    作者:molebot    | 项目源码 | 文件源码
def test_constants(self):
        e_expected = 2.71828182845904523536
        pi_expected = 3.14159265358979323846
        self.assertAlmostEqual(cmath.pi, pi_expected, places=9,
            msg="cmath.pi is {}; should be {}".format(cmath.pi, pi_expected))
        self.assertAlmostEqual(cmath.e, e_expected, places=9,
            msg="cmath.e is {}; should be {}".format(cmath.e, e_expected))
项目:statistical-learning-methods-note    作者:ysh329    | 项目源码 | 文件源码
def computeBaseClassifierCoefficient(self, classifierIdx):
        '''
        ???????????????(?0??)???????????? alpha ?
        :param classifierIdx: ???????(?0??)
        :return:
        '''
        self.alphaList[classifierIdx] = (1.0 / 2 * \
                                         cmath.log((1.0-self.eList[classifierIdx])/self.eList[classifierIdx], cmath.e)\
                                         ).real
项目:pefile.pypy    作者:cloudtracer    | 项目源码 | 文件源码
def test_constants(self):
        e_expected = 2.71828182845904523536
        pi_expected = 3.14159265358979323846
        self.assertAlmostEqual(cmath.pi, pi_expected, places=9,
            msg="cmath.pi is {}; should be {}".format(cmath.pi, pi_expected))
        self.assertAlmostEqual(cmath.e, e_expected, places=9,
            msg="cmath.e is {}; should be {}".format(cmath.e, e_expected))
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def test_constants(self):
        e_expected = 2.71828182845904523536
        pi_expected = 3.14159265358979323846
        self.assertAlmostEqual(cmath.pi, pi_expected, places=9,
            msg="cmath.pi is {}; should be {}".format(cmath.pi, pi_expected))
        self.assertAlmostEqual(cmath.e, e_expected, places=9,
            msg="cmath.e is {}; should be {}".format(cmath.e, e_expected))
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def check_polar(self, func):
        def check(arg, expected):
            got = func(arg)
            for e, g in zip(expected, got):
                self.rAssertAlmostEqual(e, g)
        check(0, (0., 0.))
        check(1, (1., 0.))
        check(-1, (1., pi))
        check(1j, (1., pi / 2))
        check(-3j, (3., -pi / 2))
        inf = float('inf')
        check(complex(inf, 0), (inf, 0.))
        check(complex(-inf, 0), (inf, pi))
        check(complex(3, inf), (inf, pi / 2))
        check(complex(5, -inf), (inf, -pi / 2))
        check(complex(inf, inf), (inf, pi / 4))
        check(complex(inf, -inf), (inf, -pi / 4))
        check(complex(-inf, inf), (inf, 3 * pi / 4))
        check(complex(-inf, -inf), (inf, -3 * pi / 4))
        nan = float('nan')
        check(complex(nan, 0), (nan, nan))
        check(complex(0, nan), (nan, nan))
        check(complex(nan, nan), (nan, nan))
        check(complex(inf, nan), (inf, nan))
        check(complex(-inf, nan), (inf, nan))
        check(complex(nan, inf), (inf, nan))
        check(complex(nan, -inf), (inf, nan))
项目:ndk-python    作者:gittor    | 项目源码 | 文件源码
def test_constants(self):
        e_expected = 2.71828182845904523536
        pi_expected = 3.14159265358979323846
        self.assertAlmostEqual(cmath.pi, pi_expected, places=9,
            msg="cmath.pi is {}; should be {}".format(cmath.pi, pi_expected))
        self.assertAlmostEqual(cmath.e, e_expected, places=9,
            msg="cmath.e is {}; should be {}".format(cmath.e, e_expected))
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def test_constants(self):
        e_expected = 2.71828182845904523536
        pi_expected = 3.14159265358979323846
        self.assertAlmostEqual(cmath.pi, pi_expected, places=9,
            msg="cmath.pi is {}; should be {}".format(cmath.pi, pi_expected))
        self.assertAlmostEqual(cmath.e, e_expected, places=9,
            msg="cmath.e is {}; should be {}".format(cmath.e, e_expected))
项目:Julus    作者:AntLang-Software    | 项目源码 | 文件源码
def _else(maybe_false_if, if_exception):
    try: return maybe_false_if()
    except ConditionalException as e: return if_exception(str(e))
项目:Julus    作者:AntLang-Software    | 项目源码 | 文件源码
def _except(maybe_exception, if_exception):
    try: return maybe_exception()
    except Exception as e: return if_exception(str(e))
项目:Julus    作者:AntLang-Software    | 项目源码 | 文件源码
def main(args = sys.argv):
    if len(sys.argv) == 3 and sys.argv[1] == '-f':
        try:
            open_script(sys.argv[2])
        except Exception as e:
            print(e)
    elif len(sys.argv) == 4 and sys.argv[1] == '-f':
        try:
            include(*sys.argv[2:])
        except Exception as e:
            print(e)
    elif len(sys.argv) >= 3 and sys.argv[1] == '-bundle':
        bundle(sys.argv[2], *sys.argv[3:])
    elif len(sys.argv) == 3 and sys.argv[1] == '-e':
        evaluate(sys.argv[2])
    else:
        try: import readline
        except ImportError: pass
        while True:
            try:
                if len(sys.argv) > 1 and sys.argv[1] == '-np':
                    line = input('')
                else:
                    line = input('--> ')
                print(evaluate(line))
            except (EOFError):
                quit()
            except Exception as e:
                print(e)
            except:
                pass

# Julus `do` interface