From d09ef7168a8c953608ee920fbff8a47b2d0efa73 Mon Sep 17 00:00:00 2001 From: AboudyKreidieh Date: Mon, 19 Nov 2018 14:01:46 -0800 Subject: [PATCH 1/7] added ignores to coverage --- .coveragerc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.coveragerc b/.coveragerc index a5f7fcee8..ed09b4af3 100644 --- a/.coveragerc +++ b/.coveragerc @@ -3,3 +3,7 @@ omit = */python?.?/* */site-packages/nose/* *__init__* + +exclude_lines = + if __name__ == .__main__.: + raise NotImplementedError() From 66379ad99ecf12b0a49c317b2f22b5181284aa88 Mon Sep 17 00:00:00 2001 From: AboudyKreidieh Date: Mon, 19 Nov 2018 14:16:47 -0800 Subject: [PATCH 2/7] decreased the number of vehicles in bay bridge --- examples/sumo/bay_bridge.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/sumo/bay_bridge.py b/examples/sumo/bay_bridge.py index 1a86a39c5..97d063224 100644 --- a/examples/sumo/bay_bridge.py +++ b/examples/sumo/bay_bridge.py @@ -61,7 +61,7 @@ def bay_bridge_example(render=None, lane_change_mode="no_lat_collide", sumo_car_following_params=sumo_car_following_params, sumo_lc_params=sumo_lc_params, - num_vehicles=1400) + num_vehicles=1000) additional_env_params = {} env_params = EnvParams(additional_params=additional_env_params) From 828668833c647385ea8c7e698c4ab9e6499c853b Mon Sep 17 00:00:00 2001 From: AboudyKreidieh Date: Mon, 19 Nov 2018 14:18:00 -0800 Subject: [PATCH 3/7] fix to coverage --- .coveragerc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.coveragerc b/.coveragerc index ed09b4af3..f629a4510 100644 --- a/.coveragerc +++ b/.coveragerc @@ -6,4 +6,4 @@ omit = exclude_lines = if __name__ == .__main__.: - raise NotImplementedError() + raise NotImplementedError From 44f56361f287225b09460c16357cb22c8b2fa499 Mon Sep 17 00:00:00 2001 From: AboudyKreidieh Date: Mon, 19 Nov 2018 22:22:03 -0800 Subject: [PATCH 4/7] cleanup to tests --- .../fast_tests/test_environment_base_class.py | 13 ++------ tests/fast_tests/test_scenario_base_class.py | 14 ++++----- tests/fast_tests/test_util.py | 5 ++-- tests/fast_tests/test_vehicles.py | 30 +++++++++---------- 4 files changed, 25 insertions(+), 37 deletions(-) diff --git a/tests/fast_tests/test_environment_base_class.py b/tests/fast_tests/test_environment_base_class.py index b10aab9cd..ee61c873d 100644 --- a/tests/fast_tests/test_environment_base_class.py +++ b/tests/fast_tests/test_environment_base_class.py @@ -442,11 +442,7 @@ def tearDown(self): def test_get_state(self): """Checks that get_state raises an error.""" - try: - self.env.get_state() - raise AssertionError - except NotImplementedError: - return + self.assertRaises(NotImplementedError, self.env.get_state) def test_action_space(self): try: @@ -467,11 +463,8 @@ def test_compute_reward(self): self.assertEqual(self.env.compute_reward([]), 0) def test__apply_rl_actions(self): - try: - self.env._apply_rl_actions(None) - raise AssertionError - except NotImplementedError: - return + self.assertRaises(NotImplementedError, self.env._apply_rl_actions, + rl_actions=None) class TestVehicleColoring(unittest.TestCase): diff --git a/tests/fast_tests/test_scenario_base_class.py b/tests/fast_tests/test_scenario_base_class.py index 785c388ca..7a05b5302 100644 --- a/tests/fast_tests/test_scenario_base_class.py +++ b/tests/fast_tests/test_scenario_base_class.py @@ -348,8 +348,7 @@ def test_edges_distribution(self): # check that all vehicles are only placed in edges specified in the # edges_distribution term for veh_id in self.env.vehicles.get_ids(): - if self.env.vehicles.get_edge(veh_id) not in edges: - raise AssertionError + self.assertTrue(self.env.vehicles.get_edge(veh_id) in edges) def test_num_vehicles(self): """ @@ -487,9 +486,8 @@ def test_lanes_distribution(self): # verify that all vehicles are located in the number of allocated lanes for veh_id in self.env.vehicles.get_ids(): - if self.env.vehicles.get_lane(veh_id) >= \ - initial_config.lanes_distribution: - raise AssertionError + self.assertLess(self.env.vehicles.get_lane(veh_id), + initial_config.lanes_distribution) def test_edges_distribution(self): """ @@ -507,8 +505,7 @@ def test_edges_distribution(self): # check that all vehicles are only placed in edges specified in the # edges_distribution term for veh_id in self.env.vehicles.get_ids(): - if self.env.vehicles.get_edge(veh_id) not in edges: - raise AssertionError + self.assertTrue(self.env.vehicles.get_edge(veh_id) in edges) class TestEvenStartPosVariableLanes(unittest.TestCase): @@ -549,8 +546,7 @@ def test_even_start_pos_coverage(self): # check that all possible lanes are covered lanes = self.env.vehicles.get_lane(self.env.vehicles.get_ids()) - if any(i not in lanes for i in range(4)): - raise AssertionError + self.assertFalse(any(i not in lanes for i in range(4))) class TestRandomStartPosVariableLanes(TestEvenStartPosVariableLanes): diff --git a/tests/fast_tests/test_util.py b/tests/fast_tests/test_util.py index 06d5b0b05..2dc562d21 100644 --- a/tests/fast_tests/test_util.py +++ b/tests/fast_tests/test_util.py @@ -327,9 +327,8 @@ def search_dicts(obj1, obj2): # make sure that the Vehicles class that was imported matches the # original one - if not search_dicts(imported_flow_params["veh"].__dict__, - flow_params["veh"].__dict__): - raise AssertionError + self.assertTrue(search_dicts(imported_flow_params["veh"].__dict__, + flow_params["veh"].__dict__)) if __name__ == '__main__': diff --git a/tests/fast_tests/test_vehicles.py b/tests/fast_tests/test_vehicles.py index bcbf89138..ac2e9ad54 100644 --- a/tests/fast_tests/test_vehicles.py +++ b/tests/fast_tests/test_vehicles.py @@ -20,7 +20,7 @@ class TestVehiclesClass(unittest.TestCase): Tests various functions in the vehicles class """ - def runSpeedLaneChangeModes(self): + def test_speed_lane_change_modes(self): """ Check to make sure vehicle class correctly specifies lane change and speed modes @@ -33,7 +33,7 @@ def runSpeedLaneChangeModes(self): lane_change_mode="no_lat_collide") self.assertEqual(vehicles.get_speed_mode("typeA_0"), 1) - self.assertEqual(vehicles.get_lane_change_mode("typeA_0"), 256) + self.assertEqual(vehicles.get_lane_change_mode("typeA_0"), 512) vehicles.add( "typeB", @@ -42,7 +42,7 @@ def runSpeedLaneChangeModes(self): lane_change_mode="strategic") self.assertEqual(vehicles.get_speed_mode("typeB_0"), 0) - self.assertEqual(vehicles.get_lane_change_mode("typeB_0"), 853) + self.assertEqual(vehicles.get_lane_change_mode("typeB_0"), 1621) vehicles.add( "typeC", @@ -145,18 +145,18 @@ def test_remove(self): vehicles.remove("test_rl_0") # ensure that the removed vehicle's ID is not in any lists of vehicles - if "test_0" in vehicles.get_ids(): - raise AssertionError("vehicle still in get_ids()") - if "test_0" in vehicles.get_human_ids(): - raise AssertionError("vehicle still in get_controlled_lc_ids()") - if "test_0" in vehicles.get_controlled_lc_ids(): - raise AssertionError("vehicle still in get_controlled_lc_ids()") - if "test_0" in vehicles.get_controlled_ids(): - raise AssertionError("vehicle still in get_controlled_ids()") - if "test_rl_0" in vehicles.get_ids(): - raise AssertionError("RL vehicle still in get_ids()") - if "test_rl_0" in vehicles.get_rl_ids(): - raise AssertionError("RL vehicle still in get_rl_ids()") + self.assertTrue("test_0" not in vehicles.get_ids(), + msg="vehicle still in get_ids()") + self.assertTrue("test_0" not in vehicles.get_human_ids(), + msg="vehicle still in get_controlled_lc_ids()") + self.assertTrue("test_0" not in vehicles.get_controlled_lc_ids(), + msg="vehicle still in get_controlled_lc_ids()") + self.assertTrue("test_0" not in vehicles.get_controlled_ids(), + msg="vehicle still in get_controlled_ids()") + self.assertTrue("test_rl_0" not in vehicles.get_ids(), + msg="RL vehicle still in get_ids()") + self.assertTrue("test_rl_0" not in vehicles.get_rl_ids(), + msg="RL vehicle still in get_rl_ids()") # ensure that the vehicles are not storing extra information in the # vehicles.__vehicles dict From 2d912f240a43f2de23b9f599ef9cb12bc2e6314a Mon Sep 17 00:00:00 2001 From: Aboudy Kreidieh Date: Tue, 20 Nov 2018 00:37:42 -0800 Subject: [PATCH 5/7] undo change --- examples/sumo/bay_bridge.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/sumo/bay_bridge.py b/examples/sumo/bay_bridge.py index 97d063224..1a86a39c5 100644 --- a/examples/sumo/bay_bridge.py +++ b/examples/sumo/bay_bridge.py @@ -61,7 +61,7 @@ def bay_bridge_example(render=None, lane_change_mode="no_lat_collide", sumo_car_following_params=sumo_car_following_params, sumo_lc_params=sumo_lc_params, - num_vehicles=1000) + num_vehicles=1400) additional_env_params = {} env_params = EnvParams(additional_params=additional_env_params) From 9053d08f1dbce90967fbbd8389ce35f5e7bc0f9e Mon Sep 17 00:00:00 2001 From: AboudyKreidieh Date: Tue, 20 Nov 2018 10:26:23 -0800 Subject: [PATCH 6/7] removed setup from coverage --- .coveragerc | 1 + 1 file changed, 1 insertion(+) diff --git a/.coveragerc b/.coveragerc index f629a4510..6bb45cd24 100644 --- a/.coveragerc +++ b/.coveragerc @@ -3,6 +3,7 @@ omit = */python?.?/* */site-packages/nose/* *__init__* + */setup.py exclude_lines = if __name__ == .__main__.: From 14788809f381e0e406b87869ab494ecb275bf3a2 Mon Sep 17 00:00:00 2001 From: AboudyKreidieh Date: Mon, 26 Nov 2018 23:34:43 -0800 Subject: [PATCH 7/7] removing rllab from coverage report --- .coveragerc | 1 + 1 file changed, 1 insertion(+) diff --git a/.coveragerc b/.coveragerc index 6bb45cd24..24dcb8d27 100644 --- a/.coveragerc +++ b/.coveragerc @@ -4,6 +4,7 @@ omit = */site-packages/nose/* *__init__* */setup.py + *rllab* exclude_lines = if __name__ == .__main__.: