File size: 1,027 Bytes
2e7de11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"""Label wording controls: frozen reference, wrong category and absent label."""
import json
import unittest
from pathlib import Path
import numpy as np
import visual_score

class LabelText(unittest.TestCase):
    def test_reference_words_are_readable(self):
        here = Path(__file__).parent/'reference'
        config = json.loads((here/'diagnostic-config.json').read_text())
        with np.load(here/'reference-frames.npz') as data:
            for name in config['category_order']:
                with self.subTest(name=name):
                    self.assertEqual(visual_score.label_text_check(data[name], name)[0], 0)

    def test_wrong_category_and_missing_label(self):
        with np.load(Path(__file__).parent/'reference/reference-frames.npz') as data:
            self.assertEqual(visual_score.label_text_check(data['dot-elastic'], 'dot-pulse')[0], 1)
        self.assertEqual(visual_score.label_text_check(np.zeros((300,216,384),np.uint8), 'dot-elastic')[0], 1)

if __name__ == '__main__':
    unittest.main()