[yt-svn] commit/yt: 5 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Wed Aug 14 06:40:03 PDT 2013
5 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/3e995dc1cd34/
Changeset: 3e995dc1cd34
Branch: yt
User: ngoldbaum
Date: 2013-08-12 06:40:25
Summary: Trying to use _repr_png_ without overriding __repr__
Affected #: 2 files
diff -r d33be33da703510aa9cf4e85da906bcf0ac61229 -r 3e995dc1cd340e536e5ba800b3fedf418a8cb682 yt/visualization/base_plot_types.py
--- a/yt/visualization/base_plot_types.py
+++ b/yt/visualization/base_plot_types.py
@@ -96,3 +96,10 @@
norm=norm, vmin=self.zmin, aspect=aspect,
vmax=self.zmax, cmap=cmap)
self.cb = self.figure.colorbar(self.image, self.cax)
+
+ def _repr_png_(self):
+ canvas = FigureCanvasAgg(self.figure)
+ f = cStringIO.StringIO()
+ canvas.print_figure(f)
+ f.seek(0)
+ return f.read()
diff -r d33be33da703510aa9cf4e85da906bcf0ac61229 -r 3e995dc1cd340e536e5ba800b3fedf418a8cb682 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -1135,11 +1135,6 @@
except YTNotInsideNotebook:
return self.save(name=name, mpl_kwargs=mpl_kwargs)
- def __repr__(self):
- if "__IPYTHON__" in dir(__builtin__):
- self.show()
- return super(PWViewerMPL, self).__repr__()
-
class SlicePlot(PWViewerMPL):
r"""Creates a slice plot from a parameter file
https://bitbucket.org/yt_analysis/yt/commits/6045463f3239/
Changeset: 6045463f3239
Branch: yt
User: ngoldbaum
Date: 2013-08-12 07:21:41
Summary: Using _repr_html() to display a list of images.
Affected #: 2 files
diff -r 3e995dc1cd340e536e5ba800b3fedf418a8cb682 -r 6045463f32397dcfe7eec028e6c62ce60d7ab3ef yt/visualization/base_plot_types.py
--- a/yt/visualization/base_plot_types.py
+++ b/yt/visualization/base_plot_types.py
@@ -23,6 +23,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
import matplotlib
+import cStringIO
from ._mpl_imports import \
FigureCanvasAgg, FigureCanvasPdf, FigureCanvasPS
from yt.funcs import \
diff -r 3e995dc1cd340e536e5ba800b3fedf418a8cb682 -r 6045463f32397dcfe7eec028e6c62ce60d7ab3ef yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -1135,6 +1135,15 @@
except YTNotInsideNotebook:
return self.save(name=name, mpl_kwargs=mpl_kwargs)
+ def _repr_html_(self):
+ """Return an html representation of the plot object. Will display as a
+ png for each WindowPlotMPL instance in self.plots"""
+ ret = ''
+ for field in self.plots:
+ img = base64.b64encode(self.plots[field]._repr_png_())
+ ret += '<img src="data:image/png;base64,%s"><br>' % img
+ return ret
+
class SlicePlot(PWViewerMPL):
r"""Creates a slice plot from a parameter file
https://bitbucket.org/yt_analysis/yt/commits/74f8e7bd76d7/
Changeset: 74f8e7bd76d7
Branch: yt
User: ngoldbaum
Date: 2013-08-12 19:33:07
Summary: Merging with my plotting PR.
Affected #: 2 files
diff -r 6c210dc42c5b750d31235ddefbc6bb78c1183009 -r 74f8e7bd76d73269551a56490d416b20029d43a6 yt/visualization/base_plot_types.py
--- a/yt/visualization/base_plot_types.py
+++ b/yt/visualization/base_plot_types.py
@@ -23,6 +23,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
import matplotlib
+import cStringIO
from ._mpl_imports import \
FigureCanvasAgg, FigureCanvasPdf, FigureCanvasPS
from yt.funcs import \
@@ -96,3 +97,10 @@
norm=norm, vmin=self.zmin, aspect=aspect,
vmax=self.zmax, cmap=cmap)
self.cb = self.figure.colorbar(self.image, self.cax)
+
+ def _repr_png_(self):
+ canvas = FigureCanvasAgg(self.figure)
+ f = cStringIO.StringIO()
+ canvas.print_figure(f)
+ f.seek(0)
+ return f.read()
diff -r 6c210dc42c5b750d31235ddefbc6bb78c1183009 -r 74f8e7bd76d73269551a56490d416b20029d43a6 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -1135,10 +1135,14 @@
except YTNotInsideNotebook:
return self.save(name=name, mpl_kwargs=mpl_kwargs)
- def __repr__(self):
- if "__IPYTHON__" in dir(__builtin__):
- self.show()
- return super(PWViewerMPL, self).__repr__()
+ def _repr_html_(self):
+ """Return an html representation of the plot object. Will display as a
+ png for each WindowPlotMPL instance in self.plots"""
+ ret = ''
+ for field in self.plots:
+ img = base64.b64encode(self.plots[field]._repr_png_())
+ ret += '<img src="data:image/png;base64,%s"><br>' % img
+ return ret
class SlicePlot(PWViewerMPL):
r"""Creates a slice plot from a parameter file
https://bitbucket.org/yt_analysis/yt/commits/2464e8f034b1/
Changeset: 2464e8f034b1
Branch: yt
User: ngoldbaum
Date: 2013-08-12 20:28:01
Summary: Fixing PlotWindow.show() to work correctly with IPython 1.0.
Affected #: 2 files
diff -r 74f8e7bd76d73269551a56490d416b20029d43a6 -r 2464e8f034b1b1165e0943f4758603a7a05d057f yt/funcs.py
--- a/yt/funcs.py
+++ b/yt/funcs.py
@@ -250,6 +250,17 @@
%(filename)s:%(lineno)s
"""
+def get_ipython_api_version():
+ import IPython
+ if LooseVersion(IPython.__version__) <= LooseVersion('0.10'):
+ api_version = '0.10'
+ elif LooseVersion(IPython.__version__) <= LooseVersion('1.0'):
+ api_version = '0.11'
+ else:
+ api_version = '1.0'
+
+ return api_version
+
def insert_ipython(num_up=1):
"""
Placed inside a function, this will insert an IPython interpreter at that
@@ -259,13 +270,7 @@
defaults to 1 so that this function itself is stripped off.
"""
- import IPython
- if LooseVersion(IPython.__version__) <= LooseVersion('0.10'):
- api_version = '0.10'
- elif LooseVersion(IPython.__version__) <= LooseVersion('1.0'):
- api_version = '0.11'
- else:
- api_version = '1.0'
+ api_version = get_ipython_api_version()
stack = inspect.stack()
frame = inspect.stack()[num_up]
diff -r 74f8e7bd76d73269551a56490d416b20029d43a6 -r 2464e8f034b1b1165e0943f4758603a7a05d057f yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -52,7 +52,7 @@
from yt.utilities.delaunay.triangulate import Triangulation as triang
from yt.funcs import \
mylog, defaultdict, iterable, ensure_list, \
- fix_axis, get_image_suffix
+ fix_axis, get_image_suffix, get_ipython_api_version
from yt.utilities.lib import write_png_to_string
from yt.utilities.definitions import \
x_dict, y_dict, \
@@ -1123,7 +1123,11 @@
"""
if "__IPYTHON__" in dir(__builtin__):
- self._send_zmq()
+ api_version = get_ipython_api_version()
+ if api_version in ('0.10', '0.11'):
+ self._send_zmq()
+ else:
+ return self
else:
raise YTNotInsideNotebook
https://bitbucket.org/yt_analysis/yt/commits/ed0606519b9e/
Changeset: ed0606519b9e
Branch: yt
User: MatthewTurk
Date: 2013-08-14 15:39:59
Summary: Merged in ngoldbaum/yt (pull request #568)
Formatting plots for the notebook in a display independent manner
Affected #: 3 files
diff -r b4963f863671c0b7f5aeb63eff3b857491b28e78 -r ed0606519b9e3ba18ccf5724517f2785860c68ea yt/funcs.py
--- a/yt/funcs.py
+++ b/yt/funcs.py
@@ -250,6 +250,17 @@
%(filename)s:%(lineno)s
"""
+def get_ipython_api_version():
+ import IPython
+ if LooseVersion(IPython.__version__) <= LooseVersion('0.10'):
+ api_version = '0.10'
+ elif LooseVersion(IPython.__version__) <= LooseVersion('1.0'):
+ api_version = '0.11'
+ else:
+ api_version = '1.0'
+
+ return api_version
+
def insert_ipython(num_up=1):
"""
Placed inside a function, this will insert an IPython interpreter at that
@@ -259,13 +270,7 @@
defaults to 1 so that this function itself is stripped off.
"""
- import IPython
- if LooseVersion(IPython.__version__) <= LooseVersion('0.10'):
- api_version = '0.10'
- elif LooseVersion(IPython.__version__) <= LooseVersion('1.0'):
- api_version = '0.11'
- else:
- api_version = '1.0'
+ api_version = get_ipython_api_version()
stack = inspect.stack()
frame = inspect.stack()[num_up]
diff -r b4963f863671c0b7f5aeb63eff3b857491b28e78 -r ed0606519b9e3ba18ccf5724517f2785860c68ea yt/visualization/base_plot_types.py
--- a/yt/visualization/base_plot_types.py
+++ b/yt/visualization/base_plot_types.py
@@ -23,6 +23,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
import matplotlib
+import cStringIO
from ._mpl_imports import \
FigureCanvasAgg, FigureCanvasPdf, FigureCanvasPS
from yt.funcs import \
@@ -96,3 +97,10 @@
norm=norm, vmin=self.zmin, aspect=aspect,
vmax=self.zmax, cmap=cmap)
self.cb = self.figure.colorbar(self.image, self.cax)
+
+ def _repr_png_(self):
+ canvas = FigureCanvasAgg(self.figure)
+ f = cStringIO.StringIO()
+ canvas.print_figure(f)
+ f.seek(0)
+ return f.read()
diff -r b4963f863671c0b7f5aeb63eff3b857491b28e78 -r ed0606519b9e3ba18ccf5724517f2785860c68ea yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -52,7 +52,7 @@
from yt.utilities.delaunay.triangulate import Triangulation as triang
from yt.funcs import \
mylog, defaultdict, iterable, ensure_list, \
- fix_axis, get_image_suffix
+ fix_axis, get_image_suffix, get_ipython_api_version
from yt.utilities.lib import write_png_to_string
from yt.utilities.definitions import \
x_dict, y_dict, \
@@ -1123,7 +1123,11 @@
"""
if "__IPYTHON__" in dir(__builtin__):
- self._send_zmq()
+ api_version = get_ipython_api_version()
+ if api_version in ('0.10', '0.11'):
+ self._send_zmq()
+ else:
+ return self
else:
raise YTNotInsideNotebook
@@ -1135,10 +1139,14 @@
except YTNotInsideNotebook:
return self.save(name=name, mpl_kwargs=mpl_kwargs)
- def __repr__(self):
- if "__IPYTHON__" in dir(__builtin__):
- self.show()
- return super(PWViewerMPL, self).__repr__()
+ def _repr_html_(self):
+ """Return an html representation of the plot object. Will display as a
+ png for each WindowPlotMPL instance in self.plots"""
+ ret = ''
+ for field in self.plots:
+ img = base64.b64encode(self.plots[field]._repr_png_())
+ ret += '<img src="data:image/png;base64,%s"><br>' % img
+ return ret
class SlicePlot(PWViewerMPL):
r"""Creates a slice plot from a parameter file
Repository URL: https://bitbucket.org/yt_analysis/yt/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the yt-svn
mailing list