adding comments
This commit is contained in:
parent
df134673f6
commit
2c2b3310ab
|
@ -109,7 +109,7 @@ class Recording(object):
|
|||
path_distance, remaining_distance,
|
||||
final_time, time_out, result):
|
||||
"""
|
||||
Method to record the summary of an episode(pose) execution
|
||||
Method to record the summary of an episode(pose) execution
|
||||
"""
|
||||
|
||||
self._dict_summary['exp_id'] = experiment.task
|
||||
|
@ -253,11 +253,11 @@ class Recording(object):
|
|||
line_on_file = self._get_last_position() - 1
|
||||
if line_on_file == 0:
|
||||
return 0, 0
|
||||
else:
|
||||
return line_on_file % number_poses_task, line_on_file // number_poses_task
|
||||
|
||||
return line_on_file % number_poses_task, line_on_file // number_poses_task
|
||||
|
||||
def _experiment_exist(self):
|
||||
|
||||
""" Check if the experiment exists"""
|
||||
return os.path.exists(self._path)
|
||||
|
||||
def _get_last_position(self):
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import os
|
||||
import unittest
|
||||
from carla.driving_benchmark.recording import Recording
|
||||
|
||||
|
@ -5,11 +6,8 @@ from carla.driving_benchmark.recording import Recording
|
|||
class testRecording(unittest.TestCase):
|
||||
|
||||
def test_init(self):
|
||||
import os
|
||||
|
||||
"""
|
||||
The recording should have a reasonable full name
|
||||
|
||||
"""
|
||||
|
||||
recording = Recording(name_to_save='Test1',
|
||||
|
@ -22,8 +20,9 @@ class testRecording(unittest.TestCase):
|
|||
self.assertEqual(len(os.listdir(recording._path)), 3)
|
||||
|
||||
def test_write_summary_results(self):
|
||||
|
||||
import os
|
||||
"""
|
||||
Test writting summary results.
|
||||
"""
|
||||
from carla.driving_benchmark.experiment import Experiment
|
||||
|
||||
recording = Recording(name_to_save='Test1',
|
||||
|
@ -47,14 +46,16 @@ class testRecording(unittest.TestCase):
|
|||
self.assertEqual(len(written_row), len(recording._dict_summary))
|
||||
|
||||
def test_write_summary_results_good_order(self):
|
||||
"""
|
||||
Test if the summary results are writen in the same order on a new process
|
||||
"""
|
||||
|
||||
from carla.driving_benchmark.experiment import Experiment
|
||||
|
||||
recording = Recording(name_to_save='Test_good_order',
|
||||
continue_experiment=False, save_images=True
|
||||
)
|
||||
continue_experiment=False, save_images=True)
|
||||
|
||||
for i in range(0, 10):
|
||||
for _ in range(0, 10):
|
||||
recording.write_summary_results(experiment=Experiment(), pose=[24, 32], rep=1,
|
||||
path_distance=200, remaining_distance=0,
|
||||
final_time=0.2, time_out=49, result=1)
|
||||
|
@ -62,7 +63,7 @@ class testRecording(unittest.TestCase):
|
|||
recording = Recording(name_to_save='Test_good_order',
|
||||
continue_experiment=True, save_images=True)
|
||||
|
||||
for i in range(0, 10):
|
||||
for _ in range(0, 10):
|
||||
recording.write_summary_results(experiment=Experiment(), pose=[24, 32], rep=1,
|
||||
path_distance=200, remaining_distance=0,
|
||||
final_time=0.2, time_out=49, result=1)
|
||||
|
@ -70,7 +71,7 @@ class testRecording(unittest.TestCase):
|
|||
recording = Recording(name_to_save='Test_good_order',
|
||||
continue_experiment=True, save_images=True)
|
||||
|
||||
for i in range(0, 10):
|
||||
for _ in range(0, 10):
|
||||
recording.write_summary_results(experiment=Experiment(), pose=[24, 32], rep=1,
|
||||
path_distance=200, remaining_distance=0,
|
||||
final_time=0.2, time_out=49, result=1)
|
||||
|
@ -78,12 +79,17 @@ class testRecording(unittest.TestCase):
|
|||
recording = Recording(name_to_save='Test_good_order',
|
||||
continue_experiment=True, save_images=True)
|
||||
|
||||
for i in range(0, 10):
|
||||
for _ in range(0, 10):
|
||||
recording.write_summary_results(experiment=Experiment(), pose=[24, 32], rep=1,
|
||||
path_distance=200, remaining_distance=0,
|
||||
final_time=0.2, time_out=49, result=1)
|
||||
|
||||
# Check if the the test_good_order summaries have all the same files.
|
||||
|
||||
def test_write_measurements_results(self):
|
||||
"""
|
||||
Test writing a few measurements into the log
|
||||
"""
|
||||
|
||||
import os
|
||||
from carla.driving_benchmark.experiment import Experiment
|
||||
|
@ -93,8 +99,8 @@ class testRecording(unittest.TestCase):
|
|||
recording = Recording(name_to_save='Test1',
|
||||
continue_experiment=False, save_images=True)
|
||||
|
||||
reward_vec = [Measurements().player_measurements for x in range(20)]
|
||||
control_vec = [Control() for x in range(25)]
|
||||
reward_vec = [Measurements().player_measurements for _ in range(20)]
|
||||
control_vec = [Control() for _ in range(25)]
|
||||
|
||||
recording.write_measurements_results(experiment=Experiment(),
|
||||
rep=1, pose=[24, 32], reward_vec=reward_vec,
|
||||
|
@ -114,7 +120,9 @@ class testRecording(unittest.TestCase):
|
|||
self.assertEqual(len(written_row), len(recording._dict_measurements))
|
||||
|
||||
def test_continue_experiment(self):
|
||||
|
||||
"""
|
||||
Test if you are able to continue an experiment after restarting the process
|
||||
"""
|
||||
recording = Recording(name_to_save='Test1',
|
||||
continue_experiment=False, save_images=True)
|
||||
|
||||
|
@ -138,6 +146,9 @@ class testRecording(unittest.TestCase):
|
|||
self.assertEqual(recording._continue_experiment(False)[1], 1)
|
||||
|
||||
def test_get_pose_and_experiment(self):
|
||||
"""
|
||||
Test getting the pose and the experiment from a previous executed benchmark
|
||||
"""
|
||||
|
||||
recording = Recording(name_to_save='Test1',
|
||||
continue_experiment=False, save_images=True)
|
||||
|
@ -162,7 +173,7 @@ class testRecording(unittest.TestCase):
|
|||
self.assertEqual(pose, 2)
|
||||
self.assertEqual(experiment, 0)
|
||||
|
||||
for i in range(23):
|
||||
for _ in range(23):
|
||||
recording.write_summary_results(experiment=Experiment(), pose=[24, 32], rep=1,
|
||||
path_distance=200, remaining_distance=0,
|
||||
final_time=0.2, time_out=49, result=1)
|
||||
|
@ -171,7 +182,7 @@ class testRecording(unittest.TestCase):
|
|||
self.assertEqual(pose, 0)
|
||||
self.assertEqual(experiment, 1)
|
||||
|
||||
for i in range(23):
|
||||
for _ in range(23):
|
||||
recording.write_summary_results(experiment=Experiment(), pose=[24, 32], rep=1,
|
||||
path_distance=200, remaining_distance=0,
|
||||
final_time=0.2, time_out=49, result=1)
|
||||
|
@ -181,7 +192,9 @@ class testRecording(unittest.TestCase):
|
|||
self.assertEqual(experiment, 1)
|
||||
|
||||
def test_get_pose_and_experiment_corner(self):
|
||||
|
||||
"""
|
||||
Test getting the pose from multiple cases.
|
||||
"""
|
||||
from carla.driving_benchmark.experiment import Experiment
|
||||
|
||||
recording = Recording(name_to_save='Test1',
|
||||
|
|
Loading…
Reference in New Issue