From 8cb367dbf552a294a7afce07476aeb201c1fbcf8 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Mon, 30 Nov 2015 10:59:44 -0600 Subject: [PATCH] More kernel printing/tutorial tweaks --- doc/tutorial.rst | 2 +- loopy/kernel/__init__.py | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/doc/tutorial.rst b/doc/tutorial.rst index 110e35bbb..54b78daa1 100644 --- a/doc/tutorial.rst +++ b/doc/tutorial.rst @@ -316,7 +316,7 @@ that these dependencies show up there, too: .. doctest:: - >>> print(knl) + >>> print(knl.stringify(with_dependencies=True)) --------------------------------------------------------------------------- KERNEL: loopy_kernel --------------------------------------------------------------------------- diff --git a/loopy/kernel/__init__.py b/loopy/kernel/__init__.py index 917279408..e42aa1fd7 100644 --- a/loopy/kernel/__init__.py +++ b/loopy/kernel/__init__.py @@ -964,7 +964,7 @@ class LoopKernel(RecordWithoutPickling): # {{{ pretty-printing - def __str__(self): + def stringify(self, with_dependencies=False): lines = [] from loopy.preprocess import add_default_dependencies @@ -1066,8 +1066,9 @@ class LoopKernel(RecordWithoutPickling): if dep_lines: lines.append(sep) lines.append("DEPENDENCIES: " - "use loopy.show_dependency_graph to visualize") - #lines.extend(dep_lines) + "(use loopy.show_dependency_graph to visualize)") + if with_dependencies: + lines.extend(dep_lines) lines.append(sep) @@ -1079,6 +1080,9 @@ class LoopKernel(RecordWithoutPickling): return "\n".join(lines) + def __str__(self): + return self.stringify() + # }}} # {{{ implementation arguments -- GitLab