def test_io_round_trip(): with path.tempdir() as p: population_path = os.path.join(p, "test_location") dummy_population.save_to(population_path) retrieved = Population.load_from(circus=None, folder=population_path) assert dummy_population.size == retrieved.size assert dummy_population.ids.tolist() == retrieved.ids.tolist() ids = dummy_population.ids.tolist() for att_name in dummy_population.attribute_names(): assert dummy_population.get_attribute_values(att_name, ids).equals( retrieved.get_attribute_values(att_name, ids)) for rel_name in dummy_population.relationship_names(): assert dummy_population.get_relationship(rel_name)._table.equals( retrieved.get_relationship(rel_name)._table)
def load_population(namespace, population_id, circus): return Population.load_from(population_folder(namespace, population_id), circus)