[yt-svn] commit/yt: 3 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Wed Sep 18 14:51:01 PDT 2013
3 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/7105b3894df9/
Changeset: 7105b3894df9
Branch: yt
User: ngoldbaum
Date: 2013-09-18 22:27:50
Summary: Making all user-accessible plot window modifying functions return self.
This makes pretty display in the notebook happen whenever a modifying function
is called.
Affected #: 1 file
diff -r 81c2f6f5f983e90ec58e4d1d9da48a7a4a810832 -r 7105b3894df977fe5df009d0d75f12972482759b yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -104,7 +104,7 @@
def newfunc(*args, **kwargs):
rv = f(*args[1:], **kwargs)
args[0]._callbacks.append((f.__name__,(args,kwargs)))
- return rv
+ return args[0]
return newfunc
field_transforms = {}
@@ -515,6 +515,7 @@
mw = max([width[0][0], width[1][0]])
self.zlim = (centerz - mw/2.,
centerz + mw/2.)
+ return self
@invalidate_data
def set_center(self, new_center, unit = '1'):
@@ -537,6 +538,7 @@
new_center = [c / self.pf[unit] for c in new_center]
self.center = new_center
self.set_window(self.bounds)
+ return self
@invalidate_data
def set_antialias(self,aa):
@@ -556,6 +558,7 @@
self.buff_size = size
else:
self.buff_size = (size, size)
+ return self
@invalidate_plot
@invalidate_figure
@@ -569,11 +572,12 @@
including the margins but not the colorbar.
"""
self.window_size = float(size)
+ return self
@invalidate_data
def refresh(self):
# invalidate_data will take care of everything
- pass
+ return self
class PWViewer(PlotWindow):
"""A viewer for PlotWindows.
@@ -619,12 +623,14 @@
self._field_transform[field] = log_transform
else:
self._field_transform[field] = linear_transform
+ return self
@invalidate_plot
def set_transform(self, field, name):
if name not in field_transforms:
raise KeyError(name)
self._field_transform[field] = field_transforms[name]
+ return self
@invalidate_plot
def set_cmap(self, field, cmap_name):
@@ -647,6 +653,7 @@
for field in fields:
self._colorbar_valid = False
self._colormaps[field] = cmap_name
+ return self
@invalidate_plot
def set_zlim(self, field, zmin, zmax, dynamic_range=None):
@@ -693,6 +700,7 @@
self.plots[field].zmin = myzmin
self.plots[field].zmax = myzmax
+ return self
def setup_callbacks(self):
for key in callback_registry:
@@ -754,6 +762,7 @@
except KeyError:
raise YTUnitNotRecognized(un)
self._axes_unit_names = unit_name
+ return self
class PWViewerMPL(PWViewer):
"""Viewer using matplotlib as a backend via the WindowPlotMPL.
@@ -1007,7 +1016,7 @@
self._font_color = font_dict.pop('color')
self._font_properties = \
FontProperties(**font_dict)
-
+ return self
@invalidate_plot
def set_cmap(self, field, cmap):
@@ -1038,6 +1047,7 @@
if not is_colormap(cmap) and cmap is not None:
raise RuntimeError("Colormap '%s' does not exist!" % str(cmap))
self.plots[field].image.set_cmap(cmap)
+ return self
def save(self, name=None, mpl_kwargs=None):
"""saves the plot to disk.
https://bitbucket.org/yt_analysis/yt/commits/3a30978c25bf/
Changeset: 3a30978c25bf
Branch: yt
User: ngoldbaum
Date: 2013-09-18 22:28:13
Summary: Improving axes labels for cosmological length units.
Affected #: 1 file
diff -r 7105b3894df977fe5df009d0d75f12972482759b -r 3a30978c25bff2907e795ffe7faef158e2c7a382 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -903,10 +903,23 @@
cax)
axes_unit_labels = ['', '']
+ comoving = False
+ hinv = False
for i, un in enumerate((unit_x, unit_y)):
+ if un.endswith('cm') and un != 'cm':
+ comoving = True
+ un = un[:-2]
+ # no length units end in h so this is safe
+ if un.endswith('h'):
+ hinv = True
+ un = un[:-1]
if un in formatted_length_unit_names:
un = formatted_length_unit_names[un]
if un not in ['1', 'u', 'unitary']:
+ if hinv:
+ un = un + '\,h^{-1}'
+ if comoving:
+ un = 'Comoving\/'+un
axes_unit_labels[i] = '\/\/('+un+')'
if self.oblique:
https://bitbucket.org/yt_analysis/yt/commits/f793b5d63cb9/
Changeset: f793b5d63cb9
Branch: yt
User: samskillman
Date: 2013-09-18 23:50:57
Summary: Merged in ngoldbaum/yt (pull request #600)
Plot window improvements: cosmological length units, pretty notebook display
Affected #: 1 file
diff -r 629b16f593192d87c080f969236bca9c0881a366 -r f793b5d63cb91f99ebb7656df021da11ed474808 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -104,7 +104,7 @@
def newfunc(*args, **kwargs):
rv = f(*args[1:], **kwargs)
args[0]._callbacks.append((f.__name__,(args,kwargs)))
- return rv
+ return args[0]
return newfunc
field_transforms = {}
@@ -515,6 +515,7 @@
mw = max([width[0][0], width[1][0]])
self.zlim = (centerz - mw/2.,
centerz + mw/2.)
+ return self
@invalidate_data
def set_center(self, new_center, unit = '1'):
@@ -537,6 +538,7 @@
new_center = [c / self.pf[unit] for c in new_center]
self.center = new_center
self.set_window(self.bounds)
+ return self
@invalidate_data
def set_antialias(self,aa):
@@ -556,6 +558,7 @@
self.buff_size = size
else:
self.buff_size = (size, size)
+ return self
@invalidate_plot
@invalidate_figure
@@ -569,11 +572,12 @@
including the margins but not the colorbar.
"""
self.window_size = float(size)
+ return self
@invalidate_data
def refresh(self):
# invalidate_data will take care of everything
- pass
+ return self
class PWViewer(PlotWindow):
"""A viewer for PlotWindows.
@@ -619,12 +623,14 @@
self._field_transform[field] = log_transform
else:
self._field_transform[field] = linear_transform
+ return self
@invalidate_plot
def set_transform(self, field, name):
if name not in field_transforms:
raise KeyError(name)
self._field_transform[field] = field_transforms[name]
+ return self
@invalidate_plot
def set_cmap(self, field, cmap_name):
@@ -647,6 +653,7 @@
for field in fields:
self._colorbar_valid = False
self._colormaps[field] = cmap_name
+ return self
@invalidate_plot
def set_zlim(self, field, zmin, zmax, dynamic_range=None):
@@ -693,6 +700,7 @@
self.plots[field].zmin = myzmin
self.plots[field].zmax = myzmax
+ return self
def setup_callbacks(self):
for key in callback_registry:
@@ -754,6 +762,7 @@
except KeyError:
raise YTUnitNotRecognized(un)
self._axes_unit_names = unit_name
+ return self
class PWViewerMPL(PWViewer):
"""Viewer using matplotlib as a backend via the WindowPlotMPL.
@@ -894,10 +903,23 @@
cax)
axes_unit_labels = ['', '']
+ comoving = False
+ hinv = False
for i, un in enumerate((unit_x, unit_y)):
+ if un.endswith('cm') and un != 'cm':
+ comoving = True
+ un = un[:-2]
+ # no length units end in h so this is safe
+ if un.endswith('h'):
+ hinv = True
+ un = un[:-1]
if un in formatted_length_unit_names:
un = formatted_length_unit_names[un]
if un not in ['1', 'u', 'unitary']:
+ if hinv:
+ un = un + '\,h^{-1}'
+ if comoving:
+ un = 'Comoving\/'+un
axes_unit_labels[i] = '\/\/('+un+')'
if self.oblique:
@@ -1007,7 +1029,7 @@
self._font_color = font_dict.pop('color')
self._font_properties = \
FontProperties(**font_dict)
-
+ return self
@invalidate_plot
def set_cmap(self, field, cmap):
@@ -1038,6 +1060,7 @@
if not is_colormap(cmap) and cmap is not None:
raise RuntimeError("Colormap '%s' does not exist!" % str(cmap))
self.plots[field].image.set_cmap(cmap)
+ return self
def save(self, name=None, mpl_kwargs=None):
"""saves the plot to disk.
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