From b5aae58666ba2ce67031e80dc3ba73aebdddc26a Mon Sep 17 00:00:00 2001
From: zhongzyd <zhongzyd@qq.com>
Date: Wed, 25 May 2016 08:05:25 +0800
Subject: [PATCH] python 3.5 compatibility and better display effect (#2338)

---
 tensorflow/g3doc/tutorials/pdes/index.md | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/tensorflow/g3doc/tutorials/pdes/index.md b/tensorflow/g3doc/tutorials/pdes/index.md
index ca240347598..9bc4340285e 100755
--- a/tensorflow/g3doc/tutorials/pdes/index.md
+++ b/tensorflow/g3doc/tutorials/pdes/index.md
@@ -19,7 +19,7 @@ import numpy as np
 
 #Imports for visualization
 import PIL.Image
-from cStringIO import StringIO
+from io import BytesIO
 from IPython.display import clear_output, Image, display
 ```
 
@@ -30,8 +30,9 @@ def DisplayArray(a, fmt='jpeg', rng=[0,1]):
   """Display an array as a picture."""
   a = (a - rng[0])/float(rng[1] - rng[0])*255
   a = np.uint8(np.clip(a, 0, 255))
-  f = StringIO()
+  f = BytesIO()
   PIL.Image.fromarray(a).save(f, fmt)
+  clear_output(wait = True)
   display(Image(data=f.getvalue()))
 ```
 
@@ -132,10 +133,7 @@ tf.initialize_all_variables().run()
 for i in range(1000):
   # Step simulation
   step.run({eps: 0.03, damping: 0.04})
-  # Visualize every 50 steps
-  if i % 50 == 0:
-    clear_output()
-    DisplayArray(U.eval(), rng=[-0.1, 0.1])
+  DisplayArray(U.eval(), rng=[-0.1, 0.1])
 ```
 
 ![jpeg](../../images/pde_output_2.jpg)