def reset_graph(): """Resets THE graph based on parameters""" global graph num_schools = dict_int(request.form, 'num_schools', 5) num_classes = dict_int(request.form, 'num_classes', 10) class_gen = lambda: new_classroom(10, variation_coeff=1) schools = [new_school(num_classes, 0.5, class_gen, extra_coaching_rate=0.1) for i in range(num_schools)] # flatten schools list graph = [user for school in schools for user in school] return users_to_graph_json(graph)
def test_list_is_flat(self): classroom_gen = lambda: graph_generation.new_classroom( avg_num_students=10, variation_coeff=0.1 ) school = graph_generation.new_school( avg_num_classes=3, variation_coeff=0.3, class_gen=classroom_gen ) for u in school: self.assertIsInstance(u, models.User, msg='School list not flattened')