|
22 | 22 | "source": [ |
23 | 23 | "from pydra.design import python\n", |
24 | 24 | "\n", |
25 | | - "# Note that we use CamelCase as the return of the is a class\n", |
| 25 | + "\n", |
| 26 | + "# Note that we use PascalCase because the object returned by the decorator is actually a class\n", |
26 | 27 | "@python.define\n", |
27 | 28 | "def MyFirstTaskDef(a, b):\n", |
28 | 29 | " \"\"\"Sample function for testing\"\"\"\n", |
|
72 | 73 | " \"\"\"Sample function for testing\"\"\"\n", |
73 | 74 | " return a + b, a - b\n", |
74 | 75 | "\n", |
| 76 | + "\n", |
75 | 77 | "named_output_task = NamedOutputTaskDef(a=2, b=1)\n", |
76 | 78 | "\n", |
77 | 79 | "outputs = named_output_task()\n", |
|
123 | 125 | "source": [ |
124 | 126 | "from pydra.design import python\n", |
125 | 127 | "\n", |
126 | | - "# Note that we use CamelCase as the function is translated to a class\n", |
127 | 128 | "\n", |
128 | 129 | "@python.define\n", |
129 | 130 | "def MyTypedTask(a: int, b: float) -> float:\n", |
130 | 131 | " \"\"\"Sample function for testing\"\"\"\n", |
131 | 132 | " return a + b\n", |
132 | 133 | "\n", |
| 134 | + "\n", |
133 | 135 | "try:\n", |
134 | 136 | " # 1.5 is not an integer so this should raise a TypeError\n", |
135 | 137 | " my_typed_task = MyTypedTask(a=1.5, b=2.0)\n", |
|
164 | 166 | "from pprint import pprint\n", |
165 | 167 | "from pydra.engine.helpers import fields_dict\n", |
166 | 168 | "\n", |
167 | | - "@python.define\n", |
| 169 | + "\n", |
| 170 | + "@python.define(outputs=[\"c\", \"d\"])\n", |
168 | 171 | "def DocStrDef(a: int, b: float) -> tuple[float, float]:\n", |
169 | 172 | " \"\"\"Sample function for testing\n", |
170 | 173 | "\n", |
|
179 | 182 | " \"\"\"\n", |
180 | 183 | " return a + b, a * b\n", |
181 | 184 | "\n", |
| 185 | + "\n", |
182 | 186 | "pprint(fields_dict(DocStrDef))\n", |
183 | 187 | "pprint(fields_dict(DocStrDef.Outputs))" |
184 | 188 | ] |
|
0 commit comments