def test_clear_na_n(self):
     obs  = np.arange(9,  dtype=float)
     obs.shape = (3, 3)
     obs[0, 2] = np.nan
     res = Melding.clearNaN(obs)
     print res,  obs
     assert_equal(res[0, 2],  np.mean([obs[0, 0], obs[0, 1]]) )
Example #2
0
 def test_clear_na_n(self):
     obs = np.arange(9, dtype=float)
     obs.shape = (3, 3)
     obs[0, 2] = np.nan
     res = Melding.clearNaN(obs)
     print(res, obs)
     assert_equal(res[0, 2], np.mean([obs[0, 0], obs[0, 1]]))
Example #3
0
 def setUp(self):
     self.meld = Melding.Meld(3000,
                              1000,
                              Melding.model,
                              2,
                              1,
                              alpha=0.5,
                              verbose=0,
                              viz=False)
     self.meld.setTheta(['r', 'p0'], [st.uniform, st.uniform], [(2, 4),
                                                                (0, 5)],
                        [(0, 10), (0, 10)])
     self.meld.setPhi(['p'], [st.uniform], [(6, 9)], [(0, 10)])
 def test_basicfit(self):
     assert_almost_equal(4.6666, Melding.basicfit(self.s1, self.s2), 1)
Example #5
0
 def test_basicfit(self):
     assert_almost_equal(4.6666, Melding.basicfit(self.s1, self.s2), 1)
Example #6
0
        '''ODE model'''
        S, I, R = y
        return [
            -beta * I * S,  # dS/dt
            beta * I * S - tau * I,  # dI/dt
            tau * I,  # dR/dt
        ]

    y = odeint(sir, inits, np.arange(0, tf, step))
    return y


fit_model = Melding.FitModel(K,
                             model,
                             inits,
                             tf,
                             thetanames,
                             phinames,
                             verbose=verbose,
                             burnin=10)


class TestFitModel(unittest.TestCase):
    def setUp(self):
        nt = len(thetanames)
        np = len(phinames)
        fit_model.set_priors(tdists=nt * [st.uniform],
                             tpars=[(0, 4), (0, 2)],
                             tlims=[(0, 4), (0, 2)],
                             pdists=np * [st.uniform],
                             ppars=np * [(0, 1)],
                             plims=np * [(0, 1)])