def test__init__(self):
        region_name = 'London'
        age_groups = ['0-10', '10-25']
        contact_data_matrix = np.array([[10, 5.2], [0, 3]])
        region_data_matrix = np.array([[0.5, 1.2], [0.29, 6]])
        pop_size = [18, 2]
        dI = 4

        contacts = em.ContactMatrix(age_groups, contact_data_matrix)
        regional = em.RegionMatrix(region_name, age_groups, region_data_matrix)
        next_gen = em.UniNextGenMatrix(pop_size, contacts, regional, dI)

        self.assertEqual(next_gen.region, 'London')
        npt.assert_array_equal(next_gen.ages, np.array(['0-10', '10-25']))
        npt.assert_array_equal(next_gen.susceptibles, np.array([18, 2]))
        npt.assert_array_equal(next_gen.contacts, contact_data_matrix)
        npt.assert_array_equal(next_gen.regional_suscep, region_data_matrix)
        self.assertEqual(next_gen.infection_period, 4)

        pdt.assert_frame_equal(
            next_gen.get_next_gen_matrix(),
            pd.DataFrame(data=np.array([[360, 449.28], [0, 144]]),
                         index=['0-10', '10-25'],
                         columns=['0-10', '10-25']))

        with self.assertRaises(TypeError):
            em.UniNextGenMatrix(pop_size, 0, regional, dI)

        with self.assertRaises(TypeError):
            em.UniNextGenMatrix(pop_size, contacts, 0, dI)

        with self.assertRaises(ValueError):
            new_age_groups = ['0-15', '15-25']
            regional1 = em.RegionMatrix(region_name, new_age_groups,
                                        region_data_matrix)
            em.UniNextGenMatrix(pop_size, contacts, regional1, dI)

        with self.assertRaises(TypeError):
            em.UniNextGenMatrix(pop_size, contacts, regional, '4')

        with self.assertRaises(ValueError):
            em.UniNextGenMatrix(pop_size, contacts, regional, 0)

        with self.assertRaises(ValueError):
            em.UniNextGenMatrix([[1], [2]], contacts, regional, dI)

        with self.assertRaises(ValueError):
            em.UniNextGenMatrix([0, 1, 1], contacts, regional, dI)

        with self.assertRaises(ValueError):
            em.UniNextGenMatrix([0, -1], contacts, regional, dI)

        with self.assertRaises(TypeError):
            em.UniNextGenMatrix([0, '1'], contacts, regional, dI)
    def test__init__(self):
        region_name = 'London'
        age_groups = ['0-10', '10-25']

        # Initial state of the system
        contact_data_matrix_0 = np.array([[10, 0], [0, 3]])
        region_data_matrix_0 = np.array([[0.5, 0], [0, 6]])
        init_pop_size = [1, 2]
        dI = 4

        contacts_0 = em.ContactMatrix(age_groups, contact_data_matrix_0)
        regional_0 = em.RegionMatrix(region_name, age_groups,
                                     region_data_matrix_0)
        next_gen_0 = em.UniNextGenMatrix(init_pop_size, contacts_0, regional_0,
                                         dI)

        initial_r = 0.5
        infect = em.UniInfectivityMatrix(initial_r,
                                         initial_nextgen_matrix=next_gen_0)

        self.assertEqual(infect.r0, 0.5)
        self.assertEqual(infect.r0_star, 144)

        with self.assertRaises(TypeError):
            em.UniInfectivityMatrix('0', initial_nextgen_matrix=next_gen_0)

        with self.assertRaises(TypeError):
            em.UniInfectivityMatrix(initial_r, initial_nextgen_matrix=0)
    def test_compute_reproduction_number(self):
        region_name = 'London'
        age_groups = ['0-10', '10-25']

        # Initial state of the system
        contact_data_matrix_0 = np.array([[10, 0], [0, 3]])
        region_data_matrix_0 = np.array([[0.5, 0], [0, 6]])
        init_pop_size = [1, 2]
        dI = 4

        contacts_0 = em.ContactMatrix(age_groups, contact_data_matrix_0)
        regional_0 = em.RegionMatrix(region_name, age_groups,
                                     region_data_matrix_0)
        next_gen_0 = em.UniNextGenMatrix(init_pop_size, contacts_0, regional_0,
                                         dI)

        # Later time state of the system
        contact_data_matrix_1 = np.array([[10, 5.2], [0, 3]])
        region_data_matrix_1 = np.array([[0.5, 1.2], [0.29, 6]])
        current_pop_size = [18, 2]

        contacts_1 = em.ContactMatrix(age_groups, contact_data_matrix_1)
        regional_1 = em.RegionMatrix(region_name, age_groups,
                                     region_data_matrix_1)
        next_gen_1 = em.UniNextGenMatrix(current_pop_size, contacts_1,
                                         regional_1, dI)

        initial_r = 0.5
        temp_variation = 1
        infect = em.UniInfectivityMatrix(initial_r,
                                         initial_nextgen_matrix=next_gen_0)

        self.assertEqual(
            infect.compute_reproduction_number(temp_variation, next_gen_1),
            5 / 4)

        with self.assertRaises(TypeError):
            infect.compute_reproduction_number('1', next_gen_1)

        with self.assertRaises(TypeError):
            infect.compute_reproduction_number(temp_variation, 0)
    def test_compute_dom_eigenvalue(self):
        region_name = 'London'
        age_groups = ['0-10', '10-25']
        contact_data_matrix = np.array([[10, 0], [0, 3]])
        region_data_matrix = np.array([[0.5, 0], [0, 6]])
        pop_size = [1, 2]
        dI = 4

        contacts = em.ContactMatrix(age_groups, contact_data_matrix)
        regional = em.RegionMatrix(region_name, age_groups, region_data_matrix)
        next_gen = em.UniNextGenMatrix(pop_size, contacts, regional, dI)

        self.assertEqual(next_gen.compute_dom_eigenvalue(), 144)