示例#1
0
    def test3(self):
        """ tau = -1, c = 1
        """
        c = 1
        tau = -1
        y = scaled_exp(0, c, tau)
        self.assertAlmostEqual(y, 1)

        y = scaled_exp(1, c, tau)
        self.assertAlmostEqual(y, np.exp(-1))
示例#2
0
    def test3(self):
        """ tau = 10, c = 1
        """
        c = 1
        tau = 1
        y = scaled_exp(0, c, tau)
        self.assertAlmostEqual(y, 1)

        t = 1
        y = scaled_exp(1, c, tau)
        self.assertAlmostEqual(y, np.exp(1 / 10.))
示例#3
0
    def test2(self):
        """ tau = 1, c = 10
        """
        c = 10
        tau = 1
        y = scaled_exp(0, c, tau)
        self.assertAlmostEqual(y, 10)

        y = scaled_exp(1, c, tau)
        self.assertAlmostEqual(y, 10 * np.exp(1))

        y = scaled_exp(10, c, tau)
        self.assertAlmostEqual(y, 10 * np.exp(10))
示例#4
0
    def test1(self):
        """ tau = 1, c = 1
        """
        c = 1
        tau = 1

        y = scaled_exp(0, c, tau)
        self.assertAlmostEqual(y, 1)

        y = scaled_exp(1, c, tau)
        self.assertAlmostEqual(y, np.exp(1))

        y = scaled_exp(10, c, tau)
        self.assertAlmostEqual(y, np.exp(10))
示例#5
0
 def test0(self):
     """0 parameters, c0, tau = 1
     """
     t = np.linspace(-10, 10)
     y = scaled_exp(t, 0, 1)
     flags = y == 0
     self.assertEqual(flags.all(), True)
示例#6
0
    def evalFitFuncs(self, c, tau):
        """Calculate values and test if fit works
        """
        t = np.linspace(-10, 10)
        y = scaled_exp(t, c, tau)
        y = y + self.b

        b_start = self.bstart
        pars, corr, err = fit_scaled_exp_offset(t, y, b=b_start)
        c_f, tau_f, b = pars
        self.assertAlmostEqual(c_f, c)
        self.assertAlmostEqual(tau_f, tau)
        self.assertAlmostEqual(b, self.b)
示例#7
0
    def evalFitFuncs(self, c, tau):
        """Calculate values and test if fit works
        """
        t = np.linspace(-10, 10)
        y = scaled_exp(t, c, tau)

        c_fe, tau_inv = estimate_tau_inv(t, y)
        self.assertAlmostEqual(c_fe, c)

        tau_f = 1. / tau_inv
        self.assertAlmostEqual(tau_f, tau)

        pars, corr, err = fit_scaled_exp(t, y)
        c_f, tau_f = pars
        self.assertAlmostEqual(c_f, c)
        self.assertAlmostEqual(tau_f, tau)