Пример #1
0
 def test_tracker_on_real_devices(self):    
     device_ids = []
     trip_suffixes_list = []
     device_ids.append('ofer_995357870c491cad')
     device_ids.append('ofer_207fabab5f381476')
     for device_id in device_ids:
         suffix_list = [x[x.index('_'):] for x in trip_ground_truth.data[device_id]]
         
         trip_suffixes_list.append(suffix_list)
     
     stop_detector_test.remove_from_redis(device_ids)
     
     for i in xrange(len(device_ids)):
         device_id = device_ids[i] 
         trip_suffixes = trip_suffixes_list[i]
         tracker_id, trips = track_device(device_id, do_preload_reports=True)
         for trip_id in trips:
             timetable.services.print_trip_stop_times(trip_id)
         stop_detector.print_tracked_stop_times(device_id)
         
         self.assertEquals(len(trips), len(trip_suffixes))
         for trip_suffix in trip_suffixes:
             self.assertTrue(self.is_trip_in_list(trips, trip_suffix))
   
     stop_detector_test.remove_from_redis(device_ids)
Пример #2
0
    def test_tracker_on_mock_device(self,
                                    device_id='fake_device_1',
                                    trip_ids=['010714_00115'],
                                    remove_some_locations=True):
        if not isinstance(trip_ids, list):
            trip_ids = [trip_ids]
        tracker_id = device_id
        stop_detector_test.remove_from_redis(tracker_id)
        reports = []
        for trip_id in trip_ids:
            day = datetime.datetime.strptime(trip_id.split('_')[0], '%d%m%y')
            now = ot_utils.get_localtime_now(
            )  # we want to get the correct timezone so we take it from get_localtime_now()
            day = now.replace(year=day.year, month=day.month, day=day.day)
            trip_reports = generate_mock_reports(
                device_id=device_id,
                trip_id=trip_id,
                nostop_percent=0.05,
                day=day)
            reports += trip_reports

        if remove_some_locations:
            for report in reports[::2]:
                del report.my_loc_mock
            logger.addFilter(
                MessageExcludeFilter(
                    'skipped because it has not location data'))

        matched_trips = self.track_mock_reports(reports, tracker_id)
        for matched_trip in matched_trips:
            timetable.services.get_trip(matched_trip).print_stoptimes()
        self.assertEquals(len(matched_trips), len(trip_ids))
        self.assertEquals(sorted(matched_trips), sorted(trip_ids))
        stop_detector_test.remove_from_redis(tracker_id)
def run_tracker_on_trips_without_ground_truth(device_ids=None):    
    trip_suffixes_list = []
    if not device_ids:
        device_ids = [x for x in trip_ground_truth.data if not trip_ground_truth.data[x]]
    
    stop_detector_test.remove_from_redis(device_ids)
    
    for i in xrange(len(device_ids)):
        device_id = device_ids[i] 
        tracker_id, trips = train_tracker_test.track_device(device_id, do_preload_reports=True, report_limit=100)
        print 'DEVICE_ID=%s' % device_id
        for trip_id in trips:
            timetable.services.print_trip_stop_times(trip_id)
        stop_detector.print_tracked_stop_times(device_id)
        
    stop_detector_test.remove_from_redis(device_ids)
Пример #4
0
    def test_tracker_on_mock_device(self, device_id = 'fake_device_1', trip_ids = ['010414_00168'], remove_some_locations=True):
        if not isinstance(trip_ids, list):
            trip_ids = [trip_ids]
        tracker_id = device_id
        stop_detector_test.remove_from_redis(tracker_id)
        reports = []
        for trip_id in trip_ids:
            day = datetime.datetime.strptime(trip_id.split('_')[0], '%d%m%y')
            now = ot_utils.get_localtime_now() # we want to get the correct timezone so we take it from get_localtime_now()
            day = now.replace(year=day.year, month=day.month, day=day.day)
            trip_reports = generate_mock_reports(device_id=device_id, trip_id=trip_id, nostop_percent=0.05, day=day)
            reports += trip_reports

        for report in reports[::2]:
            del report.my_loc_mock
        
        matched_trip = self.track_mock_reports(reports, tracker_id)
        if matched_trip:
            gtfs.models.Trip.objects.filter(trip_id = matched_trip)[0].print_stoptimes()
        self.assertEquals(matched_trip, trip_id)
        stop_detector_test.remove_from_redis(tracker_id)        
Пример #5
0
    def test_tracker_on_real_devices(self):    
        device_ids = []
        trip_suffixes_list = []
        device_ids.append('1cb87f1e')# Udi's trip  
        trip_suffixes_list.append(['_00073'])
        device_ids.append('02090d12')# Eran's trip
        trip_suffixes_list.append(['_00077'])
        device_ids.append('f752c40d')# Ofer's trip
        trip_suffixes_list.append(['_00283'])

        stop_detector_test.remove_from_redis(device_ids)
        
        for i in xrange(len(device_ids)):
            device_id = device_ids[i] 
            trip_suffixes = trip_suffixes_list[i]
            tracker_id, trips = self.track_device(device_id, do_preload_reports=True)
            print trips
            self.assertEquals(len(trips), len(trip_suffixes))
            for trip_suffix in trip_suffixes:
                self.assertTrue(self.is_trip_in_list(trips, trip_suffix))
      
        stop_detector_test.remove_from_redis(device_ids)