aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/argaze.test/AreaOfInterest/AOI2DScene.py40
-rw-r--r--src/argaze.test/AreaOfInterest/AOI3DScene.py40
-rw-r--r--src/argaze.test/AreaOfInterest/AOIFeatures.py52
3 files changed, 92 insertions, 40 deletions
diff --git a/src/argaze.test/AreaOfInterest/AOI2DScene.py b/src/argaze.test/AreaOfInterest/AOI2DScene.py
index 8a71ffb..35f0f17 100644
--- a/src/argaze.test/AreaOfInterest/AOI2DScene.py
+++ b/src/argaze.test/AreaOfInterest/AOI2DScene.py
@@ -149,6 +149,46 @@ class TestAOI2DSceneClass(unittest.TestCase):
self.assertEqual(aoi_ratio, 0.)
self.assertEqual(gaze_ratio, 0.)
+ def test_copy(self):
+ """Test AOI2DScene copy method."""
+
+ aoi_2D_A = AOIFeatures.AreaOfInterest([[0, 0], [0, 1], [1, 1], [1, 0]])
+ aoi_2D_B = AOIFeatures.AreaOfInterest([[1, 1], [1, 2], [2, 2], [2, 1]])
+ aoi_2d_scene = AOI2DScene.AOI2DScene({"A": aoi_2D_A, "B": aoi_2D_B})
+
+ # Check full copy
+ aoi_2d_scene_copy = aoi_2d_scene.copy()
+
+ self.assertEqual(aoi_2d_scene_copy.dimension, 2)
+ self.assertEqual(len(aoi_2d_scene_copy.items()), 2)
+ self.assertEqual(list(aoi_2d_scene_copy.keys()), ["A", "B"])
+
+ # Check cpy with exclusion
+ aoi_2d_scene_copy = aoi_2d_scene.copy(exclude=["B"])
+
+ self.assertEqual(aoi_2d_scene_copy.dimension, 2)
+ self.assertEqual(len(aoi_2d_scene_copy.items()), 1)
+ self.assertEqual(list(aoi_2d_scene_copy.keys()), ["A"])
+
+class TestTimeStampedAOIScenesClass(unittest.TestCase):
+ """Test TimeStampedAOIScenes class."""
+
+ def test___setitem__(self):
+ """Test TimeStampedAOIScenes creation."""
+
+ aoi_2D_A = AOIFeatures.AreaOfInterest([[0, 0], [0, 1], [1, 1], [1, 0]])
+ aoi_2D_B = AOIFeatures.AreaOfInterest([[1, 1], [1, 2], [2, 2], [2, 1]])
+ aoi_2d_scene = AOI2DScene.AOI2DScene({"A": aoi_2D_A, "B": aoi_2D_B})
+
+ ts_aois_scenes = AOIFeatures.TimeStampedAOIScenes()
+
+ ts_aois_scenes[0] = aoi_2d_scene
+
+ # Check that only AOIScene can be added
+ with self.assertRaises(AssertionError):
+
+ ts_aois_scenes[1] = "This string is not an AOI2DScene"
+
if __name__ == '__main__':
unittest.main() \ No newline at end of file
diff --git a/src/argaze.test/AreaOfInterest/AOI3DScene.py b/src/argaze.test/AreaOfInterest/AOI3DScene.py
index 5a575bb..e74e246 100644
--- a/src/argaze.test/AreaOfInterest/AOI3DScene.py
+++ b/src/argaze.test/AreaOfInterest/AOI3DScene.py
@@ -71,6 +71,46 @@ class TestAOI3DSceneClass(unittest.TestCase):
self.assertIsNone(numpy.testing.assert_array_equal(aoi_3d_scene['B'], [[2.0, 1.0, 0.0], [2.0, 2.0, 0.0], [3.0, 2.0, 0.0], [3.0, 1.0, 0.0]]))
+ def test_copy(self):
+ """Test AOI2DScene copy method."""
+
+ aoi_3D_A = AOIFeatures.AreaOfInterest([[0, 0, 0], [0, 1, 0], [1, 1, 0], [1, 0, 0]])
+ aoi_3D_B = AOIFeatures.AreaOfInterest([[1, 1, 0], [1, 2, 0], [2, 2, 0], [2, 1, 0]])
+ aoi_3d_scene = AOI3DScene.AOI3DScene({"A": aoi_3D_A, "B": aoi_3D_B})
+
+ # Check full copy
+ aoi_3d_scene_copy = aoi_3d_scene.copy()
+
+ self.assertEqual(aoi_3d_scene_copy.dimension, 3)
+ self.assertEqual(len(aoi_3d_scene_copy.items()), 2)
+ self.assertEqual(list(aoi_3d_scene_copy.keys()), ["A", "B"])
+
+ # Check cpy with exclusion
+ aoi_3d_scene_copy = aoi_3d_scene.copy(exclude=["B"])
+
+ self.assertEqual(aoi_3d_scene_copy.dimension, 3)
+ self.assertEqual(len(aoi_3d_scene_copy.items()), 1)
+ self.assertEqual(list(aoi_3d_scene_copy.keys()), ["A"])
+
+class TestTimeStampedAOIScenesClass(unittest.TestCase):
+ """Test TimeStampedAOIScenes class."""
+
+ def test___setitem__(self):
+ """Test TimeStampedAOIScenes creation."""
+
+ aoi_3D_A = AOIFeatures.AreaOfInterest([[0, 0, 0], [0, 1, 0], [1, 1, 0], [1, 0, 0]])
+ aoi_3D_B = AOIFeatures.AreaOfInterest([[1, 1, 0], [1, 2, 0], [2, 2, 0], [2, 1, 0]])
+ aoi_3d_scene = AOI3DScene.AOI3DScene({"A": aoi_3D_A, "B": aoi_3D_B})
+
+ ts_aois_scenes = AOIFeatures.TimeStampedAOIScenes()
+
+ ts_aois_scenes[0] = aoi_3d_scene
+
+ # Check that only AOIScene can be added
+ with self.assertRaises(AssertionError):
+
+ ts_aois_scenes[1] = "This string is not an AOI3DScene"
+
if __name__ == '__main__':
unittest.main() \ No newline at end of file
diff --git a/src/argaze.test/AreaOfInterest/AOIFeatures.py b/src/argaze.test/AreaOfInterest/AOIFeatures.py
index 650411a..0a5e44c 100644
--- a/src/argaze.test/AreaOfInterest/AOIFeatures.py
+++ b/src/argaze.test/AreaOfInterest/AOIFeatures.py
@@ -126,6 +126,18 @@ class TestAOISceneClass(unittest.TestCase):
self.assertEqual(len(aoi_2d_scene.items()), 1)
self.assertEqual(list(aoi_2d_scene.keys()), ["A"])
+ def test___set_item__(self):
+ """Test AOIScene __set_item__ method."""
+
+ aoi_2d_scene = AOIFeatures.AOIScene(2,)
+
+ # Check AOI with same dimension can be added
+ aoi_2d_scene["A"] = AOIFeatures.AreaOfInterest([[0, 0], [0, 1], [1, 1], [1, 0]])
+
+ # Check that AOI with different dimension fails
+ with self.assertRaises(AssertionError):
+ aoi_2d_scene["B"] = AOIFeatures.AreaOfInterest([[0, 0, 0], [0, 1, 0], [1, 1, 0], [1, 0, 0]])
+
def test___repr__(self):
"""Test AOIScene string representation."""
@@ -159,46 +171,6 @@ class TestAOISceneClass(unittest.TestCase):
self.assertIsNone(numpy.testing.assert_array_equal(aoi_2d_scene.center, [1, 1]))
self.assertIsNone(numpy.testing.assert_array_equal(aoi_2d_scene.size, [2, 2]))
- def test_copy(self):
- """Test AOIScene copy method."""
-
- aoi_2D_A = AOIFeatures.AreaOfInterest([[0, 0], [0, 1], [1, 1], [1, 0]])
- aoi_2D_B = AOIFeatures.AreaOfInterest([[1, 1], [1, 2], [2, 2], [2, 1]])
- aoi_2d_scene = AOIFeatures.AOIScene(2, {"A": aoi_2D_A, "B": aoi_2D_B})
-
- # Check full copy
- aoi_2d_scene_copy = aoi_2d_scene.copy()
-
- self.assertEqual(aoi_2d_scene_copy.dimension, 2)
- self.assertEqual(len(aoi_2d_scene_copy.items()), 2)
- self.assertEqual(list(aoi_2d_scene_copy.keys()), ["A", "B"])
-
- # Check cpy with exclusion
- aoi_2d_scene_copy = aoi_2d_scene.copy(exclude=["B"])
-
- self.assertEqual(aoi_2d_scene_copy.dimension, 2)
- self.assertEqual(len(aoi_2d_scene_copy.items()), 1)
- self.assertEqual(list(aoi_2d_scene_copy.keys()), ["A"])
-
-class TestTimeStampedAOIScenesClass(unittest.TestCase):
- """Test TimeStampedAOIScenes class."""
-
- def test___setitem__(self):
- """Test TimeStampedAOIScenes creation."""
-
- aoi_2D_A = AOIFeatures.AreaOfInterest([[0, 0], [0, 1], [1, 1], [1, 0]])
- aoi_2D_B = AOIFeatures.AreaOfInterest([[1, 1], [1, 2], [2, 2], [2, 1]])
- aoi_2d_scene = AOIFeatures.AOIScene(2, {"A": aoi_2D_A, "B": aoi_2D_B})
-
- ts_aois_scenes = AOIFeatures.TimeStampedAOIScenes()
-
- ts_aois_scenes[0] = aoi_2d_scene
-
- # Check that only AOIScene can be added
- with self.assertRaises(AssertionError):
-
- ts_aois_scenes[1] = "This string is not an AOIScene"
-
if __name__ == '__main__':
unittest.main() \ No newline at end of file