|
13 | 13 |
|
14 | 14 |
|
15 | 15 | class TestAggregateOutcome(unittest.TestCase): |
16 | | - def test_outcome_from_dict(self): |
| 16 | + def test_outcome_from_dict_default(self): |
| 17 | + # For a task that has no costume thresholds, default is 0.99 PASS and 0.9 WARNING and 0 FAIL, |
| 18 | + # np.nan and None return not set |
| 19 | + qc_dict = {'gnap': .99, 'gnop': np.nan, 'gnip': None, 'gnep': 0.9, 'gnup': 0.89} |
| 20 | + expect = {'gnap': 'PASS', 'gnop': 'NOT_SET', 'gnip': 'NOT_SET', 'gnep': 'WARNING', 'gnup': 'FAIL'} |
| 21 | + outcome, outcome_dict = qcmetrics.TaskQC.compute_session_status_from_dict(qc_dict) |
| 22 | + self.assertEqual(outcome, 'FAIL') |
| 23 | + self.assertEqual(expect, outcome_dict) |
| 24 | + |
| 25 | + def test_outcome_from_dict_stimFreeze_delays(self): |
| 26 | + # For '_task_stimFreeze_delays' the threshold are 0.99 PASS and 0 WARNING |
17 | 27 | qc_dict = {'gnap': .99, 'gnop': np.nan, '_task_stimFreeze_delays': .1} |
18 | | - expect = {'gnap': 'PASS', 'gnop': 'NOT_SET', '_task_stimFreeze_delays': 'NOT_SET'} |
| 28 | + expect = {'gnap': 'PASS', 'gnop': 'NOT_SET', '_task_stimFreeze_delays': 'WARNING'} |
| 29 | + outcome, outcome_dict = qcmetrics.TaskQC.compute_session_status_from_dict(qc_dict) |
| 30 | + self.assertEqual(outcome, 'WARNING') |
| 31 | + self.assertEqual(expect, outcome_dict) |
| 32 | + |
| 33 | + def test_outcome_from_dict_iti_delays(self): |
| 34 | + # For '_task_iti_delays' the threshold is 0 NOT_SET |
| 35 | + qc_dict = {'gnap': .99, 'gnop': np.nan, '_task_iti_delays': .1} |
| 36 | + expect = {'gnap': 'PASS', 'gnop': 'NOT_SET', '_task_iti_delays': 'NOT_SET'} |
19 | 37 | outcome, outcome_dict = qcmetrics.TaskQC.compute_session_status_from_dict(qc_dict) |
20 | 38 | self.assertEqual(outcome, 'PASS') |
21 | 39 | self.assertEqual(expect, outcome_dict) |
22 | 40 |
|
| 41 | + def test_out_of_bounds(self): |
| 42 | + # When qc values are below 0 or above 1, give error |
| 43 | + qc_dict = {'gnap': 1.01, 'gnop': 0, 'gnip': 0.99} |
| 44 | + with self.assertRaises(ValueError) as e: |
| 45 | + outcome, outcome_dict = qcmetrics.TaskQC.compute_session_status_from_dict(qc_dict) |
| 46 | + self.assertTrue(e.exception.args[0] == 'Values out of bound') |
| 47 | + |
23 | 48 |
|
24 | 49 | class TestTaskMetrics(unittest.TestCase): |
25 | 50 | def setUp(self): |
|
0 commit comments