Skip to content
Snippets Groups Projects
Commit 5d449b16 authored by Amir MOHAMMADI's avatar Amir MOHAMMADI
Browse files

Merge branch 'alpha-option-in-roc' into 'master'

Add an alpha option to ROC,DET,EPC figures

See merge request !96
parents eeed95c2 df9e53bb
No related branches found
No related tags found
1 merge request!96Add an alpha option to ROC,DET,EPC figures
Pipeline #32883 passed
......@@ -59,6 +59,20 @@ def scores_argument(min_arg=1, force_eval=False, **kwargs):
return custom_scores_argument
def alpha_option(dflt=1, **kwargs):
'''An alpha option for plots'''
def custom_eval_option(func):
def callback(ctx, param, value):
ctx.meta['alpha'] = value
return value
return click.option(
'-a', '--alpha', default=dflt, type=click.FLOAT,
show_default=True,
help='Adjusts transparency of plots.',
callback=callback, **kwargs)(func)
return custom_eval_option
def no_legend_option(dflt=True, **kwargs):
'''Get option flag to say if legend should be displayed or not'''
return bool_option(
......@@ -284,7 +298,7 @@ def n_bins_option(**kwargs):
return custom_n_bins_option
def table_option(**kwargs):
def table_option(dflt="rst", **kwargs):
'''Get table option for tabulate package
More informnations: https://pypi.org/project/tabulate/
'''
......@@ -294,7 +308,7 @@ def table_option(**kwargs):
return value
return click.option(
'--tablefmt', type=click.Choice(tabulate.tabulate_formats),
default='rst', show_default=True, help='Format of printed tables.',
default=dflt, show_default=True, help='Format of printed tables.',
callback=callback, **kwargs)(func)
return custom_table_option
......@@ -664,6 +678,7 @@ def roc_command(docstring, far_name="FAR"):
@figsize_option()
@style_option()
@linestyles_option()
@alpha_option()
@verbosity_option()
@click.pass_context
@functools.wraps(func)
......@@ -718,6 +733,7 @@ def det_command(docstring, far_name="FAR"):
@figsize_option()
@style_option()
@linestyles_option()
@alpha_option()
@verbosity_option()
@click.pass_context
@functools.wraps(func)
......@@ -765,6 +781,7 @@ def epc_command(docstring):
@figsize_option()
@style_option()
@linestyles_option()
@alpha_option()
@verbosity_option()
@click.pass_context
@functools.wraps(func)
......
......@@ -430,6 +430,7 @@ class PlotBase(MeasureBase):
self._points = ctx.meta.get('points', 2000)
self._split = ctx.meta.get('split')
self._axlim = ctx.meta.get('axlim')
self._alpha = ctx.meta.get('alpha')
self._disp_legend = ctx.meta.get('disp_legend', True)
self._legend_loc = ctx.meta.get('legend_loc')
self._min_dig = None
......@@ -571,7 +572,8 @@ class Roc(PlotBase):
CAR=self._semilogx,
min_far=self._min_dig,
color=self._colors[idx], linestyle=self._linestyles[idx],
label=self._label('dev', idx)
label=self._label('dev', idx),
alpha=self._alpha,
)
if self._split:
mpl.figure(2)
......@@ -584,7 +586,8 @@ class Roc(PlotBase):
CAR=self._semilogx,
min_far=self._min_dig,
color=self._colors[idx],
label=self._label('eval.', idx)
label=self._label('eval.', idx),
alpha=self._alpha,
)
if self._far_at is not None:
from .. import fprfnr
......@@ -604,7 +607,8 @@ class Roc(PlotBase):
CAR=self._semilogx,
min_far=self._min_dig,
color=self._colors[idx], linestyle=self._linestyles[idx],
label=self._label('dev', idx)
label=self._label('dev', idx),
alpha=self._alpha,
)
......@@ -648,7 +652,8 @@ class Det(PlotBase):
dev_neg, dev_pos, self._points, min_far=self._min_dig,
color=self._colors[idx],
linestyle=self._linestyles[idx],
label=self._label('dev.', idx)
label=self._label('dev.', idx),
alpha=self._alpha,
)
if self._split:
mpl.figure(2)
......@@ -658,7 +663,8 @@ class Det(PlotBase):
eval_neg, eval_pos, self._points, min_far=self._min_dig,
color=self._colors[idx],
linestyle=linestyle,
label=self._label('eval.', idx)
label=self._label('eval.', idx),
alpha=self._alpha,
)
if self._far_at is not None:
from .. import farfrr
......@@ -675,7 +681,8 @@ class Det(PlotBase):
dev_neg, dev_pos, self._points, min_far=self._min_dig,
color=self._colors[idx],
linestyle=self._linestyles[idx],
label=self._label('dev.', idx)
label=self._label('dev.', idx),
alpha=self._alpha,
)
def _set_axis(self):
......@@ -713,7 +720,8 @@ class Epc(PlotBase):
color=self._colors[idx], linestyle=self._linestyles[idx],
label=self._label(
'curve', idx
)
),
alpha=self._alpha,
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment