Commit c169a52a authored by Amir MOHAMMADI's avatar Amir MOHAMMADI

Merge branch 'histlegends' into 'master'

Histogram legends

Closes #44

See merge request !73
parents 1a9b6ba8 273614af
Pipeline #21229 passed with stages
in 24 minutes and 44 seconds
......@@ -62,8 +62,8 @@ class MeasureBase(object):
'Number of argument must be a non-zero multiple of %d' % self._min_arg
)
self.n_systems = int(len(scores) / self._min_arg)
if self._legends is not None and len(self._legends) != self.n_systems:
raise click.BadParameter("Number of legends must be equal to the "
if self._legends is not None and len(self._legends) < self.n_systems:
raise click.BadParameter("Number of legends must be >= to the "
"number of systems")
def run(self):
......@@ -584,6 +584,10 @@ class Hist(PlotBase):
self._y_label = 'Probability density'
self._x_label = 'Scores values'
self._end_setup_plot = False
if self._legends is not None and len(self._legends) == self.n_systems \
and not self._hide_dev:
self._legends = [x for pair in zip(self._legends,self._legends)
for x in pair]
def compute(self, idx, input_scores, input_names):
''' Draw histograms of negative and positive scores.'''
......
......@@ -150,6 +150,29 @@ def test_hist():
click.echo(result.output)
assert result.exit_code == 0, (result.exit_code, result.output)
def test_hist_legends():
dev1 = bob.io.base.test_utils.datafile('dev-1.txt', 'bob.measure')
test1 = bob.io.base.test_utils.datafile('test-1.txt', 'bob.measure')
dev2 = bob.io.base.test_utils.datafile('dev-2.txt', 'bob.measure')
test2 = bob.io.base.test_utils.datafile('test-2.txt', 'bob.measure')
runner = CliRunner()
# share same legend for dev/eval of each system
with runner.isolated_filesystem():
result = runner.invoke(commands.hist, ['-e', '-sp', 221, '-lg', 'A,B',
dev1, test1, dev2, test2])
if result.output:
click.echo(result.output)
assert result.exit_code == 0, (result.exit_code, result.output)
# individual legends for dev and eval
with runner.isolated_filesystem():
result = runner.invoke(commands.hist, ['-e', '-sp', 221, '-lg',
'A,B,C,D',
dev1, test1, dev2, test2])
if result.output:
click.echo(result.output)
assert result.exit_code == 0, (result.exit_code, result.output)
def test_evaluate():
dev1 = bob.io.base.test_utils.datafile('dev-1.txt', 'bob.measure')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment