diff --git a/bob/measure/data/dev-4col.tar.gz b/bob/measure/data/dev-4col.tar.gz new file mode 100644 index 0000000..a903eaa Binary files /dev/null and b/bob/measure/data/dev-4col.tar.gz differ diff --git a/bob/measure/data/dev-5col.tar.gz b/bob/measure/data/dev-5col.tar.gz new file mode 100644 index 0000000..65a1cef Binary files /dev/null and b/bob/measure/data/dev-5col.tar.gz differ diff --git a/bob/measure/test_io.py b/bob/measure/test_io.py new file mode 100644 index 0000000..1868147 --- /dev/null +++ b/bob/measure/test_io.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python +# vim: set fileencoding=utf-8 : +# Andre Anjos +# Wed 11 Dec 15:14:08 2013 CET +# +# Copyright (C) 2011-2013 Idiap Research Institute, Martigny, Switzerland + +"""Tests the IO functionality of bob.measure.""" + +import bob.measure +import pkg_resources + +def test_load_scores(): + # This function tests the IO functionality of loading score files in different ways + + scores = [] + load_functions = {'4col' : bob.measure.load.four_column, '5col' : bob.measure.load.five_column} + cols = {'4col' : 4, '5col' : 5} + + for variant in ('4col', '5col'): + + # read score file in normal way + normal_score_file = pkg_resources.resource_filename('bob.measure', 'data/dev-%s.txt' % variant) + normal_scores = list(load_functions[variant](normal_score_file)) + + assert len(normal_scores) == 910 + assert all(len(s) == cols[variant] for s in normal_scores) + + # read the compressed score file + compressed_score_file = pkg_resources.resource_filename('bob.measure', 'data/dev-%s.tar.gz' % variant) + compressed_scores = list(load_functions[variant](compressed_score_file)) + + assert len(compressed_scores) == len(normal_scores) + assert all(len(c) == cols[variant] for c in compressed_scores) + assert all(c[i] == s[i] for c,s in zip(compressed_scores, normal_scores) for i in range(cols[variant]))