Skip to content

Commit a38a712

Browse files
committed
Update docstrings
1 parent 23c9c2e commit a38a712

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

nbparameterise/code.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,15 @@ def extract_parameter_dict(nb, lang=None, tag='Parameters'):
7171
"""Returns a dictionary of Parameter objects derived from the notebook.
7272
7373
This looks for assignments (like 'n = 50') in the first code cell of the
74-
notebook. The parameters may also have some metadata stored in the notebook
75-
metadata; this will be attached as the .metadata instance on each one.
74+
notebook, or the first cell with a 'parameters' tag. The parameters may also
75+
have some metadata stored in the notebook metadata; this will be attached as
76+
the .metadata instance on each one.
7677
77-
lang may be used to override the kernel name embedded in the notebook. For
78+
*lang* may be used to override the kernel name embedded in the notebook. For
7879
now, nbparameterise only handles 'python'.
80+
81+
*tag* specifies the cell tag which it will look for, with case-insensitive
82+
matching. If no code cell has the tag, it will take the first code cell.
7983
"""
8084
params = extract_parameters(nb, lang, tag=tag)
8185
return {p.name: p for p in params}
@@ -84,11 +88,15 @@ def extract_parameters(nb, lang=None, tag='Parameters'):
8488
"""Returns a list of Parameter instances derived from the notebook.
8589
8690
This looks for assignments (like 'n = 50') in the first code cell of the
87-
notebook. The parameters may also have some metadata stored in the notebook
88-
metadata; this will be attached as the .metadata instance on each one.
91+
notebook, or the first cell with a 'parameters' tag. The parameters may also
92+
have some metadata stored in the notebook metadata; this will be attached as
93+
the .metadata instance on each one.
8994
90-
lang may be used to override the kernel name embedded in the notebook. For
95+
*lang* may be used to override the kernel name embedded in the notebook. For
9196
now, nbparameterise only handles 'python'.
97+
98+
*tag* specifies the cell tag which it will look for, with case-insensitive
99+
matching. If no code cell has the tag, it will take the first code cell.
92100
"""
93101
drv = get_driver_module(nb, override=lang)
94102
cell = get_parameter_cell(nb,tag)
@@ -144,7 +152,7 @@ def parameter_values(params, new_values=None, new='ignore', **kwargs):
144152

145153
def replace_definitions(nb, values, execute=False, execute_resources=None,
146154
lang=None, *, comments=True, tag='Parameters'):
147-
"""Return a copy of nb with the first code cell defining the given parameters.
155+
"""Return a copy of nb with the parameter cell defining the given parameters.
148156
149157
values should be a dict (from :func:`extract_parameter_dict`) or a list
150158
(from :func:`extract_parameters`) of :class:`Parameter` objects,
@@ -155,8 +163,12 @@ def replace_definitions(nb, values, execute=False, execute_resources=None,
155163
and if possible should contain a 'path' key for the working directory in
156164
which to run the notebook.
157165
158-
lang may be used to override the kernel name embedded in the notebook. For
166+
*lang* may be used to override the kernel name embedded in the notebook. For
159167
now, nbparameterise only handles 'python3' and 'python2'.
168+
169+
*tag* specifies the cell tag which the parameter cell should have, with
170+
case-insensitive matching. If no code cell has the tag, it will replace the
171+
first code cell.
160172
"""
161173
if isinstance(values, list):
162174
values = {p.name: p for p in values}

0 commit comments

Comments
 (0)