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.py: 97%

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

36 statements  

1#!/usr/bin/env python 

2# coding=utf-8 

3 

4 

5"""Tests for Padchest dataset""" 

6 

7from ..data.padchest import dataset 

8import pytest 

9 

10def test_protocol_consistency(): 

11 

12 # Default protocol 

13 subset = dataset.subsets("idiap") 

14 assert len(subset) == 1 

15 

16 assert "train" in subset 

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

18 

19 # Check labels 

20 for s in subset["train"]: 

21 for l in list(set(s.label)): 

22 assert l in [0.0, 1.0] 

23 

24 # Cross-validation 2 

25 subset = dataset.subsets("tb_idiap") 

26 assert len(subset) == 2 

27 

28 assert "train" in subset 

29 assert len(subset["train"]) == 200 

30 

31 # Check labels 

32 for s in subset["train"]: 

33 assert s.label in [0.0, 1.0] 

34 

35 assert "test" in subset 

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

37 

38 # Check labels 

39 for s in subset["test"]: 

40 assert s.label in [0.0, 1.0] 

41 

42 # Cross-validation 3 

43 subset = dataset.subsets("no_tb_idiap") 

44 assert len(subset) == 2 

45 

46 assert "train" in subset 

47 assert len(subset["train"]) == 54371 

48 

49 # Check labels 

50 for s in subset["train"]: 

51 for l in list(set(s.label)): 

52 assert l in [0.0, 1.0] 

53 

54 assert "validation" in subset 

55 assert len(subset["validation"]) == 4052 

56 

57 # Check labels 

58 for s in subset["validation"]: 

59 for l in list(set(s.label)): 

60 assert l in [0.0, 1.0] 

61 

62@pytest.mark.skip_if_rc_var_not_set('bob.med.tb.padchest.datadir') 

63def test_check(): 

64 assert dataset.check() == 0