Skip to content
Snippets Groups Projects
Commit 5b5a2d32 authored by Raphael Sturgis's avatar Raphael Sturgis
Browse files

added tests and function prototype for getting time stamps' for label changes

parent 58ca07aa
No related branches found
No related tags found
3 merge requests!12version 0.2a,!10Resolve "Image creation bugs with 0 size windows",!8Resolve "Get time windows for labels"
......@@ -214,3 +214,6 @@ class AISTrajectory(AISPoints):
return self
else:
return AISTrajectory(new_df, mmsi=self.mmsi)
def get_time_per_label_shift(self):
pass
\ No newline at end of file
......@@ -333,4 +333,49 @@ class TestAISTrajectory(unittest.TestCase):
expected = np.array([2, 2, 2, 2, 2])
np.testing.assert_equal(result, expected)
\ No newline at end of file
np.testing.assert_equal(result, expected)
def test_get_time_per_label_shift_single_label(self):
trajectory = AISTrajectory(
pd.DataFrame(
{
"label": [1 for _ in range(0, 101, 10)],
"ts_sec": [i for i in range(0, 6001, 600)]
}
)
)
result = trajectory.get_time_per_label_shift()
expected = [(0, 1)]
self.assertListEqual(result, expected)
def test_get_time_per_label_shift_label_switch_1(self):
trajectory = AISTrajectory(
pd.DataFrame(
{
"label": [1 for _ in range(0, 101, 10)] + [2 for _ in range(0, 101, 10)],
"ts_sec": [i for i in range(0, 12001, 600)]
}
)
)
result = trajectory.get_time_per_label_shift()
expected = [(0, 1), (6600, 2)]
self.assertListEqual(result, expected)
def test_get_time_per_label_shift_label_switch_2(self):
trajectory = AISTrajectory(
pd.DataFrame(
{
"label": [1 for _ in range(0, 101, 10)] + [2 for _ in range(0, 101, 10)]+ [1 for _ in range(0, 101, 10)],
"ts_sec": [i for i in range(0, 18001, 600)]
}
)
)
result = trajectory.get_time_per_label_shift()
expected = [(0, 1), (6600, 2), (12600, 1)]
self.assertListEqual(result, expected)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment