diff --git a/bob/measure/script/commands.py b/bob/measure/script/commands.py index 3e47265caec357516b3c9269558a5e7170e87c9c..e42704ee2975253cbcf5cc96c7a2673360082dcf 100644 --- a/bob/measure/script/commands.py +++ b/bob/measure/script/commands.py @@ -16,7 +16,7 @@ from bob.extension.scripts.click_helper import (verbosity_option, @common_options.criterion_option() @common_options.thresholds_option() @common_options.far_option() -@common_options.titles_option() +@common_options.legends_option() @open_file_mode_option() @verbosity_option() @click.pass_context @@ -43,7 +43,7 @@ def metrics(ctx, scores, evaluation, **kwargs): @click.command() @common_options.scores_argument(nargs=-1) @common_options.title_option() -@common_options.titles_option() +@common_options.legends_option() @common_options.sep_dev_eval_option() @common_options.output_plot_file_option(default_out='roc.pdf') @common_options.eval_option() @@ -83,7 +83,7 @@ def roc(ctx, scores, evaluation, **kwargs): @common_options.scores_argument(nargs=-1) @common_options.output_plot_file_option(default_out='det.pdf') @common_options.title_option() -@common_options.titles_option() +@common_options.legends_option() @common_options.sep_dev_eval_option() @common_options.eval_option() @common_options.axes_val_option(dflt=[0.01, 95, 0.01, 95]) @@ -121,7 +121,7 @@ def det(ctx, scores, evaluation, **kwargs): @common_options.scores_argument(min_arg=1, force_eval=True, nargs=-1) @common_options.output_plot_file_option(default_out='epc.pdf') @common_options.title_option() -@common_options.titles_option() +@common_options.legends_option() @common_options.points_curve_option() @common_options.const_layout_option() @common_options.x_label_option() @@ -158,7 +158,7 @@ def epc(ctx, scores, **kwargs): @common_options.show_dev_option() @common_options.print_filenames_option() @common_options.title_option() -@common_options.titles_option() +@common_options.legends_option() @common_options.figsize_option() @common_options.style_option() @verbosity_option() @@ -189,7 +189,7 @@ def hist(ctx, scores, evaluation, **kwargs): @click.command() @common_options.scores_argument(nargs=-1) -@common_options.titles_option() +@common_options.legends_option() @common_options.sep_dev_eval_option() @common_options.table_option() @common_options.eval_option() diff --git a/bob/measure/script/common_options.py b/bob/measure/script/common_options.py index 2df4973c0601540cb2732851875700bc47f69d97..8cdd2ce5206dd670f22024583167b72dde0e1d99 100644 --- a/bob/measure/script/common_options.py +++ b/bob/measure/script/common_options.py @@ -288,7 +288,7 @@ def figsize_option(**kwargs): plt.rcParams['figure.figsize'] = ctx.meta['figsize'] return value return click.option( - '--figsize', help='If given, will run ' + '--figsize', default='4,3', help='If given, will run ' '``plt.rcParams[\'figure.figsize\']=figsize)``. Example: --fig-size 4,6', callback=callback, **kwargs)(func) return custom_figsize_option @@ -341,20 +341,20 @@ def marker_style_option(**kwargs): callback=callback, **kwargs)(func) return custom_marker_style_option -def titles_option(**kwargs): - '''Get the titles option for the different systems''' - def custom_titles_option(func): +def legends_option(**kwargs): + '''Get the legends option for the different systems''' + def custom_legends_option(func): def callback(ctx, param, value): if value is not None: value = value.split(',') - ctx.meta['titles'] = value + ctx.meta['legends'] = value return value return click.option( - '-ts', '--titles', type=click.STRING, default=None, + '-ls', '--legends', type=click.STRING, default=None, help='The title for each system comma separated. ' - 'Example: --titles ISV,CNN', + 'Example: --legends ISV,CNN', callback=callback, **kwargs)(func) - return custom_titles_option + return custom_legends_option def title_option(**kwargs): '''Get the title option for the different systems''' diff --git a/bob/measure/script/figure.py b/bob/measure/script/figure.py index 2620896efe9f28bc208dc26aabee2b1962ab480f..60c5746c9535da7f98706dd420f344b461b7d410 100644 --- a/bob/measure/script/figure.py +++ b/bob/measure/script/figure.py @@ -56,7 +56,7 @@ class MeasureBase(object): self._min_arg = 1 if 'min_arg' not in ctx.meta else ctx.meta['min_arg'] self._ctx = ctx self.func_load = func_load - self._titles = None if 'titles' not in ctx.meta else ctx.meta['titles'] + self._legends = None if 'legends' not in ctx.meta else ctx.meta['legends'] self._eval = evaluation self._min_arg = 1 if 'min_arg' not in ctx.meta else ctx.meta['min_arg'] if len(scores) < 1 or len(scores) % self._min_arg != 0: @@ -64,8 +64,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._titles is not None and len(self._titles) != self.n_systems: - raise click.BadParameter("Number of titles 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 equal to the " "number of systems") def run(self): @@ -85,7 +85,7 @@ class MeasureBase(object): # each system for idx in range(self.n_systems): input_scores, input_names = self._load_files( - self._scores[idx:(idx + self._min_arg)] + self._scores[idx * self._min_arg:(idx + 1) * self._min_arg] ) self.compute(idx, input_scores, input_names) #setup final configuration, plotting properties, ... @@ -188,7 +188,7 @@ class Metrics(MeasureBase): threshold = utils.get_thres(self._criterion, dev_neg, dev_pos, self._far) \ if self._thres is None else self._thres[idx] - title = self._titles[idx] if self._titles is not None else None + title = self._legends[idx] if self._legends is not None else None if self._thres is None: far_str = '' if self._criterion == 'far' and self._far is not None: @@ -364,8 +364,8 @@ class PlotBase(MeasureBase): #common protected functions def _label(self, base, name, idx): - if self._titles is not None and len(self._titles) > idx: - return self._titles[idx] + if self._legends is not None and len(self._legends) > idx: + return self._legends[idx] if self.n_systems > 1: return base + (" %d (%s)" % (idx + 1, name)) return base + (" (%s)" % name) @@ -584,7 +584,7 @@ class Hist(PlotBase): self._pdf_page.savefig(fig) def _get_title(self, idx, dev_file, eval_file): - title = self._titles[idx] if self._titles is not None else None + title = self._legends[idx] if self._legends is not None else None if title is None: title = self._title_base if not self._print_fn else \ ('%s \n (%s)' % ( diff --git a/bob/measure/test_script.py b/bob/measure/test_script.py index fd117c355ea3e30b673e1df74be1d16ea22cfa7e..0819aafa4ff6ba00eb0a0461e4d1a59bcbe6f3e5 100644 --- a/bob/measure/test_script.py +++ b/bob/measure/test_script.py @@ -30,7 +30,7 @@ def test_metrics(): assert result.exit_code == 0 with runner.isolated_filesystem(): result = runner.invoke( - commands.metrics, ['-l', 'tmp', dev1, test1, dev2, test2, '-ts', + commands.metrics, ['-l', 'tmp', dev1, test1, dev2, test2, '-ls', 'A,B'] ) assert result.exit_code == 0, (result.exit_code, result.output) @@ -63,7 +63,7 @@ def test_roc(): with runner.isolated_filesystem(): result = runner.invoke(commands.roc, ['--output', - 'test.pdf', '--titles', 'A,B', + 'test.pdf', '--legends', 'A,B', dev1, test1, dev2, test2]) if result.output: click.echo(result.output) @@ -83,7 +83,7 @@ def test_det(): test2 = bob.io.base.test_utils.datafile('test-2.txt', 'bob.measure') with runner.isolated_filesystem(): result = runner.invoke(commands.det, ['--split', '--output', - 'test.pdf', '--titles', 'A,B', + 'test.pdf', '--legends', 'A,B', dev1, test1, dev2, test2]) if result.output: click.echo(result.output) @@ -111,7 +111,7 @@ def test_epc(): test2 = bob.io.base.test_utils.datafile('test-2.txt', 'bob.measure') with runner.isolated_filesystem(): result = runner.invoke(commands.epc, ['--output', 'test.pdf', - '--titles', 'A,B', + '--legends', 'A,B', dev1, test1, dev2, test2]) if result.output: click.echo(result.output)