def make_tour_model_from_raw_user_data(user_id): try: list_of_cluster_data = eamtmcp.main(user_id, False) esdcpq.create_places(list_of_cluster_data, user_id) esdctq.set_up_trips(list_of_cluster_data, user_id) except ValueError as e: logging.debug("Got ValueError %s while creating tour model, skipping it..." % e)
def testClusterToTourModel(self): data = cp.cluster_to_tour_model(None, None) #for a negative test case self.assertTrue(not data) #checking that the code doesn't crash on an empty dataset data = cp.read_data(size=100)#this and the following lines form the positive test case data, bins = cp.remove_noise(data, 300) n, labels, data = cp.cluster(data, len(bins)) tour_dict = cp.main() self.assertTrue(len(tour_dict) <= n)
def make_tour_model_from_raw_user_data(user_id): try: list_of_cluster_data = eamtmcp.main(user_id) esdcpq.create_places(list_of_cluster_data, user_id) esdctq.set_up_trips(list_of_cluster_data, user_id) except ValueError as e: logging.debug( "Got ValueError %s while creating tour model, skipping it..." % e)
def testCreation(self): # This is mostly just a sanity check db = get_trip_db() db.remove() create_fake_trips() list_of_cluster_data = eamtcp.main() tm = create_tour_model('test_user', list_of_cluster_data) self.assertEquals(len(tm.get_top_trips(1)), 1) tour = tm.build_tour_model() self.assertEquals(len(tour), 7)
def testClusterToTourModel(self): # Test to make sure it doesn't crash on a empty dataset data = cp.cluster_to_tour_model(None, None) self.assertFalse(data) # Test with the real dataset data = cp.read_data(uuid=self.testUUID) data, bins = cp.remove_noise(data, self.RADIUS) n, labels, data = cp.cluster(data, len(bins)) tour_dict = cp.main(uuid=self.testUUID) self.assertTrue(len(tour_dict) <= n)
def testClusterToTourModel(self): # Test to make sure it doesn't crash on a empty dataset data = cp.cluster_to_tour_model(None, None) self.assertFalse(data) # Test with the real dataset data = cp.read_data(uuid=self.testUUID) data, bins = cp.remove_noise(data, self.RADIUS) n, labels, data = cp.cluster(data, len(bins)) tour_dict = cp.main(uuid=self.testUUID) self.assertTrue(len(tour_dict) <= n)
def testClusterToTourModelNew(self): data = cp.cluster_to_tour_model(None, None, old=False) #for a negative test case self.assertTrue(not data) #checking that the code doesn't crash on an empty dataset user_name = "test1" data = cp.read_data(uuid=self.testUUID, size=100, old=False) #this and the following lines form the positive test case data, bins = cp.remove_noise(data, 300, old=False) n, labels, data = cp.cluster(data, len(bins), old=False) tour_dict = cp.main(uuid=user_name, old=False) print 'n = %s | len(tour_dict) = %s' % (n, len(tour_dict)) self.assertTrue(len(tour_dict) <= n)
def testCreatePlace(self): etc.setupRealExample(self, "emission/tests/data/real_examples/shankari_2015-aug-27") eaicf.filter_accuracy(self.testUUID) estfm.move_all_filters_to_data() eaist.segment_current_trips(self.testUUID) eaiss.segment_current_sections(self.testUUID) data = eamtcp.main(self.testUUID) esdcpq.create_places(data, self.testUUID) places = esdcpq.get_all_common_places_for_user(self.testUUID) places_list = [] for p in places: places_list.append(esdcpq.make_common_place(p)) for place in places_list: self.assertIsNotNone(place.location) self.assertIsNotNone(place["successors"])
def make_graph_edge(start_point, end_point, tour_model): sp = tour_model.get_location(start_point) ep = tour_model.get_location(end_point) comm = tm.Commute(sp, ep) tour_model.add_edge(comm) return comm def get_start_hour(section_info): return section_info.start_time.hour def get_end_hour(section_info): return section_info.start_time.hour def get_day(section_info): return section_info.start_time.weekday() def get_mode_num(section_info): map_modes_to_numbers = {"walking" : 0, "car" : 1, "train" : 2, "bart" : 3, "bike" : 4} return random.randint(0, 4) final_tour_model = None if __name__ == "__main__": if len(sys.argv) > 1: user = UUID(sys.argv[1]) else: user = None list_of_cluster_data = eamtcp.main(user) final_tour_model = create_tour_model("shankari", list_of_cluster_data)
def testSanity(self): cp.main(self.testUUID)
def testSanity(self): cp.main(self.testUUID)
def get_fake_data(user_name): # Call with a username unique to your database tg.create_fake_trips(user_name, True) return eamtcp.main(user_name)
def get_end_hour(section_info): return section_info.start_time.hour def get_day(section_info): return section_info.start_time.weekday() def get_mode_num(section_info): map_modes_to_numbers = { "walking": 0, "car": 1, "train": 2, "bart": 3, "bike": 4 } return random.randint(0, 4) final_tour_model = None if __name__ == "__main__": if len(sys.argv) > 1: user = UUID(sys.argv[1]) else: user = None list_of_cluster_data = eamtcp.main(user) final_tour_model = create_tour_model("shankari", list_of_cluster_data)
def get_fake_data(user_name): # Call with a username unique to your database tg.create_fake_trips(user_name, True) return eamtcp.main(user_name, old=False)
def testSanityCheckNew(self): thing = cp.main(self.testUUID, False)