From f44d584f5ff9ac3fd5d5f2bd9746775e52295e90 Mon Sep 17 00:00:00 2001 From: RemDelaporteMathurin Date: Fri, 8 Aug 2025 17:04:56 -0400 Subject: [PATCH] added test + fix --- src/python/templates/template_with_macros.py | 4 ++++ test/test_convert_python.py | 1 + 2 files changed, 5 insertions(+) diff --git a/src/python/templates/template_with_macros.py b/src/python/templates/template_with_macros.py index 51bc4207..e56d7337 100644 --- a/src/python/templates/template_with_macros.py +++ b/src/python/templates/template_with_macros.py @@ -7,6 +7,10 @@ {% from 'block_macros.py' import create_block, create_integrator_block, create_bubbler_block, create_connections, create_event -%} # Create global variables +{%- if pythonCode %} +{{ pythonCode }} +{% endif -%} + {% for var in globalVariables -%} {{ var["name"] }} = {{ var["value"] }} {% endfor %} diff --git a/test/test_convert_python.py b/test/test_convert_python.py index ea43894b..116a6891 100644 --- a/test/test_convert_python.py +++ b/test/test_convert_python.py @@ -160,6 +160,7 @@ def test_bubbler_has_reset_times(): "tolerance_fpi": "1e-6", }, "globalVariables": [], + "pythonCode": "def func(t):\n print('coucou')\n return 2\n", } code = convert_graph_to_python(sample_data) print(code)