我们从Python开源项目中,提取了以下18个代码示例,用于说明如何使用cmath.e()。
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))
def _else(maybe_false_if, if_exception): try: return maybe_false_if() except ConditionalException as e: return if_exception(str(e))
def _except(maybe_exception, if_exception): try: return maybe_exception() except Exception as e: return if_exception(str(e))
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
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))
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
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