Commit 0fc6e809 authored by Theophile GENTILHOMME's avatar Theophile GENTILHOMME
Browse files

Add default parameter to generate figsize option

parent fec04bb8
Pipeline #19608 passed with stage
in 88 minutes and 22 seconds
...@@ -278,8 +278,20 @@ def far_option(**kwargs): ...@@ -278,8 +278,20 @@ def far_option(**kwargs):
callback=callback, show_default=True,**kwargs)(func) callback=callback, show_default=True,**kwargs)(func)
return custom_far_option return custom_far_option
def figsize_option(**kwargs): def figsize_option(dflt='4,3', **kwargs):
'''Get option for matplotlib figsize''' """Get option for matplotlib figsize
dflt : str
matplotlib default figsize for the command. must be a a list of int
separated by commas.
A decorator to be used for adding score arguments for click commands
def custom_figsize_option(func): def custom_figsize_option(func):
def callback(ctx, param, value): def callback(ctx, param, value):
ctx.meta['figsize'] = value if value is None else \ ctx.meta['figsize'] = value if value is None else \
...@@ -288,7 +300,7 @@ def figsize_option(**kwargs): ...@@ -288,7 +300,7 @@ def figsize_option(**kwargs):
plt.rcParams['figure.figsize'] = ctx.meta['figsize'] plt.rcParams['figure.figsize'] = ctx.meta['figsize']
return value return value
return click.option( return click.option(
'--figsize', default='4,3', help='If given, will run ' '--figsize', default=dflt, help='If given, will run '
'``plt.rcParams[\'figure.figsize\']=figsize)``. Example: --fig-size 4,6', '``plt.rcParams[\'figure.figsize\']=figsize)``. Example: --fig-size 4,6',
callback=callback, **kwargs)(func) callback=callback, **kwargs)(func)
return custom_figsize_option return custom_figsize_option
Supports Markdown
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