Skip to content

Commit 7fd52c7

Browse files
committed
WIP: changes layout of exercise
1 parent bb4dcb3 commit 7fd52c7

File tree

1 file changed

+5
-114
lines changed

1 file changed

+5
-114
lines changed

notebooks/basic_iteration.ipynb

Lines changed: 5 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,7 @@
253253
},
254254
{
255255
"cell_type": "markdown",
256-
"metadata": {
257-
"solution2": "hidden",
258-
"solution2_first": true
259-
},
256+
"metadata": {},
260257
"source": [
261258
"#### Exercise 1\n",
262259
"Create a workflow to calculate a various powers of ``2`` using two nodes, one for ``IdentityInterface`` with ``iterables``, and one for ``Function`` interface to calculate power of ``2``."
@@ -266,61 +263,10 @@
266263
"cell_type": "code",
267264
"execution_count": null,
268265
"metadata": {
269-
"solution2": "hidden"
270-
},
271-
"outputs": [],
272-
"source": [
273-
"# lets start from the Identity node\n",
274-
"from nipype import Function, Node, Workflow\n",
275-
"from nipype.interfaces.utility import IdentityInterface\n",
276-
"\n",
277-
"iden = Node(IdentityInterface(fields=['number']), name=\"identity\") \n",
278-
"iden.iterables = [(\"number\", range(8))]"
279-
]
280-
},
281-
{
282-
"cell_type": "code",
283-
"execution_count": null,
284-
"metadata": {
285-
"solution2": "hidden"
286-
},
287-
"outputs": [],
288-
"source": [
289-
"# the second node should use the Function interface\n",
290-
"\n",
291-
"def power_of_two(n):\n",
292-
" return 2**n\n",
293-
"\n",
294-
"# Create Node\n",
295-
"power = Node(Function(input_names=[\"n\"],\n",
296-
" output_names=[\"pow\"],\n",
297-
" function=power_of_two),\n",
298-
" name='power')"
299-
]
300-
},
301-
{
302-
"cell_type": "code",
303-
"execution_count": null,
304-
"metadata": {
305-
"solution2": "hidden"
266+
"solution2": "hidden",
267+
"solution2_first": true
306268
},
307269
"outputs": [],
308-
"source": [
309-
"#and now the workflow\n",
310-
"wf_ex1 = Workflow(name=\"exercise1\")\n",
311-
"wf_ex1.connect(iden, \"number\", power, \"n\")\n",
312-
"res_ex1 = wf_ex1.run()\n",
313-
"\n",
314-
"# we can print the results\n",
315-
"for i in range(8):\n",
316-
" print(list(res_ex1.nodes())[i].result.outputs)"
317-
]
318-
},
319-
{
320-
"cell_type": "code",
321-
"execution_count": null,
322-
"metadata": {},
323-
"outputs": [],
324270
"source": [
325271
"# write your solution here"
326272
]
@@ -333,11 +279,11 @@
333279
},
334280
"outputs": [],
335281
"source": [
336-
"# lets start from theIdentity node\n",
282+
"# lets start from the Identity node\n",
337283
"from nipype import Function, Node, Workflow\n",
338284
"from nipype.interfaces.utility import IdentityInterface\n",
339285
"\n",
340-
"iden = Node(IdentityInterface(fields=['number']), name=\"identity\") \n",
286+
"iden = Node(IdentityInterface(fields=['number']), name=\"identity\")\n",
341287
"iden.iterables = [(\"number\", range(8))]"
342288
]
343289
},
@@ -350,61 +296,6 @@
350296
"outputs": [],
351297
"source": [
352298
"# the second node should use the Function interface\n",
353-
"\n",
354-
"def power_of_two(n):\n",
355-
" return 2**n\n",
356-
"\n",
357-
"# Create Node\n",
358-
"power = Node(Function(input_names=[\"n\"],\n",
359-
" output_names=[\"pow\"],\n",
360-
" function=power_of_two),\n",
361-
" name='power')"
362-
]
363-
},
364-
{
365-
"cell_type": "code",
366-
"execution_count": null,
367-
"metadata": {
368-
"solution2": "hidden"
369-
},
370-
"outputs": [],
371-
"source": [
372-
"# lets start from theIdentity node\n",
373-
"from nipype import Function, Node, Workflow\n",
374-
"from nipype.interfaces.utility import IdentityInterface\n",
375-
"\n",
376-
"iden = Node(IdentityInterface(fields=['number']), name=\"identity\") \n",
377-
"iden.iterables = [(\"number\", range(8))]\n"
378-
]
379-
},
380-
{
381-
"cell_type": "code",
382-
"execution_count": null,
383-
"metadata": {
384-
"solution2": "hidden"
385-
},
386-
"outputs": [],
387-
"source": [
388-
"#and now the workflow\n",
389-
"wf_ex1 = Workflow(name=\"exercise1\")\n",
390-
"wf_ex1.connect(iden, \"number\", power, \"n\")\n",
391-
"res_ex1 = wf_ex1.run()\n",
392-
"\n",
393-
"# we can print the results\n",
394-
"for i in range(8):\n",
395-
" print(list(res_ex1.nodes())[i].result.outputs)"
396-
]
397-
},
398-
{
399-
"cell_type": "code",
400-
"execution_count": null,
401-
"metadata": {
402-
"solution2": "hidden"
403-
},
404-
"outputs": [],
405-
"source": [
406-
"# the second node should use the Function interface\n",
407-
"\n",
408299
"def power_of_two(n):\n",
409300
" return 2**n\n",
410301
"\n",

0 commit comments

Comments
 (0)