Skip to content
Snippets Groups Projects
Commit 6d4024b7 authored by Raphael's avatar Raphael
Browse files

solved bug

parent f77ecf10
No related branches found
No related tags found
2 merge requests!19Resolve "[fix] fix bug "IndexError: index 1 is out of bounds" when generating multi channel images",!13Draft: Develop
...@@ -306,7 +306,6 @@ class AISTrajectory(AISPoints): ...@@ -306,7 +306,6 @@ class AISTrajectory(AISPoints):
else: else:
bounds = [] bounds = []
if type(features) is list: if type(features) is list:
nb_channels = len(features)
features_vectors = self.df[features].to_numpy() features_vectors = self.df[features].to_numpy()
for c in features_vectors.T: for c in features_vectors.T:
bounds.append((0, max(c))) bounds.append((0, max(c)))
...@@ -319,6 +318,8 @@ class AISTrajectory(AISPoints): ...@@ -319,6 +318,8 @@ class AISTrajectory(AISPoints):
features_vectors = self.df[features.keys()].to_numpy() features_vectors = self.df[features.keys()].to_numpy()
else: else:
raise TypeError("Type not supported") raise TypeError("Type not supported")
nb_channels = len(features_vectors.T)
data = np.zeros((height, width, nb_channels), dtype=np.float) data = np.zeros((height, width, nb_channels), dtype=np.float)
......
...@@ -631,7 +631,7 @@ class TestAISTrajectoryImageGeneration(unittest.TestCase): ...@@ -631,7 +631,7 @@ class TestAISTrajectoryImageGeneration(unittest.TestCase):
) )
result = trajectory.generate_array_from_positions(height=9, width=18, link=True, bounding_box='fit', result = trajectory.generate_array_from_positions(height=9, width=18, link=True, bounding_box='fit',
features={'sog': (0, 40), 'cog': (0, 40)}, node_size=2) features={'sog': (0, 40), 'cog': (0, 40)}, node_size=0)
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], 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.5, 0.25]], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0.5, 0.25]],
[[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% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment