Commit 4bb2749d authored by Theophile GENTILHOMME's avatar Theophile GENTILHOMME

[script][common_options,figure,test_script] Change legends options to

titles for histograms.
parent b4174c2c
Pipeline #21346 passed with stage
in 8 minutes and 46 seconds
...@@ -491,7 +491,7 @@ def legends_option(**kwargs): ...@@ -491,7 +491,7 @@ def legends_option(**kwargs):
return value return value
return click.option( return click.option(
'-lg', '--legends', type=click.STRING, default=None, '-lg', '--legends', type=click.STRING, default=None,
help='The title for each system comma separated. ' help='The legend for each system comma separated. '
'Example: --legends ISV,CNN', 'Example: --legends ISV,CNN',
callback=callback, **kwargs)(func) callback=callback, **kwargs)(func)
return custom_legends_option return custom_legends_option
...@@ -779,7 +779,7 @@ def hist_command(docstring): ...@@ -779,7 +779,7 @@ def hist_command(docstring):
@eval_option() @eval_option()
@hide_dev_option() @hide_dev_option()
@n_bins_option() @n_bins_option()
@legends_option() @titles_option()
@no_legend_option() @no_legend_option()
@legend_ncols_option() @legend_ncols_option()
@criterion_option() @criterion_option()
......
...@@ -680,10 +680,12 @@ class Hist(PlotBase): ...@@ -680,10 +680,12 @@ class Hist(PlotBase):
self._y_label = 'Probability density' self._y_label = 'Probability density'
self._x_label = 'Score values' self._x_label = 'Score values'
self._end_setup_plot = False self._end_setup_plot = False
if self._legends is not None and len(self._legends) == self.n_systems \ # overide _titles of PlotBase
self._titles = ctx.meta.get('titles')
if self._titles is not None and len(self._titles) == self.n_systems \
and not self._hide_dev: and not self._hide_dev:
# use same legend for dev and eval if needed # use same legend for dev and eval if needed
self._legends = [x for pair in zip(self._legends, self._legends) self._titles = [x for pair in zip(self._titles, self._titles)
for x in pair] for x in pair]
def compute(self, idx, input_scores, input_names): def compute(self, idx, input_scores, input_names):
...@@ -740,8 +742,8 @@ class Hist(PlotBase): ...@@ -740,8 +742,8 @@ class Hist(PlotBase):
def _get_title(self, idx, dflt=None): def _get_title(self, idx, dflt=None):
''' Get the histo title for the given idx''' ''' Get the histo title for the given idx'''
title = self._legends[idx] if self._legends is not None \ title = self._titles[idx] if self._titles is not None \
and idx < len(self._legends) else dflt and idx < len(self._titles) else dflt
title = title or self._title_base title = title or self._title_base
title = '' if title is not None and not title.replace( title = '' if title is not None and not title.replace(
' ', '') else title ' ', '') else title
......
...@@ -144,7 +144,7 @@ def test_hist(): ...@@ -144,7 +144,7 @@ def test_hist():
with runner.isolated_filesystem(): with runner.isolated_filesystem():
result = runner.invoke(commands.hist, ['-e', '--criterion', 'eer','--output', result = runner.invoke(commands.hist, ['-e', '--criterion', 'eer','--output',
'HISTO.pdf', '-b', '30,20', 'HISTO.pdf', '-b', '30,20',
'-sp', 221, '-lg', 'A,B', '-sp', 221, '-ts', 'A,B',
dev1, test1, dev2, test2]) dev1, test1, dev2, test2])
if result.output: if result.output:
click.echo(result.output) click.echo(result.output)
...@@ -159,7 +159,7 @@ def test_hist_legends(): ...@@ -159,7 +159,7 @@ def test_hist_legends():
# share same legend for dev/eval of each system # share same legend for dev/eval of each system
with runner.isolated_filesystem(): with runner.isolated_filesystem():
result = runner.invoke(commands.hist, ['-e', '-sp', 221, '-lg', 'A,B', result = runner.invoke(commands.hist, ['-e', '-sp', 221, '-ts', 'A,B',
dev1, test1, dev2, test2]) dev1, test1, dev2, test2])
if result.output: if result.output:
click.echo(result.output) click.echo(result.output)
...@@ -167,7 +167,7 @@ def test_hist_legends(): ...@@ -167,7 +167,7 @@ def test_hist_legends():
# individual legends for dev and eval # individual legends for dev and eval
with runner.isolated_filesystem(): with runner.isolated_filesystem():
result = runner.invoke(commands.hist, ['-e', '-sp', 221, '-lg', result = runner.invoke(commands.hist, ['-e', '-sp', 221, '-ts',
'A,B,C,D', 'A,B,C,D',
dev1, test1, dev2, test2]) dev1, test1, dev2, test2])
if result.output: if result.output:
......
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