def test_migrate_all_animals_all_move(self, jungle, herb_list_big, carn_list_big, tear_down_params): """Test to see that all animals migrate if they deside to migrate. """ j = jungle j.herb_list = herb_list_big j.carn_list = carn_list_big neighbors = (Jungle(), Jungle(), Jungle(), Jungle()) Herb.set_parameters({"mu": 100, "F": 0}) Carn.set_parameters({"mu": 100, "F": 0}) j.migrate_all_animals(neighbors) assert len(j.herb_move_from_list) == 1000 assert len(j.carn_move_from_list) == 1000
def set_animal_parameters(self, species, params): """ Set parameters for animal species. :param species: String, name of animal species :param params: Dict with valid parameter specification for species """ if species == "Herbivore": h = Herb() h.set_parameters(params) elif species == "Carnivore": c = Carn() c.set_parameters(params) else: raise ValueError(f'Got non existing species {species} ')
def test_migrate_all_animals_equal_prob(self, jungle, herb_list_big, carn_list_big, tear_down_params): """ Test to see that animal is equally likely to migrate to any square if move propensity is equal for all squares. """ j = jungle j.herb_list = herb_list_big j.carn_list = carn_list_big neighbors = (Jungle(), Jungle(), Jungle(), Jungle()) Herb.set_parameters({"mu": 100, "F": 0}) Carn.set_parameters({"mu": 100, "F": 0}) j.migrate_all_animals(neighbors) num_moved = np.array(( len(neighbors[0].herb_move_to_list), len(neighbors[1].herb_move_to_list), len(neighbors[2].herb_move_to_list), len(neighbors[3].herb_move_to_list), )) num_expected = np.array((250, 250, 250, 250)) _, pvalue = chisquare(num_moved, num_expected) assert pvalue > 0.001