Skip to content

Commit

Permalink
Number 0 and 1 were rendered as false and true in C++ code
Browse files Browse the repository at this point in the history
Usually, this shouldn't be a problem (implicit type cast), but it is at least surprising and may also break test assuming that the numbers appear in the code.
  • Loading branch information
mstimberg committed Mar 26, 2024
1 parent 2082778 commit abb5161
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion brian2/parsing/rendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,12 @@ def render_BinOp(self, node):
return NodeRenderer.render_BinOp(self, node)

def render_Constant(self, node):
return {True: "true", False: "false"}.get(node.value, repr(node.value))
if node.value is True:
return "true"
elif node.value is False:
return "false"
else:
return repr(node.value)

def render_Name(self, node):
if node.id == "inf":
Expand Down

0 comments on commit abb5161

Please sign in to comment.