Coverage for /scratch/builds/bob/bob.med.tb/miniconda/conda-bld/bob.med.tb_1637571489937/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placeho/lib/python3.8/site-packages/bob/med/tb/test/test_pc_RS.py: 100%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

30 statements  

1#!/usr/bin/env python 

2# coding=utf-8 

3 

4 

5"""Tests for Extended Padchest dataset""" 

6 

7from ..data.padchest_RS import dataset 

8 

9 

10def test_protocol_consistency(): 

11 

12 # tb_idiap protocol 

13 subset = dataset.subsets("tb_idiap") 

14 assert len(subset) == 3 

15 

16 assert "train" in subset 

17 assert len(subset["train"]) == 160 

18 

19 assert "validation" in subset 

20 assert len(subset["validation"]) == 40 

21 

22 assert "test" in subset 

23 assert len(subset["test"]) == 50 

24 

25 # Check labels 

26 for s in subset["train"]: 

27 assert s.label in [0.0, 1.0] 

28 

29 for s in subset["validation"]: 

30 assert s.label in [0.0, 1.0] 

31 

32 for s in subset["test"]: 

33 assert s.label in [0.0, 1.0] 

34 

35 

36def test_loading(): 

37 def _check_sample(s): 

38 

39 data = s.data 

40 

41 assert isinstance(data, dict) 

42 assert len(data) == 2 

43 

44 assert "data" in data 

45 assert len(data["data"]) == 14 # Check radiological signs 

46 

47 assert "label" in data 

48 assert data["label"] in [0.0, 1.0] # Check labels 

49 

50 limit = 30 # use this to limit testing to first images only, else None 

51 

52 subset = dataset.subsets("tb_idiap") 

53 for s in subset["train"][:limit]: 

54 _check_sample(s)