-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added test for loading compressed score files
- Loading branch information
1 parent
d1afa31
commit 7c668e3
Showing
3 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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])) |