@@ -71,11 +71,15 @@ def extract_parameter_dict(nb, lang=None, tag='Parameters'):
71
71
"""Returns a dictionary of Parameter objects derived from the notebook.
72
72
73
73
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.
76
77
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
78
79
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.
79
83
"""
80
84
params = extract_parameters (nb , lang , tag = tag )
81
85
return {p .name : p for p in params }
@@ -84,11 +88,15 @@ def extract_parameters(nb, lang=None, tag='Parameters'):
84
88
"""Returns a list of Parameter instances derived from the notebook.
85
89
86
90
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.
89
94
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
91
96
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.
92
100
"""
93
101
drv = get_driver_module (nb , override = lang )
94
102
cell = get_parameter_cell (nb ,tag )
@@ -144,7 +152,7 @@ def parameter_values(params, new_values=None, new='ignore', **kwargs):
144
152
145
153
def replace_definitions (nb , values , execute = False , execute_resources = None ,
146
154
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.
148
156
149
157
values should be a dict (from :func:`extract_parameter_dict`) or a list
150
158
(from :func:`extract_parameters`) of :class:`Parameter` objects,
@@ -155,8 +163,12 @@ def replace_definitions(nb, values, execute=False, execute_resources=None,
155
163
and if possible should contain a 'path' key for the working directory in
156
164
which to run the notebook.
157
165
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
159
167
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.
160
172
"""
161
173
if isinstance (values , list ):
162
174
values = {p .name : p for p in values }
0 commit comments