Skip to content

Commit

Permalink
Improve the example in the python tutorial. (#1019)
Browse files Browse the repository at this point in the history
The python code-generation example previously failed to handle
wrapped expressions like: "(a * (b + c))".

Fix typo in nmodl python tutorial.
  • Loading branch information
ctrl-z-9000-times authored Sep 1, 2023
1 parent a309bc1 commit 638b870
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion docs/notebooks/nmodl-python-tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,11 @@
" self.pycode += \" \" * 4 * self.indent + \"else:\\n\"\n",
" node.get_statement_block().accept(self)\n",
"\n",
" def visit_wrapped_expression(self, node):\n",
" self.pycode += \"(\"\n",
" node.visit_children(self)\n",
" self.pycode += \")\"\n",
"\n",
" def visit_binary_expression(self, node):\n",
" lhs = node.lhs\n",
" rhs = node.rhs\n",
Expand All @@ -701,7 +706,7 @@
" self.pycode += node.name.get_node_name()\n",
"\n",
" def visit_integer(self, node):\n",
" self.pycode += nmod.to_nmodl(node)\n",
" self.pycode += nmodl.to_nmodl(node)\n",
"\n",
" def visit_double(self, node):\n",
" self.pycode += nmodl.to_nmodl(node)"
Expand Down

0 comments on commit 638b870

Please sign in to comment.