Skip to content
Snippets Groups Projects

Draft: Develop

Open Raphael Sturgis requested to merge develop into main
1 file
+ 62
13
Compare changes
  • Side-by-side
  • Inline
@@ -380,8 +380,9 @@ class TestAISTrajectory(unittest.TestCase):
self.assertListEqual(result, expected)
def test_generate_array_from_positions(self):
trajectory = AISTrajectory(
class TestAISTrajectoryImageGeneration(unittest.TestCase):
def setUp(self) -> None:
self.trajectory = AISTrajectory(
pd.DataFrame(
{
"latitude": [0, 10, 0, -10],
@@ -391,7 +392,8 @@ class TestAISTrajectory(unittest.TestCase):
)
)
result = trajectory.generate_array_from_positions(height=9, width=9, link=False, bounding_box='fit',
def test_generate_array_from_positions(self):
result = self.trajectory.generate_array_from_positions(height=9, width=9, link=False, bounding_box='fit',
features=None, node_size=0).reshape((9, 9))
expected = np.array([[0, 0, 0, 0, 0, 0, 0, 0, 1],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
@@ -406,17 +408,8 @@ class TestAISTrajectory(unittest.TestCase):
np.testing.assert_array_equal(result, expected)
def test_generate_array_from_positions_node_size(self):
trajectory = AISTrajectory(
pd.DataFrame(
{
"latitude": [0, 10, 0, -10],
"longitude": [0, 10, 10, -10],
"ts_sec": [i for i in range(4)]
}
)
)
result = trajectory.generate_array_from_positions(height=9, width=9, link=False, bounding_box='fit',
result = self.trajectory.generate_array_from_positions(height=9, width=9, link=False, bounding_box='fit',
features=None, node_size=1).reshape((9, 9))
expected = np.array([[0, 0, 0, 0, 0, 0, 0, 1, 1],
[0, 0, 0, 0, 0, 0, 0, 1, 1],
@@ -556,4 +549,60 @@ class TestAISTrajectory(unittest.TestCase):
[[0,0], [0.25,1], [0.25,1], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0.25,0.5], [0.25,0.5], [0,0], [0.5,0.25]],
[[0.25,1], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0.25,0.5], [0.5,0.25]]])
np.testing.assert_array_equal(result, expected)
def test_generate_array_centered(self):
result = self.trajectory.generate_array_from_positions(height=9, width=9, link=False, bounding_box='centered',
features=None, node_size=0).reshape((9, 9))
expected = np.array([[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 1, 0, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[1, 0, 0, 0, 0, 0, 0, 0, 0]])
np.testing.assert_array_equal(result, expected)
def test_generate_array_bounding_box(self):
result = self.trajectory.generate_array_from_positions(height=9, width=9, link=False, bounding_box=[(0, 0), (10,10)],
features=None, node_size=0).reshape((9, 9))
expected = np.array([[0, 0, 0, 0, 0, 0, 0, 0, 1],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[1, 0, 0, 0, 0, 0, 0, 0, 0]])
np.testing.assert_array_equal(result, expected)
def test_generate_array_from_positions_with_line_grey_scale(self):
trajectory = AISTrajectory(
pd.DataFrame(
{
"latitude": [0, 10, 0, 20],
"longitude": [0, 10, 20, 20],
"ts_sec": [i for i in range(4)],
"sog": [10,10,20,40]
}
)
)
result = trajectory.generate_array_from_positions(height=9, width=18, link=True, bounding_box='fit',
features=("sog", (0,80)), node_size=0).reshape((9, 18))
expected = np.array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.5],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.5],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.5],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.5],
[0, 0, 0, 0, 0, 0, 0, 0.25, 0.25, 0.25, 0, 0, 0, 0, 0, 0, 0, 0.5],
[0, 0, 0, 0, 0, 0.25, 0.25, 0, 0, 0, 0.25, 0.25, 0, 0, 0, 0, 0, 0.5],
[0, 0, 0, 0.25, 0.25, 0, 0, 0, 0, 0, 0, 0, 0.25, 0.25, 0, 0, 0, 0.5],
[0, 0.25, 0.25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.25, 0.25, 0, 0.5],
[0.25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.25, 0.5]])/2
np.testing.assert_array_equal(result, expected)
\ No newline at end of file
Loading