From c27a12332ecbfdf6dadea63a0df3e543c4da596a Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Mon, 18 Dec 2023 16:46:56 +0100 Subject: [PATCH] .. --- python/sdist/amici/cxxcodeprinter.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/python/sdist/amici/cxxcodeprinter.py b/python/sdist/amici/cxxcodeprinter.py index 76c7f67850..a6ff17e835 100644 --- a/python/sdist/amici/cxxcodeprinter.py +++ b/python/sdist/amici/cxxcodeprinter.py @@ -343,18 +343,19 @@ def get_switch_statement( ) case_code = f"{indent1}case {expression}:" - cases_map[statement_code] = cases_map.get(statement_code, []) + [case_code] + cases_map[statement_code] = cases_map.get(statement_code, []) + [ + case_code + ] if not cases_map: return [] - def get_lines(): - for statements, case_code in cases_map.items(): - yield from case_code - yield from statements - return [ f"{indent0}switch({condition}) {{", - *(get_lines()), + *( + code + for codes in cases_map.items() + for code in itertools.chain.from_iterable(reversed(codes)) + ), indent0 + "}", ]