Commit fdba3272 authored by Ayush Tiwari's avatar Ayush Tiwari

erp5_data_notebook bt5: Close plot object and after every call to...

erp5_data_notebook bt5: Close plot object and after every call to Base_dispalyImage with matplotlib object
parent d52666e7
...@@ -190,8 +190,11 @@ def Base_displayImage(self, image_object=None): ...@@ -190,8 +190,11 @@ def Base_displayImage(self, image_object=None):
""" """
External function to display Image objects to jupyter frontend. External function to display Image objects to jupyter frontend.
XXX: This function is intented to be called from Base_executeJupyter XXX: This function is intented to be called from Base_executeJupyter
or Jupyter frontend.That's why printing string and returning None or Jupyter frontend.That's why printing string and returning None.
Also, it clears the plot for Matplotlib object after every call, so
in case of saving the plot, its essential to call Base_savePlot before
calling Base_displayImage.
Parameters Parameters
---------- ----------
...@@ -228,6 +231,8 @@ def Base_displayImage(self, image_object=None): ...@@ -228,6 +231,8 @@ def Base_displayImage(self, image_object=None):
# Encode the value in figfile to base64 string so as to serve it jupyter frontend # Encode the value in figfile to base64 string so as to serve it jupyter frontend
figdata = base64.b64encode(figfile.getvalue()) figdata = base64.b64encode(figfile.getvalue())
mime_type = 'image/png' mime_type = 'image/png'
# Clear the plot figures after every execution
image_object.close()
# XXX: We are not returning anything because we want this function to be called # XXX: We are not returning anything because we want this function to be called
# by Base_executeJupyter , inside exec(), and its better to get the printed string # by Base_executeJupyter , inside exec(), and its better to get the printed string
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
<string>W: 91, 8: Use of exec (exec-used)</string> <string>W: 91, 8: Use of exec (exec-used)</string>
<string>W:115, 8: Use of exec (exec-used)</string> <string>W:115, 8: Use of exec (exec-used)</string>
<string>W:121, 8: Use of exec (exec-used)</string> <string>W:121, 8: Use of exec (exec-used)</string>
<string>W:213, 4: Using the global statement (global-statement)</string> <string>W:216, 4: Using the global statement (global-statement)</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment