Skip to content

Commit

Permalink
Added test for loading compressed score files
Browse files Browse the repository at this point in the history
  • Loading branch information
siebenkopf committed Sep 17, 2015
1 parent d1afa31 commit 7c668e3
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
Binary file added bob/measure/data/dev-4col.tar.gz
Binary file not shown.
Binary file added bob/measure/data/dev-5col.tar.gz
Binary file not shown.
35 changes: 35 additions & 0 deletions bob/measure/test_io.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env python
# vim: set fileencoding=utf-8 :
# Andre Anjos <andre.anjos@idiap.ch>
# 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]))

0 comments on commit 7c668e3

Please sign in to comment.