def test_get_population(history: History): population = Population(rand_pop_list(0)) history.append_population( t=0, current_epsilon=7.0, population=population, nr_simulations=200, model_names=["m0"], ) population_h = history.get_population(t=0) # length assert len(population) == len(population_h) # distances distances = [p.distance for p in population.particles] distances_h = [p.distance for p in population_h.particles] for d0, d1 in zip(distances, distances_h): assert np.isclose(d0, d1) # weights weights = [p.weight for p in population.particles] weights_h = [p.weight for p in population_h.particles] for w0, w1 in zip(weights, weights_h): assert np.isclose(w0, w1)
def test_get_population(history: History): population = Population(rand_pop(0)) history.append_population(t=0, current_epsilon=7.0, population=population, nr_simulations=200, model_names=["m0"]) population_h = history.get_population(t=0) # length assert len(population) == len(population_h) # distances distances = sum((p.accepted_distances for p in population.get_list()), []) distances_h = sum((p.accepted_distances for p in population_h.get_list()), []) for d0, d1 in zip(distances, distances_h): assert np.isclose(d0, d1) # weights weights = [p.weight for p in population.get_list()] weights_h = [p.weight for p in population_h.get_list()] for w0, w1 in zip(weights, weights_h): assert np.isclose(w0, w1)