コード例 #1
0
 def test_is_on_time(self):
     dataset = buses.load_from_files(
         os.path.dirname(os.getcwd()) + '/buses_warsaw/data', 'data')
     locations_dataset = buses.load_bus_stops_from_file(
         os.path.dirname(os.getcwd()) + '/buses_warsaw/data',
         "bus_stops_0.txt")
     result = buses.is_on_time(
         dataset,
         locations_dataset,
         "Marszałkowska",
         "01",
         520,
         api_key='b2b6deb9-bb03-4279-b25d-55fa1bb97690')
     self.assertTrue(result <= 1)
     result = buses.is_on_time(
         dataset,
         locations_dataset,
         "Marszałkowska",
         "01",
         521,
         api_key='b2b6deb9-bb03-4279-b25d-55fa1bb97690')
     self.assertIsNone(result)
     result = buses.is_on_time(
         dataset,
         locations_dataset,
         "Marszałkowska",
         "99",
         520,
         api_key='b2b6deb9-bb03-4279-b25d-55fa1bb97690')
     self.assertIsNone(result)
コード例 #2
0
 def test_load_from_files(self):
     result = buses.load_from_files(
         os.path.dirname(os.getcwd()) + '/buses_warsaw/data', 'data')
     self.assertIsNot(result[0], [])
     self.assertEqual(result[0]["Lines"].dtypes, 'object')
     self.assertEqual(result[0]["Lon"].dtypes, 'float64')
     self.assertEqual(result[0]["VehicleNumber"].dtypes, 'int64')
     self.assertEqual(result[0]["Time"].dtypes, '<M8[ns]')
     self.assertEqual(result[0]["Lat"].dtypes, 'float64')
     self.assertEqual(result[0]["Brigade"].dtypes, 'object')
     self.assertRaises(ValueError, buses.load_from_files,
                       os.path.dirname(os.getcwd()) + '/buses_warsaw/data',
                       'bus_stops')
コード例 #3
0
 def test_percentage_exceeding_50(self):
     dataset = buses.load_from_files(
         os.path.dirname(os.getcwd()) + '/buses_warsaw/data', 'data')
     result = buses.percentage_exceeding_50(dataset, 52, 21, 100)
     self.assertTrue(result >= 0 and result <= 1)
コード例 #4
0
 def test_how_many_exceeded_50(self):
     dataset = buses.load_from_files(
         os.path.dirname(os.getcwd()) + '/buses_warsaw/data', 'data')
     result = buses.how_many_exceeded_50(dataset)
     self.assertTrue(result > 0)
コード例 #5
0
 def test_all_exceeding_50(self):
     dataset = buses.load_from_files(
         os.path.dirname(os.getcwd()) + '/buses_warsaw/data', 'data')
     result = buses.all_exceeding_50(dataset)
     self.assertTrue(result["Velocity"].ge(50).all())
コード例 #6
0
 def test_inst_velocity(self):
     dataset = buses.load_from_files(
         os.path.dirname(os.getcwd()) + '/buses_warsaw/data', 'data')
     v = buses.inst_velocity(dataset, 0, len(dataset) - 1)
     self.assertTrue(v["Velocity"][v["Velocity"].notna()].ge(0).all())
     self.assertTrue(v["Velocity"][v["Velocity"].notna()].le(200).all())
コード例 #7
0
 def test_time_difference(self):
     dataset = buses.load_from_files(
         os.path.dirname(os.getcwd()) + '/buses_warsaw/data', 'data')
     t = buses.time_difference(dataset, 0, len(dataset) - 1)
     self.assertTrue(t["Time_difference"].ge(0).all())
コード例 #8
0
 def test_distance(self):
     dataset = buses.load_from_files(
         os.path.dirname(os.getcwd()) + '/buses_warsaw/data', 'data')
     dist = buses.distance(dataset, 0, len(dataset) - 1)
     self.assertTrue(dist["Distance"].ge(0).all())
     self.assertTrue(dist["Distance"].le(70).all())