Ejemplo n.º 1
0
    def test_matcher_on_full_trip(self, trip_id="010714_00115"):
        detected_stop_times_gtfs, day = self.load_trip_info_for_matcher(trip_id)

        trip_delays_ids_list_of_lists = get_matched_trips("test_matcher_on_full_trip", detected_stop_times_gtfs, day)
        self.assertEquals(len(trip_delays_ids_list_of_lists), 1)
        matched_trip_ids = get_trusted_trips(trip_delays_ids_list_of_lists)
        self.assertEquals(matched_trip_ids[0], trip_id)
Ejemplo n.º 2
0
 def test_matcher_on_full_trip(self, trip_id = '010414_00168'):
     detected_stop_times_gtfs, relevant_service_ids = self.load_trip_info_for_matcher(trip_id)
         
     trips, time_deviation_in_seconds = get_matched_trips('test_matcher_on_full_trip', detected_stop_times_gtfs,\
                            relevant_service_ids, print_debug_info=True)
     matched_trip_id = get_trusted_trip_or_none(trips, time_deviation_in_seconds)        
     self.assertEquals(matched_trip_id, trip_id)
Ejemplo n.º 3
0
    def test_matcher_on_trip_set(self, trip_ids=["010714_00283", "010714_00115"]):
        detected_stop_times_gtfs_all = []
        for trip_id in trip_ids:
            detected_stop_times_gtfs, day = self.load_trip_info_for_matcher(trip_id)
            detected_stop_times_gtfs_all += detected_stop_times_gtfs

        trip_delays_ids_list_of_lists = get_matched_trips(
            "test_matcher_on_full_trip", detected_stop_times_gtfs_all, day
        )

        self.assertEquals(len(trip_delays_ids_list_of_lists), 2)
        matched_trip_ids = sorted(get_trusted_trips(trip_delays_ids_list_of_lists))
        self.assertEquals(matched_trip_ids, sorted(trip_ids))
Ejemplo n.º 4
0
    def test_matcher_on_partial_random_trip(self, trip_id = '010414_00168', seeds=[0,1,2,3], stop_counts=[3,4,5]):
        for seed in seeds:
            for stop_count in stop_counts:
                print 'seed =', seed, 'stop_count =', stop_count
                detected_stop_times_gtfs, relevant_service_ids = self.load_trip_info_for_matcher(trip_id)
                random.seed(seed)
                subset_inds = sorted(random.sample(xrange(0,len(detected_stop_times_gtfs)),stop_count))
                detected_stop_times_gtfs_subset = [detected_stop_times_gtfs[i] for i in subset_inds]
                trips, time_deviation_in_seconds = get_matched_trips('test_matcher_on_full_trip', detected_stop_times_gtfs,\
                                       relevant_service_ids, print_debug_info=True)

                matched_trip_id = get_trusted_trip_or_none(trips, time_deviation_in_seconds)        
                self.assertEquals(matched_trip_id, unicode(trip_id))
Ejemplo n.º 5
0
    def test_matcher_on_partial_random_trip(self, trip_id="010714_00115", seeds=[0, 1, 2, 3], stop_counts=[3, 4, 5]):
        for seed in seeds:
            for stop_count in stop_counts:
                print "seed =", seed, "stop_count =", stop_count
                detected_stop_times_gtfs, day = self.load_trip_info_for_matcher(trip_id)
                random.seed(seed)
                subset_inds = sorted(random.sample(xrange(0, len(detected_stop_times_gtfs)), stop_count))
                detected_stop_times_gtfs_subset = [detected_stop_times_gtfs[i] for i in subset_inds]
                trip_delays_ids_list_of_lists = get_matched_trips(
                    "test_matcher_on_full_trip", detected_stop_times_gtfs, day
                )

                self.assertEquals(len(trip_delays_ids_list_of_lists), 1)
                matched_trip_ids = get_trusted_trips(trip_delays_ids_list_of_lists)
                self.assertEquals(matched_trip_ids[0], unicode(trip_id))
Ejemplo n.º 6
0
def update_trips(tracker_id, day, detected_stop_times):
    logger.info('Updating trips for tracker_id={}'.format(tracker_id))
    trip_delays_ids_list_of_lists = trip_matcher.get_matched_trips(tracker_id, detected_stop_times, day)
    logger.info('Updated trip_delays_ids_list_of_lists for tracker_id={}: {}'.format(tracker_id, trip_delays_ids_list_of_lists))
    save_by_key(get_train_tracker_trip_delays_ids_list_of_lists_key(tracker_id), trip_delays_ids_list_of_lists)
    return trip_delays_ids_list_of_lists
Ejemplo n.º 7
0
def update_trips(tracker_id, detected_stop_times):
    relevant_service_ids = get_relevant_service_ids(tracker_id)
    trips, time_deviation_in_seconds = trip_matcher.get_matched_trips(tracker_id, detected_stop_times, relevant_service_ids)
    save_by_key(get_train_tracker_trip_ids_key(tracker_id), trips)
    save_by_key(get_train_tracker_trip_ids_deviation_seconds_key(tracker_id), time_deviation_in_seconds)
    return trips, time_deviation_in_seconds