From c4096908581b5f71760cf26f8c733501e638319d Mon Sep 17 00:00:00 2001 From: Stephan Seitz <stephan.seitz@fau.de> Date: Tue, 13 Aug 2019 16:48:19 +0200 Subject: [PATCH] Print str in CBackend as str --- pystencils/astnodes.py | 3 +-- pystencils/backends/cbackend.py | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pystencils/astnodes.py b/pystencils/astnodes.py index 38bb988..1fcb5ff 100644 --- a/pystencils/astnodes.py +++ b/pystencils/astnodes.py @@ -703,8 +703,7 @@ class DestructuringBindingsForFieldClass(Node): corresponding_field_names = {s.field_name for s in undefined_field_symbols if hasattr(s, 'field_name')} corresponding_field_names |= {s.field_names[0] for s in undefined_field_symbols if hasattr(s, 'field_names')} return {TypedSymbol(f, self.CLASS_NAME_TEMPLATE.format(dtype=field_map[f].dtype, ndim=field_map[f].ndim) + '&') - for f in corresponding_field_names} | \ - (self.body.undefined_symbols - undefined_field_symbols) + for f in corresponding_field_names} | (self.body.undefined_symbols - undefined_field_symbols) def subs(self, subs_dict) -> None: """Inplace! substitute, similar to sympy's but modifies the AST inplace.""" diff --git a/pystencils/backends/cbackend.py b/pystencils/backends/cbackend.py index 38cba5c..2362086 100644 --- a/pystencils/backends/cbackend.py +++ b/pystencils/backends/cbackend.py @@ -168,6 +168,8 @@ class CBackend: return result def _print(self, node): + if isinstance(node, str): + return node for cls in type(node).__mro__: method_name = "_print_" + cls.__name__ if hasattr(self, method_name): -- GitLab