def test_bury_the_dead(): p2_virus = Pathogen("Libertarianism", 1.0, 1.0) p2_pop = Population("Rapture", 6, p2_virus, 6, 0.0) # print(p2_pop.the_living[0].print_greeting()) assert len(p2_pop.the_living) is 6 assert len(p2_pop.the_dead) is 0 for person in p2_pop.the_living: person.newly_infected = False assert not person.is_dead for person in p2_pop.the_living: assert person.infection is p2_virus # person.print_greeting() assert p2_virus.mortality_rate is 1.0 print("burying the dead") index = 0 p2_pop.bury_the_dead() # print(p2_pop.the_living[0].name) print("List of living:") for person in p2_pop.the_living: print(person.id) print("List of dead:") for person in p2_pop.the_dead: print(person.id) assert len(p2_pop.the_living) is 0 assert len(p2_pop.the_dead) is 6
def test_newly_infected(): p3_virus = Pathogen("This class", 1.0, 1.0) p3_pop = Population("My brain cells", 2, p3_virus, 2, 0.0) assert p3_pop.the_living[0].newly_infected assert not p3_pop.the_living[0].did_die() assert not p3_pop.the_living[0].newly_infected assert p3_pop.the_living[0].did_die() # TEST RUN LOOP # def test_sim(): # sim = Simulation() # sim.pathogen_name = "Ebola" # sim.mortality_rate = 1.0 # sim.infectiousness = 1.0 # sim.population_size = 10 # sim.initial_infected = 10 # sim.percent_vaccinated = 0.0 # sim.initialize() # sim.run(logger) # assert len(sim.population.the_living) is 0
def test(): virus = Pathogen("the gay agenda", 0.5, 0.5) make_school = Population("Make School", 30, virus, 3, 0.5) make_school.print_info() make_school.mingle(2, virus) make_school.bury_the_dead() make_school.print_info()
def test_newly_infected(): p3_virus = Pathogen("This class", 1.0, 1.0) p3_pop = Population("My brain cells", 2, p3_virus, 2, 0.0) assert p3_pop.the_living[0].newly_infected assert not p3_pop.the_living[0].did_die() assert not p3_pop.the_living[0].newly_infected assert p3_pop.the_living[0].did_die()
def initialize(self): # create the pathogen self.pathogen = Pathogen(self.pathogen_name, self.mortality_rate, self.infectiousness) # create the population # leaving out name for the user generated stuff self.population = Population( name="Simulated Population", people=self.population_size, pathogen=self.pathogen, initial_infected=self.initial_infected, percent_vaccinated=self.percent_vaccinated)
def test(): # Population(self, name, people, pathogen, initial_infected, percent_vaccinated=0.0) virus = Pathogen("the gay agenda", 0.5, 0.5) # person1 = Person() # person1.print_greeting() # person1.get_infected(stale_memes) # person1.get_infected(dank_memes) # person1.print_greeting() # person1.did_die() # print("above human should have died\n") # person2 = Person() # person2.is_vaccinated = True # person2.get_infected(stale_memes) # person2.get_infected(dank_memes) # person2.did_die() make_school = Population("Make School", 30, virus, 3, 0.5) make_school.print_info() make_school.mingle(2, virus) make_school.bury_the_dead() make_school.print_info()
def test_print_pathogen_info(): ebola = Pathogen("ebola", 0.70, 0.25) ebola_greeting = ebola.print_info(False) assert "ebola" in ebola_greeting assert "70" in ebola_greeting assert "25" in ebola_greeting
import io import sys # from logger import logger # TEST PATHOGEN def test_print_pathogen_info(): ebola = Pathogen("ebola", 0.70, 0.25) ebola_greeting = ebola.print_info(False) assert "ebola" in ebola_greeting assert "70" in ebola_greeting assert "25" in ebola_greeting virus = Pathogen("the black plague", 0.5, 0.5) my_pop = Population("1437 France", 30, virus, 3, 0.5) def clear_log_file(): file = open("NO_FILE_SPECIFIED.md", "w+") file.write("# this file for testing") print("File cleared.") print(file.read()) def read_log_file(): file = open("NO_FILE_SPECIFIED.md", "r") print("File read.") return file.read()
# apples-to-apples comparison possible. max_number_of_edges = 1500 # parameters for the pathogen object. r_0 = 0.05 timesteps_for_recovery = 45 # What fraction of infections result in symptomatic infection. symptomatic_prob = 0.2 # Parameters for the simulation. num_initially_infected = 2 # If you are symptomatic, then your likelihood of interaction becomes this. symptomatic_edge_weight = 0.1 pathogen = Pathogen(r_0, timesteps_for_recovery, symptomatic_prob) GC = GraphConstructor(N, cluster_size, cluster_stdev, in_cluster_transition, out_cluster_transition, out_cluster_edge_mean, out_cluster_edge_stdev, max_number_of_edges=max_number_of_edges) GC.construct_graph() S = Simulator(GC.graph, pathogen) S.prepare_simulation(num_initially_infected, symptomatic_edge_weight=symptomatic_edge_weight)