Ejemplo n.º 1
0
    def test_integral_func1(self):
        res1 = utils.logtrapzexp(self.lnfunc1, self.dx)
        res2 = utils.logtrapzexp(self.lnfunc1, self.dxs)

        self.assertTrue(np.abs(res1 - res2) < 1e-12)
        self.assertTrue(
            np.abs((np.exp(res1) - self.func1int) / self.func1int) < 1e-12)
Ejemplo n.º 2
0
 def test_integral_func2_irregular_steps(self):
     res = utils.logtrapzexp(self.lnfunc2irregular, self.irregulardxs)
     self.assertTrue(
         np.abs((np.exp(res) - self.func2int) / self.func2int) < 1e-2)
Ejemplo n.º 3
0
 def test_integral_func2(self):
     res = utils.logtrapzexp(self.lnfunc2, self.dxs)
     self.assertTrue(
         np.abs((np.exp(res) - self.func2int) / self.func2int) < 1e-4)
Ejemplo n.º 4
0
 def test_inconsistent_step_length(self):
     with self.assertRaises(ValueError):
         utils.logtrapzexp(self.lnfunc1, self.x[0:len(self.x) // 2])
Ejemplo n.º 5
0
 def test_incorrect_step_type(self):
     with self.assertRaises(TypeError):
         utils.logtrapzexp(self.lnfunc1, "blah")