From 2874e51c57e5325ffd7f0f7f32e56fbe81af5038 Mon Sep 17 00:00:00 2001
From: Raphael <raphael.sturgis@lis-lab.fr>
Date: Sun, 14 Nov 2021 08:36:40 +0100
Subject: [PATCH] fixed circular import

---
 skais/ais/ais_points.py            | 14 -------------
 skais/process/ais_operations.py    | 14 +++++++++++++
 skais/tests/ais/test_ais_points.py | 32 ------------------------------
 3 files changed, 14 insertions(+), 46 deletions(-)
 create mode 100644 skais/process/ais_operations.py

diff --git a/skais/ais/ais_points.py b/skais/ais/ais_points.py
index 470562d..3367cfd 100644
--- a/skais/ais/ais_points.py
+++ b/skais/ais/ais_points.py
@@ -2,8 +2,6 @@ import numpy as np
 import pandas as pd
 from scipy.stats import stats
 
-from skais.ais.ais_trajectory import AISTrajectory
-
 
 # def compute_trajectories(df, time_gap, min_size=50, size_limit=500, interpolation_time=None):
 #     n_sample = len(df.index)
@@ -108,18 +106,6 @@ class AISPoints:
         self.df["drift"] = self.df.apply(lambda x: 180 - abs(abs(x['heading'] - x['cog']) - 180),
                                          axis=1)
 
-    # Trajectories
-    """
-        Separates AISPoints into individual trajectories
-    """
-
-    def get_trajectories(self):
-        trajectories = []
-        for mmsi in self.df.mmsi.unique():
-            trajectories.append(AISTrajectory(self.df[self.df['mmsi'] == mmsi].reset_index(drop=True)))
-
-        return trajectories
-
     # Static methods
     @staticmethod
     def fuse(*args):
diff --git a/skais/process/ais_operations.py b/skais/process/ais_operations.py
new file mode 100644
index 0000000..1075fd0
--- /dev/null
+++ b/skais/process/ais_operations.py
@@ -0,0 +1,14 @@
+from skais.ais.ais_trajectory import AISTrajectory
+
+# Trajectories
+"""
+    Separates AISPoints into individual trajectories
+"""
+
+
+def get_trajectories(ais_points):
+    trajectories = []
+    for mmsi in ais_points.df.mmsi.unique():
+        trajectories.append(AISTrajectory(ais_points.df[ais_points.df['mmsi'] == mmsi].reset_index(drop=True)))
+
+    return trajectories
diff --git a/skais/tests/ais/test_ais_points.py b/skais/tests/ais/test_ais_points.py
index 48d8c01..eea6ea7 100644
--- a/skais/tests/ais/test_ais_points.py
+++ b/skais/tests/ais/test_ais_points.py
@@ -179,38 +179,6 @@ class TestAISPositions(unittest.TestCase):
                                                       40, 30, 20, 10, 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110,
                                                       120, 130, 140, 150, 160, 170]))
 
-    def test_get_trajectories(self):
-        ais_points = AISPoints(
-            pd.DataFrame(
-                {
-                    "mmsi": [123456789 for _ in range(10)] + [987654321 for _ in range(10)],
-                    "ts_sec": [i for i in range(20)]
-                }
-            )
-        )
-
-        expected = [
-            AISTrajectory(
-                pd.DataFrame(
-                    {
-                        "mmsi": [123456789 for _ in range(10)],
-                        "ts_sec": [i for i in range(10)]
-                    }
-                )
-            ),
-            AISTrajectory(
-                pd.DataFrame(
-                    {
-                        "mmsi": [987654321 for _ in range(10)],
-                        "ts_sec": [10+ i for i in range(10)]
-                    }
-                )
-            )
-        ]
-
-        for expected_trajectory, result_trajectory in zip(expected, ais_points.get_trajectories()):
-            pd.testing.assert_frame_equal(expected_trajectory.df, result_trajectory.df)
-
     # def test_histogram_no_label_simple(self):
     #     result = np.histogramdd(self.ais_points.df[["sog", "diff"]].to_numpy(), 3, [[0, 30], [0, 180]])[0]
     #
-- 
GitLab