aboutsummaryrefslogtreecommitdiff
path: root/src/argaze.test/GazeAnalysis
diff options
context:
space:
mode:
authorThéo de la Hogue2023-07-03 14:53:40 +0200
committerThéo de la Hogue2023-07-03 14:53:40 +0200
commit3d66f3e2d58b7038cdfdf272f2d813e24b730243 (patch)
tree912f8c70933f1f4b3d0097b93f6089b5f7914f23 /src/argaze.test/GazeAnalysis
parent25554ea7710c35107f0904532df093f9c15f74ae (diff)
downloadargaze-3d66f3e2d58b7038cdfdf272f2d813e24b730243.zip
argaze-3d66f3e2d58b7038cdfdf272f2d813e24b730243.tar.gz
argaze-3d66f3e2d58b7038cdfdf272f2d813e24b730243.tar.bz2
argaze-3d66f3e2d58b7038cdfdf272f2d813e24b730243.tar.xz
Updating GazeAnalysis test.
Diffstat (limited to 'src/argaze.test/GazeAnalysis')
-rw-r--r--src/argaze.test/GazeAnalysis/Entropy.py10
-rw-r--r--src/argaze.test/GazeAnalysis/ExploitExploreRatio.py4
-rw-r--r--src/argaze.test/GazeAnalysis/KCoefficient.py8
-rw-r--r--src/argaze.test/GazeAnalysis/LempelZivComplexity.py8
-rw-r--r--src/argaze.test/GazeAnalysis/NGram.py46
-rw-r--r--src/argaze.test/GazeAnalysis/NearestNeighborIndex.py11
-rw-r--r--src/argaze.test/GazeAnalysis/TransitionMatrix.py22
7 files changed, 61 insertions, 48 deletions
diff --git a/src/argaze.test/GazeAnalysis/Entropy.py b/src/argaze.test/GazeAnalysis/Entropy.py
index b69f329..f84eca0 100644
--- a/src/argaze.test/GazeAnalysis/Entropy.py
+++ b/src/argaze.test/GazeAnalysis/Entropy.py
@@ -21,20 +21,20 @@ class TestAOIScanPathAnalyzer(unittest.TestCase):
def test_analyze(self):
"""Test analyze method."""
- entropy_analyzer = Entropy.AOIScanPathAnalyzer()
transition_matrix_analyser = TransitionMatrix.AOIScanPathAnalyzer()
+ entropy_analyzer = Entropy.AOIScanPathAnalyzer(transition_matrix_analyser)
aoi_scan_path = GazeFeaturesTest.build_aoi_scan_path(['Foo', 'Bar', 'Shu'], ['Bar', 'Shu', 'Foo', 'Bar', 'Shu', 'Foo', 'Bar', 'Shu', 'Foo'])
# Check aoi scan path
self.assertEqual(len(aoi_scan_path), 9)
- transition_matrix_probabilities, transition_matrix_density = transition_matrix_analyser.analyze(aoi_scan_path)
- stationary_entropy, transition_entropy = entropy_analyzer.analyze(aoi_scan_path, transition_matrix_probabilities)
+ transition_matrix_analyser.analyze(aoi_scan_path)
+ entropy_analyzer.analyze(aoi_scan_path)
# Check entropy analysis
- self.assertAlmostEqual(stationary_entropy, 1.09, 1)
- self.assertAlmostEqual(transition_entropy, 0, 1)
+ self.assertAlmostEqual(entropy_analyzer.stationary_entropy, 1.09, 1)
+ self.assertAlmostEqual(entropy_analyzer.transition_entropy, 0, 1)
if __name__ == '__main__':
diff --git a/src/argaze.test/GazeAnalysis/ExploitExploreRatio.py b/src/argaze.test/GazeAnalysis/ExploitExploreRatio.py
index 9cfcc0b..d788a42 100644
--- a/src/argaze.test/GazeAnalysis/ExploitExploreRatio.py
+++ b/src/argaze.test/GazeAnalysis/ExploitExploreRatio.py
@@ -28,10 +28,10 @@ class TestScanPathAnalyzer(unittest.TestCase):
# Check scan path
self.assertEqual(len(scan_path), 10)
- xxr = xxr_analyzer.analyze(scan_path)
+ xxr_analyzer.analyze(scan_path)
# Check exploit explore ratio: it should greater than 1 because of build_scan_path
- self.assertGreaterEqual(xxr, 1.)
+ self.assertGreaterEqual(xxr_analyzer.exploit_explore_ratio, 1.)
if __name__ == '__main__':
diff --git a/src/argaze.test/GazeAnalysis/KCoefficient.py b/src/argaze.test/GazeAnalysis/KCoefficient.py
index c834b28..a45d3e4 100644
--- a/src/argaze.test/GazeAnalysis/KCoefficient.py
+++ b/src/argaze.test/GazeAnalysis/KCoefficient.py
@@ -28,10 +28,10 @@ class TestScanPathAnalyzer(unittest.TestCase):
# Check scan path
self.assertEqual(len(scan_path), 10)
- K = kcoeff_analyzer.analyze(scan_path)
+ kcoeff_analyzer.analyze(scan_path)
# Check that K coefficient is almost equal to 0
- self.assertAlmostEqual(K, 0)
+ self.assertAlmostEqual(kcoeff_analyzer.K, 0)
class TestAOIScanPathAnalyzer(unittest.TestCase):
"""Test AOIScanPathAnalyzer class."""
@@ -46,10 +46,10 @@ class TestAOIScanPathAnalyzer(unittest.TestCase):
# Check aoi scan path
self.assertEqual(len(aoi_scan_path), 4)
- K = kcoeff_analyzer.analyze(aoi_scan_path)
+ kcoeff_analyzer.analyze(aoi_scan_path)
# Check that K coefficient is almost equal to 0
- self.assertAlmostEqual(K, 0)
+ self.assertAlmostEqual(kcoeff_analyzer.K, 0)
if __name__ == '__main__':
diff --git a/src/argaze.test/GazeAnalysis/LempelZivComplexity.py b/src/argaze.test/GazeAnalysis/LempelZivComplexity.py
index 75afc4d..9f5ec84 100644
--- a/src/argaze.test/GazeAnalysis/LempelZivComplexity.py
+++ b/src/argaze.test/GazeAnalysis/LempelZivComplexity.py
@@ -29,10 +29,10 @@ class TestAOIScanPathAnalyzer(unittest.TestCase):
# Check aoi scan path
self.assertEqual(len(aoi_scan_path), 13)
- lzc = lzc_analyzer.analyze(aoi_scan_path)
+ lzc_analyzer.analyze(aoi_scan_path)
# Check LZC coefficient
- self.assertEqual(lzc, 6)
+ self.assertEqual(lzc_analyzer.lempel_ziv_complexity, 6)
def test_analyze_seconde_example(self):
"""Test analyze method with second example sequence from the paper."""
@@ -44,10 +44,10 @@ class TestAOIScanPathAnalyzer(unittest.TestCase):
# Check aoi scan path
self.assertEqual(len(aoi_scan_path), 13)
- lzc = lzc_analyzer.analyze(aoi_scan_path)
+ lzc_analyzer.analyze(aoi_scan_path)
# Check LZC coefficient
- self.assertEqual(lzc, 9)
+ self.assertEqual(lzc_analyzer.lempel_ziv_complexity, 9)
if __name__ == '__main__':
diff --git a/src/argaze.test/GazeAnalysis/NGram.py b/src/argaze.test/GazeAnalysis/NGram.py
index 9608b90..15e1319 100644
--- a/src/argaze.test/GazeAnalysis/NGram.py
+++ b/src/argaze.test/GazeAnalysis/NGram.py
@@ -21,36 +21,48 @@ class TestAOIScanPathAnalyzer(unittest.TestCase):
def test_analyze(self):
"""Test analyze method."""
- ngram_analyzer = NGram.AOIScanPathAnalyzer()
-
aoi_scan_path = GazeFeaturesTest.build_aoi_scan_path(['Foo', 'Bar', 'Shu'], ['Bar', 'Shu', 'Foo', 'Bar', 'Shu', 'Foo'])
# Check aoi scan path
self.assertEqual(len(aoi_scan_path), 6)
- ngram_analysis = ngram_analyzer.analyze(aoi_scan_path, 2)
+ ngram_analyzer = NGram.AOIScanPathAnalyzer(n_min=2, n_max=2)
+ ngram_analyzer.analyze(aoi_scan_path)
# Check 2-gram analysis
- self.assertEqual(len(ngram_analysis), 3)
- self.assertEqual(ngram_analysis[('Bar', 'Shu')], 2)
- self.assertEqual(ngram_analysis[('Shu', 'Foo')], 2)
- self.assertEqual(ngram_analysis[('Foo', 'Bar')], 1)
+ self.assertEqual(len(ngram_analyzer.ngrams_count), 1)
+ self.assertEqual(len(ngram_analyzer.ngrams_count[2]), 3)
+ self.assertEqual(ngram_analyzer.ngrams_count[2][('Bar', 'Shu')], 2)
+ self.assertEqual(ngram_analyzer.ngrams_count[2][('Shu', 'Foo')], 2)
+ self.assertEqual(ngram_analyzer.ngrams_count[2][('Foo', 'Bar')], 1)
- ngram_analysis = ngram_analyzer.analyze(aoi_scan_path, 3)
+ ngram_analyzer = NGram.AOIScanPathAnalyzer(n_min=3, n_max=3)
+ ngram_analyzer.analyze(aoi_scan_path)
# Check 3-gram analysis
- self.assertEqual(len(ngram_analysis), 3)
- self.assertEqual(ngram_analysis[('Bar', 'Shu', 'Foo')], 2)
- self.assertEqual(ngram_analysis[('Shu', 'Foo', 'Bar')], 1)
- self.assertEqual(ngram_analysis[('Foo', 'Bar', 'Shu')], 1)
+ self.assertEqual(len(ngram_analyzer.ngrams_count), 1)
+ self.assertEqual(len(ngram_analyzer.ngrams_count[3]), 3)
+ self.assertEqual(ngram_analyzer.ngrams_count[3][('Bar', 'Shu', 'Foo')], 2)
+ self.assertEqual(ngram_analyzer.ngrams_count[3][('Shu', 'Foo', 'Bar')], 1)
+ self.assertEqual(ngram_analyzer.ngrams_count[3][('Foo', 'Bar', 'Shu')], 1)
- ngram_analysis = ngram_analyzer.analyze(aoi_scan_path, 4)
+ ngram_analyzer = NGram.AOIScanPathAnalyzer(n_min=2, n_max=4)
+ ngram_analyzer.analyze(aoi_scan_path)
# Check 4-gram analysis
- self.assertEqual(len(ngram_analysis), 3)
- self.assertEqual(ngram_analysis[('Bar', 'Shu', 'Foo', 'Bar')], 1)
- self.assertEqual(ngram_analysis[('Shu', 'Foo', 'Bar', 'Shu')], 1)
- self.assertEqual(ngram_analysis[('Foo', 'Bar', 'Shu', 'Foo')], 1)
+ self.assertEqual(len(ngram_analyzer.ngrams_count), 3)
+ self.assertEqual(len(ngram_analyzer.ngrams_count[2]), 3)
+ self.assertEqual(len(ngram_analyzer.ngrams_count[3]), 3)
+ self.assertEqual(len(ngram_analyzer.ngrams_count[4]), 3)
+ self.assertEqual(ngram_analyzer.ngrams_count[2][('Bar', 'Shu')], 2)
+ self.assertEqual(ngram_analyzer.ngrams_count[2][('Shu', 'Foo')], 2)
+ self.assertEqual(ngram_analyzer.ngrams_count[2][('Foo', 'Bar')], 1)
+ self.assertEqual(ngram_analyzer.ngrams_count[3][('Bar', 'Shu', 'Foo')], 2)
+ self.assertEqual(ngram_analyzer.ngrams_count[3][('Shu', 'Foo', 'Bar')], 1)
+ self.assertEqual(ngram_analyzer.ngrams_count[3][('Foo', 'Bar', 'Shu')], 1)
+ self.assertEqual(ngram_analyzer.ngrams_count[4][('Bar', 'Shu', 'Foo', 'Bar')], 1)
+ self.assertEqual(ngram_analyzer.ngrams_count[4][('Shu', 'Foo', 'Bar', 'Shu')], 1)
+ self.assertEqual(ngram_analyzer.ngrams_count[4][('Foo', 'Bar', 'Shu', 'Foo')], 1)
if __name__ == '__main__':
diff --git a/src/argaze.test/GazeAnalysis/NearestNeighborIndex.py b/src/argaze.test/GazeAnalysis/NearestNeighborIndex.py
index fb7d4ec..abd6b2c 100644
--- a/src/argaze.test/GazeAnalysis/NearestNeighborIndex.py
+++ b/src/argaze.test/GazeAnalysis/NearestNeighborIndex.py
@@ -21,19 +21,20 @@ class TestScanPathAnalyzer(unittest.TestCase):
def test_analyze(self):
"""Test analyze."""
- nni_analyzer = NearestNeighborIndex.ScanPathAnalyzer()
-
screen_dimension = (100, 100)
+
+ nni_analyzer = NearestNeighborIndex.ScanPathAnalyzer(size=screen_dimension)
+
scan_path = GazeFeaturesTest.build_scan_path(6, screen_dimension)
# Check aoi scan path
self.assertEqual(len(scan_path), 6)
- nni = nni_analyzer.analyze(scan_path, screen_dimension)
+ nni_analyzer.analyze(scan_path)
# Check NNI
- self.assertGreaterEqual(nni, 0)
- self.assertLessEqual(nni, 1)
+ self.assertGreaterEqual(nni_analyzer.nearest_neighbor_index, 0)
+ self.assertLessEqual(nni_analyzer.nearest_neighbor_index, 1)
if __name__ == '__main__':
diff --git a/src/argaze.test/GazeAnalysis/TransitionMatrix.py b/src/argaze.test/GazeAnalysis/TransitionMatrix.py
index 997b706..9a2f4e7 100644
--- a/src/argaze.test/GazeAnalysis/TransitionMatrix.py
+++ b/src/argaze.test/GazeAnalysis/TransitionMatrix.py
@@ -28,24 +28,24 @@ class TestAOIScanPathAnalyzer(unittest.TestCase):
# Check aoi scan path
self.assertEqual(len(aoi_scan_path), 4)
- transition_matrix_probabilities, transition_matrix_density = transition_matrix_analyser.analyze(aoi_scan_path)
+ transition_matrix_analyser.analyze(aoi_scan_path)
# Check transition matrix probabilities ([destination][departure])
- self.assertEqual(transition_matrix_probabilities['Foo']['Foo'], 0)
- self.assertEqual(transition_matrix_probabilities['Bar']['Bar'], 0)
- self.assertEqual(transition_matrix_probabilities['Shu']['Shu'], 0)
+ self.assertEqual(transition_matrix_analyser.transition_matrix_probabilities['Foo']['Foo'], 0)
+ self.assertEqual(transition_matrix_analyser.transition_matrix_probabilities['Bar']['Bar'], 0)
+ self.assertEqual(transition_matrix_analyser.transition_matrix_probabilities['Shu']['Shu'], 0)
- self.assertEqual(transition_matrix_probabilities['Foo']['Bar'], 0)
- self.assertEqual(transition_matrix_probabilities['Foo']['Shu'], 1)
+ self.assertEqual(transition_matrix_analyser.transition_matrix_probabilities['Foo']['Bar'], 0)
+ self.assertEqual(transition_matrix_analyser.transition_matrix_probabilities['Foo']['Shu'], 1)
- self.assertEqual(transition_matrix_probabilities['Bar']['Foo'], 1)
- self.assertEqual(transition_matrix_probabilities['Bar']['Shu'], 0)
+ self.assertEqual(transition_matrix_analyser.transition_matrix_probabilities['Bar']['Foo'], 1)
+ self.assertEqual(transition_matrix_analyser.transition_matrix_probabilities['Bar']['Shu'], 0)
- self.assertEqual(transition_matrix_probabilities['Shu']['Foo'], 0)
- self.assertEqual(transition_matrix_probabilities['Shu']['Bar'], 1)
+ self.assertEqual(transition_matrix_analyser.transition_matrix_probabilities['Shu']['Foo'], 0)
+ self.assertEqual(transition_matrix_analyser.transition_matrix_probabilities['Shu']['Bar'], 1)
# Check transition matrix density
- self.assertEqual(transition_matrix_density, 0.3333333333333333)
+ self.assertEqual(transition_matrix_analyser.transition_matrix_density, 0.3333333333333333)
if __name__ == '__main__':