From 6d4024b77dabef878eb039b317d85106df3b2820 Mon Sep 17 00:00:00 2001 From: Raphael <raphael.sturgis@gmail.com> Date: Tue, 12 Apr 2022 11:22:37 +0200 Subject: [PATCH] solved bug --- skais/ais/ais_trajectory.py | 3 ++- skais/tests/ais/test_ais_trajectory.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/skais/ais/ais_trajectory.py b/skais/ais/ais_trajectory.py index a20abf4..f4ec956 100644 --- a/skais/ais/ais_trajectory.py +++ b/skais/ais/ais_trajectory.py @@ -306,7 +306,6 @@ class AISTrajectory(AISPoints): else: bounds = [] if type(features) is list: - nb_channels = len(features) features_vectors = self.df[features].to_numpy() for c in features_vectors.T: bounds.append((0, max(c))) @@ -319,6 +318,8 @@ class AISTrajectory(AISPoints): features_vectors = self.df[features.keys()].to_numpy() else: raise TypeError("Type not supported") + + nb_channels = len(features_vectors.T) data = np.zeros((height, width, nb_channels), dtype=np.float) diff --git a/skais/tests/ais/test_ais_trajectory.py b/skais/tests/ais/test_ais_trajectory.py index d22e22f..51d776c 100644 --- a/skais/tests/ais/test_ais_trajectory.py +++ b/skais/tests/ais/test_ais_trajectory.py @@ -631,7 +631,7 @@ class TestAISTrajectoryImageGeneration(unittest.TestCase): ) 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], [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], -- GitLab