aboutsummaryrefslogtreecommitdiff
path: root/src/argaze.test/GazeFeatures.py
diff options
context:
space:
mode:
authorThéo de la Hogue2024-02-29 14:18:50 +0100
committerThéo de la Hogue2024-02-29 14:18:50 +0100
commitcd601be0b9366a9bd1554523319e57801440ed64 (patch)
tree62eb67448c3b601eb1e7da7f1b03e6c208747b9c /src/argaze.test/GazeFeatures.py
parent1a3aac125980019ae86493782795569327bc8eaa (diff)
downloadargaze-cd601be0b9366a9bd1554523319e57801440ed64.zip
argaze-cd601be0b9366a9bd1554523319e57801440ed64.tar.gz
argaze-cd601be0b9366a9bd1554523319e57801440ed64.tar.bz2
argaze-cd601be0b9366a9bd1554523319e57801440ed64.tar.xz
More work on time management.
Diffstat (limited to 'src/argaze.test/GazeFeatures.py')
-rw-r--r--src/argaze.test/GazeFeatures.py43
1 files changed, 16 insertions, 27 deletions
diff --git a/src/argaze.test/GazeFeatures.py b/src/argaze.test/GazeFeatures.py
index c6ccfca..e678093 100644
--- a/src/argaze.test/GazeFeatures.py
+++ b/src/argaze.test/GazeFeatures.py
@@ -31,6 +31,9 @@ def random_gaze_positions(size, frame_dimension: tuple[float, float] = (1, 1)):
# Edit gaze position
random_gaze_position = GazeFeatures.GazePosition((random.random() * frame_dimension[0], random.random() * frame_dimension[1]), precision=5)
+ # DEBUG
+ print('random_gaze_position', type(random_gaze_position), random_gaze_position.__class__.__bases__)
+
# Timestamp gaze position
random_gaze_position.timestamp = time.time()
@@ -375,13 +378,11 @@ def build_scan_path(size, frame_dimension: tuple[float, float] = (1, 1)):
for i in range(size):
- fixation = TestFixation(random_gaze_positions(10, frame_dimension))
- ts, _ = fixation.first
- scan_path.append_fixation(ts, fixation)
+ fixation = TestFixation(random_gaze_positions(10, frame_dimension), timestamp=i)
+ scan_path.append_fixation(fixation)
- saccade = TestSaccade(random_gaze_positions(2, frame_dimension))
- ts, _ = saccade.first
- scan_path.append_saccade(ts, saccade)
+ saccade = TestSaccade(random_gaze_positions(2, frame_dimension), timestamp=i+1)
+ scan_path.append_saccade(saccade)
return scan_path
@@ -404,9 +405,7 @@ class TestScanPathClass(unittest.TestCase):
# Append a saccade that should be ignored
saccade = TestSaccade(random_gaze_positions(2))
- ts = saccade[0].timestamp
-
- new_step = scan_path.append_saccade(ts, saccade)
+ new_step = scan_path.append_saccade(saccade)
# Check that no scan step have been created yet
self.assertEqual(len(scan_path), 0)
@@ -415,9 +414,7 @@ class TestScanPathClass(unittest.TestCase):
# Append first fixation
fixation_A = TestFixation(random_gaze_positions(10))
- ts = fixation_A[0].timestamp
-
- new_step = scan_path.append_fixation(ts, fixation_A)
+ new_step = scan_path.append_fixation(fixation_A)
# Check that no scan step have been created yet
self.assertEqual(len(scan_path), 0)
@@ -426,9 +423,7 @@ class TestScanPathClass(unittest.TestCase):
# Append consecutive saccade
saccade_A = TestSaccade(random_gaze_positions(2))
- ts = saccade_A[0].timestamp
-
- new_step_A = scan_path.append_saccade(ts, saccade_A)
+ new_step_A = scan_path.append_saccade(saccade_A)
# Check that new scan step have been created
self.assertEqual(len(scan_path), 1)
@@ -439,9 +434,7 @@ class TestScanPathClass(unittest.TestCase):
# Append 2 consecutive fixations then a saccade
fixation_B1 = TestFixation(random_gaze_positions(10))
- ts = fixation_B1[0].timestamp
-
- new_step = scan_path.append_fixation(ts, fixation_B1)
+ new_step = scan_path.append_fixation(fixation_B1)
# Check that no scan step have been created yet
self.assertEqual(len(scan_path), 1)
@@ -449,9 +442,7 @@ class TestScanPathClass(unittest.TestCase):
self.assertEqual(new_step, None)
fixation_B2 = TestFixation(random_gaze_positions(10))
- ts = fixation_B2[0].timestamp
-
- new_step = scan_path.append_fixation(ts, fixation_B2)
+ new_step = scan_path.append_fixation(fixation_B2)
# Check that no scan step have been created yet
self.assertEqual(len(scan_path), 1)
@@ -459,9 +450,7 @@ class TestScanPathClass(unittest.TestCase):
self.assertEqual(new_step, None)
saccade_B = TestSaccade(random_gaze_positions(2))
- ts = saccade_B[0].timestamp
-
- new_step_B = scan_path.append_saccade(ts, saccade_B)
+ new_step_B = scan_path.append_saccade(saccade_B)
# Check that new scan step have been created
self.assertEqual(len(scan_path), 2)
@@ -521,12 +510,12 @@ def build_aoi_scan_path(expected_aoi, aoi_path):
# Append a hidden last step to allow last given step creation
aoi_path.append(aoi_path[-2])
- for aoi in aoi_path:
+ for i, aoi in enumerate(aoi_path):
- fixation = TestFixation(random_gaze_positions(10))
+ fixation = TestFixation(random_gaze_positions(10), timestamp=i)
aoi_scan_path.append_fixation(fixation, aoi)
- saccade = TestSaccade(random_gaze_positions(2))
+ saccade = TestSaccade(random_gaze_positions(2), timestamp=i+1)
aoi_scan_path.append_saccade(saccade)
return aoi_scan_path