aboutsummaryrefslogtreecommitdiff
path: root/src/argaze.test
diff options
context:
space:
mode:
authorThéo de la Hogue2023-05-30 13:34:44 +0200
committerThéo de la Hogue2023-05-30 13:34:44 +0200
commit2c296a5adc88d9fde36d6c8e24ca275a7088a8f9 (patch)
treeda87a530eb8b64355df90377d6abf06d6df07763 /src/argaze.test
parentb1c5eaa9974d91263083ea457b65ad60c20cca85 (diff)
downloadargaze-2c296a5adc88d9fde36d6c8e24ca275a7088a8f9.zip
argaze-2c296a5adc88d9fde36d6c8e24ca275a7088a8f9.tar.gz
argaze-2c296a5adc88d9fde36d6c8e24ca275a7088a8f9.tar.bz2
argaze-2c296a5adc88d9fde36d6c8e24ca275a7088a8f9.tar.xz
Updating tests.
Diffstat (limited to 'src/argaze.test')
-rw-r--r--src/argaze.test/ArUcoMarkers/ArUcoScene.py10
-rw-r--r--src/argaze.test/GazeFeatures.py11
-rw-r--r--src/argaze.test/PupilAnalysis/WorkloadIndex.py5
3 files changed, 19 insertions, 7 deletions
diff --git a/src/argaze.test/ArUcoMarkers/ArUcoScene.py b/src/argaze.test/ArUcoMarkers/ArUcoScene.py
index ee618d8..5e24995 100644
--- a/src/argaze.test/ArUcoMarkers/ArUcoScene.py
+++ b/src/argaze.test/ArUcoMarkers/ArUcoScene.py
@@ -130,7 +130,8 @@ class TestArUcoSceneClass(unittest.TestCase):
# Check consistent markers, unconsistent markers and unconsistencies
self.assertEqual(len(consistent_markers), 3)
self.assertEqual(len(unconsistent_markers), 0)
- self.assertEqual(len(unconsistencies), 0)
+ self.assertEqual(len(unconsistencies['rotation']), 0)
+ self.assertEqual(len(unconsistencies['translation']), 0)
self.assertIsNone(numpy.testing.assert_array_equal(list(consistent_markers.keys()), self.aruco_scene.identifiers))
@@ -143,10 +144,13 @@ class TestArUcoSceneClass(unittest.TestCase):
# Check consistent markers, unconsistent markers and unconsistencies
self.assertEqual(len(consistent_markers), 2)
self.assertEqual(len(unconsistent_markers), 1)
- self.assertEqual(len(unconsistencies), 2)
+ self.assertEqual(len(unconsistencies['rotation']), 0)
+ self.assertEqual(len(unconsistencies['translation']), 2)
self.assertIsNone(numpy.testing.assert_array_equal(list(unconsistent_markers.keys()), [2]))
- self.assertIsNone(numpy.testing.assert_array_equal(list(unconsistencies.keys()), ['0/2 distance', '1/2 distance']))
+ self.assertIsNone(numpy.testing.assert_array_equal(list(unconsistencies['translation'].keys()), ['0/2', '1/2']))
+ self.assertIsNone(numpy.testing.assert_array_equal(list(unconsistencies['translation']['0/2'].keys()), ['current', 'expected']))
+ self.assertIsNone(numpy.testing.assert_array_equal(list(unconsistencies['translation']['1/2'].keys()), ['current', 'expected']))
def test_estimate_pose_from_single_marker(self):
"""Test ArUcoScene pose estimation from single marker."""
diff --git a/src/argaze.test/GazeFeatures.py b/src/argaze.test/GazeFeatures.py
index d6c32ed..f440a4e 100644
--- a/src/argaze.test/GazeFeatures.py
+++ b/src/argaze.test/GazeFeatures.py
@@ -273,7 +273,7 @@ class TestAOIScanPathClass(unittest.TestCase):
def test_append(self):
"""Test AOIScanPath append methods."""
- aoi_scan_path = GazeFeatures.AOIScanPath()
+ aoi_scan_path = GazeFeatures.AOIScanPath(['A', 'B'])
# Append fixation on A aoi
fixation = GazeFeatures.Fixation(random_gaze_positions(10))
@@ -309,7 +309,7 @@ class TestAOIScanPathClass(unittest.TestCase):
def test_append_error(self):
"""Test AOIScanPath append error."""
- aoi_scan_path = GazeFeatures.AOIScanPath()
+ aoi_scan_path = GazeFeatures.AOIScanPath(['A', 'B'])
# Append fixation on A aoi
fixation = GazeFeatures.Fixation(random_gaze_positions(10))
@@ -325,11 +325,16 @@ class TestAOIScanPathClass(unittest.TestCase):
fixation = GazeFeatures.Fixation(random_gaze_positions(10))
ts, _ = fixation.positions.first
- # Check that aoi scan step creation fail
+ # Check that aoi scan step creation fail when fixation is appened after another fixation
with self.assertRaises(GazeFeatures.AOIScanStepError):
new_step = aoi_scan_path.append_fixation(ts, fixation, 'B')
+ # Check that unexpected aoi scan step creation fail
+ with self.assertRaises(GazeFeatures.AOIScanStepError):
+
+ new_step = aoi_scan_path.append_fixation(ts, fixation, 'C')
+
if __name__ == '__main__':
unittest.main() \ No newline at end of file
diff --git a/src/argaze.test/PupilAnalysis/WorkloadIndex.py b/src/argaze.test/PupilAnalysis/WorkloadIndex.py
index dd735ba..fec32ef 100644
--- a/src/argaze.test/PupilAnalysis/WorkloadIndex.py
+++ b/src/argaze.test/PupilAnalysis/WorkloadIndex.py
@@ -40,13 +40,16 @@ class TestWorkloadIndexClass(unittest.TestCase):
# Check each workload index
ts_1, analysis_1 = ts_analysis.pop_first()
+ self.assertEqual(ts_1, 3)
self.assertTrue(math.isclose(analysis_1, 0.1, abs_tol=1e-2))
ts_2, analysis_2 = ts_analysis.pop_first()
+ self.assertEqual(ts_2, 6)
self.assertTrue(math.isclose(analysis_2, 0.2, abs_tol=1e-2))
ts_3, analysis_3 = ts_analysis.pop_first()
- self.assertTrue(math.isclose(analysis_3, 0.1, abs_tol=1e-2))
+ self.assertEqual(ts_3, 9)
+ self.assertTrue(math.isclose(analysis_3, -0.1, abs_tol=1e-2))
if __name__ == '__main__':