From abb5161ad470cce0ec870f500bd91bd8b5e4b000 Mon Sep 17 00:00:00 2001 From: Marcel Stimberg Date: Tue, 26 Mar 2024 14:34:48 +0100 Subject: [PATCH] Number 0 and 1 were rendered as false and true in C++ code 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. --- brian2/parsing/rendering.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/brian2/parsing/rendering.py b/brian2/parsing/rendering.py index 122311df5..6c93f11df 100644 --- a/brian2/parsing/rendering.py +++ b/brian2/parsing/rendering.py @@ -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":