Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bob
bob.measure
Commits
7c668e3c
Commit
7c668e3c
authored
Sep 17, 2015
by
Manuel Günther
Browse files
Added test for loading compressed score files
parent
d1afa319
Changes
3
Hide whitespace changes
Inline
Side-by-side
bob/measure/data/dev-4col.tar.gz
0 → 100644
View file @
7c668e3c
File added
bob/measure/data/dev-5col.tar.gz
0 → 100644
View file @
7c668e3c
File added
bob/measure/test_io.py
0 → 100644
View file @
7c668e3c
#!/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
]))
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment