2023-01-12 14:31:21 +01:00
|
|
|
"""
|
|
|
|
Some preconfigured ArgumentParser
|
|
|
|
"""
|
|
|
|
|
|
|
|
from argparse import ArgumentParser
|
|
|
|
|
2023-01-12 14:49:54 +01:00
|
|
|
def MyArgumentParser(default_fig_dir='./figures', default_show_plots=False, **kwargs):
|
2023-01-12 14:31:21 +01:00
|
|
|
"""
|
|
|
|
A somewhat preconfigured ArgumentParser
|
|
|
|
|
|
|
|
Set show_plots=True to by default enable showing plots.
|
2023-01-12 14:49:54 +01:00
|
|
|
Likewise, set fig_dir=None to by default disable saving figures.
|
2023-01-12 14:31:21 +01:00
|
|
|
"""
|
|
|
|
parser = ArgumentParser(**kwargs)
|
|
|
|
|
|
|
|
# Whether to show plots
|
|
|
|
parser.add_argument('--show-plots', action='store_true')
|
|
|
|
parser.add_argument('--no-show-plots', dest='show-plots', action='store_false')
|
|
|
|
parser.set_defaults(show_plots=default_show_plots)
|
|
|
|
|
2023-01-12 14:49:54 +01:00
|
|
|
# Figures directory
|
|
|
|
parser.add_argument('--fig-dir', type=str, default=default_fig_dir)
|
|
|
|
|
2023-01-12 14:31:21 +01:00
|
|
|
return parser
|