Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pycalibration
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
calibration
pycalibration
Commits
dd54c7e7
Commit
dd54c7e7
authored
4 years ago
by
Thomas Kluyver
Browse files
Options
Downloads
Patches
Plain Diff
Docstrings & parameter name
parent
2ee56392
No related branches found
No related tags found
1 merge request
!331
Some cleanup in calibrate.py
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
xfel_calibrate/calibrate.py
+16
-5
16 additions, 5 deletions
xfel_calibrate/calibrate.py
with
16 additions
and
5 deletions
xfel_calibrate/calibrate.py
+
16
−
5
View file @
dd54c7e7
...
@@ -351,7 +351,18 @@ def make_extended_parser() -> argparse.ArgumentParser:
...
@@ -351,7 +351,18 @@ def make_extended_parser() -> argparse.ArgumentParser:
add_args_from_nb
(
nb
,
parser
,
cvar
=
cvar
)
add_args_from_nb
(
nb
,
parser
,
cvar
=
cvar
)
return
parser
return
parser
def
add_args_from_nb
(
nb
,
parser
,
cvar
=
None
,
overwrite_reqs
=
False
):
def
add_args_from_nb
(
nb
,
parser
,
cvar
=
None
,
no_required
=
False
):
"""
Add argparse arguments for parameters in the first cell of a notebook.
Uses nbparameterise to extract the parameter information. Each foo_bar
parameter gets a --foo-bar command line option.
Boolean parameters get a pair of flags like --abc and --no-abc.
:param nb: NotebookNode object representing a loaded .ipynb file
:param parser: argparse.ArgumentParser instance
:param str cvar: Name of the concurrency parameter.
:param bool no_required: If True, none of the added options are required.
"""
parser
.
description
=
make_epilog
(
nb
)
parser
.
description
=
make_epilog
(
nb
)
parms
=
extract_parameters
(
nb
)
parms
=
extract_parameters
(
nb
)
...
@@ -361,7 +372,7 @@ def add_args_from_nb(nb, parser, cvar=None, overwrite_reqs=False):
...
@@ -361,7 +372,7 @@ def add_args_from_nb(nb, parser, cvar=None, overwrite_reqs=False):
else
"
{}. Default: %(default)s
"
.
format
(
p
.
comment
.
replace
(
"
#
"
,
"
"
).
strip
()))
else
"
{}. Default: %(default)s
"
.
format
(
p
.
comment
.
replace
(
"
#
"
,
"
"
).
strip
()))
required
=
(
p
.
comment
is
not
None
required
=
(
p
.
comment
is
not
None
and
"
required
"
in
p
.
comment
and
"
required
"
in
p
.
comment
and
not
overwrite_reqs
and
not
no_required
and
p
.
name
!=
cvar
)
and
p
.
name
!=
cvar
)
# This may be not a public API
# This may be not a public API
...
@@ -402,7 +413,7 @@ def add_args_from_nb(nb, parser, cvar=None, overwrite_reqs=False):
...
@@ -402,7 +413,7 @@ def add_args_from_nb(nb, parser, cvar=None, overwrite_reqs=False):
type
=
p
.
type
,
type
=
p
.
type
,
default
=
default
,
default
=
default
,
help
=
helpstr
,
help
=
helpstr
,
required
=
required
)
required
=
required
)
def
extend_params
(
nb
,
extend_func_name
):
def
extend_params
(
nb
,
extend_func_name
):
"""
Add parameters in the first code cell by calling a function in the notebook
"""
Add parameters in the first code cell by calling a function in the notebook
...
@@ -418,7 +429,7 @@ def extend_params(nb, extend_func_name):
...
@@ -418,7 +429,7 @@ def extend_params(nb, extend_func_name):
# Make a temporary parser that won't exit if it sees -h or --help
# Make a temporary parser that won't exit if it sees -h or --help
pre_parser
=
make_initial_parser
(
add_help
=
False
)
pre_parser
=
make_initial_parser
(
add_help
=
False
)
add_args_from_nb
(
nb
,
pre_parser
,
overwrite_reqs
=
True
)
add_args_from_nb
(
nb
,
pre_parser
,
no_required
=
True
)
known
,
_
=
pre_parser
.
parse_known_args
()
known
,
_
=
pre_parser
.
parse_known_args
()
args
=
deconsolize_args
(
vars
(
known
))
args
=
deconsolize_args
(
vars
(
known
))
...
@@ -475,7 +486,7 @@ def flatten_list(l):
...
@@ -475,7 +486,7 @@ def flatten_list(l):
def
set_figure_format
(
nb
,
enable_vector_format
):
def
set_figure_format
(
nb
,
enable_vector_format
):
"""
Set svg format in inline backend for figures
"""
Set svg format in inline backend for figures
If parameter
'
vector_f
igs
'
is set to True svg format will
If parameter
enable_
vector_f
ormat
is set to True
,
svg format will
be used for figures in the notebook rendering. Subsequently vector
be used for figures in the notebook rendering. Subsequently vector
graphics figures will be used for report.
graphics figures will be used for report.
"""
"""
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment