From 77f906729e46336b8e860b311cafdcf42087007c Mon Sep 17 00:00:00 2001 From: Théo de la Hogue Date: Tue, 8 Aug 2023 17:14:49 +0200 Subject: Renaming Pupil by Pupill. --- src/argaze.test/PupillAnalysis/WorkloadIndex.py | 56 +++++++++++++++++++++++++ src/argaze.test/PupillAnalysis/__init__.py | 0 2 files changed, 56 insertions(+) create mode 100644 src/argaze.test/PupillAnalysis/WorkloadIndex.py create mode 100644 src/argaze.test/PupillAnalysis/__init__.py (limited to 'src/argaze.test/PupillAnalysis') diff --git a/src/argaze.test/PupillAnalysis/WorkloadIndex.py b/src/argaze.test/PupillAnalysis/WorkloadIndex.py new file mode 100644 index 0000000..d60b6ae --- /dev/null +++ b/src/argaze.test/PupillAnalysis/WorkloadIndex.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python + +""" """ + +__author__ = "Théo de la Hogue" +__credits__ = [] +__copyright__ = "Copyright 2023, Ecole Nationale de l'Aviation Civile (ENAC)" +__license__ = "BSD" + +import unittest +import math + +from argaze import PupillFeatures +from argaze.PupillAnalysis import WorkloadIndex + +class TestWorkloadIndexClass(unittest.TestCase): + """Test WorkloadIndex class.""" + + def test_analysis(self): + """Test WorkloadIndex analysis.""" + + ts_pupill_diameters = { + 0: PupillFeatures.PupillDiameter(1.), + 1: PupillFeatures.PupillDiameter(1.1), + 2: PupillFeatures.PupillDiameter(1.2), + 3: PupillFeatures.PupillDiameter(1.3), + 4: PupillFeatures.PupillDiameter(1.2), + 5: PupillFeatures.PupillDiameter(1.1), + 6: PupillFeatures.PupillDiameter(1.), + 7: PupillFeatures.PupillDiameter(0.9), + 8: PupillFeatures.PupillDiameter(0.8), + 9: PupillFeatures.PupillDiameter(0.7) + } + + pupill_diameter_analyzer = WorkloadIndex.PupillDiameterAnalyzer(reference=PupillFeatures.PupillDiameter(1.), period=3) + ts_analysis = pupill_diameter_analyzer.browse(PupillFeatures.TimeStampedPupillDiameters(ts_pupill_diameters)) + + # Check result size + self.assertEqual(len(ts_analysis), 3) + + # 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.assertEqual(ts_3, 9) + self.assertTrue(math.isclose(analysis_3, -0.1, abs_tol=1e-2)) + +if __name__ == '__main__': + + unittest.main() \ No newline at end of file diff --git a/src/argaze.test/PupillAnalysis/__init__.py b/src/argaze.test/PupillAnalysis/__init__.py new file mode 100644 index 0000000..e69de29 -- cgit v1.1