[yt-svn] commit/yt: chummels: Merged in ngoldbaum/yt (pull request #2551)
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Fri Mar 24 08:27:41 PDT 2017
1 new commit in yt:
https://bitbucket.org/yt_analysis/yt/commits/c7f3b670327e/
Changeset: c7f3b670327e
Branch: yt
User: chummels
Date: 2017-03-24 15:27:33+00:00
Summary: Merged in ngoldbaum/yt (pull request #2551)
Make the scale callback support non-unit aspect ratios. Closes #1337.
Approved-by: Hsi-Yu Schive <hyschive at GMAIL.COM>
Approved-by: John ZuHone <jzuhone at gmail.com>
Approved-by: chummels <chummels at gmail.com>
Affected #: 2 files
diff -r 67f6393d8e53528357604621a5b5ad0ffbcc52bb -r c7f3b670327ec01fda6ad7e7210c840a91af754c yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -2033,10 +2033,6 @@
# Callback only works for plots with axis ratios of 1
xsize = plot.xlim[1] - plot.xlim[0]
- if plot.aspect != 1.0:
- raise NotImplementedError(
- "Scale callback has only been implemented for plots with no "
- "aspect ratio scaling. (aspect = {%s})".format(plot._aspect))
# Setting pos overrides corner argument
if self.pos is None:
@@ -2076,8 +2072,8 @@
text = "{scale} {units}".format(scale=int(self.coeff), units=self.unit)
image_scale = (plot.frb.convert_distance_x(self.scale) /
plot.frb.convert_distance_x(xsize)).v
-
- size_vertical = self.size_bar_args.pop('size_vertical', .005)
+ size_vertical = self.size_bar_args.pop(
+ 'size_vertical', .005 * plot.aspect)
fontproperties = self.size_bar_args.pop(
'fontproperties', plot.font_properties.copy())
frameon = self.size_bar_args.pop('frameon', self.draw_inset_box)
diff -r 67f6393d8e53528357604621a5b5ad0ffbcc52bb -r c7f3b670327ec01fda6ad7e7210c840a91af754c yt/visualization/tests/test_callbacks.py
--- a/yt/visualization/tests/test_callbacks.py
+++ b/yt/visualization/tests/test_callbacks.py
@@ -107,32 +107,38 @@
ds = fake_amr_ds(fields = ("density",))
p = ProjectionPlot(ds, ax, "density")
p.annotate_scale()
- yield assert_fname, p.save(prefix)[0]
+ assert_fname(p.save(prefix)[0])
+ p = ProjectionPlot(ds, ax, "density", width=(0.5, 1.0))
+ p.annotate_scale()
+ assert_fname(p.save(prefix)[0])
+ p = ProjectionPlot(ds, ax, "density", width=(1.0, 1.5))
+ p.annotate_scale()
+ assert_fname(p.save(prefix)[0])
p = SlicePlot(ds, ax, "density")
p.annotate_scale()
- yield assert_fname, p.save(prefix)[0]
+ assert_fname(p.save(prefix)[0])
p = OffAxisSlicePlot(ds, vector, "density")
p.annotate_scale()
- yield assert_fname, p.save(prefix)[0]
+ assert_fname(p.save(prefix)[0])
# Now we'll check a few additional minor things
p = SlicePlot(ds, "x", "density")
p.annotate_scale(corner='upper_right', coeff=10., unit='kpc')
- yield assert_fname, p.save(prefix)[0]
+ assert_fname(p.save(prefix)[0])
p = SlicePlot(ds, "x", "density")
p.annotate_scale(text_args={"size": 24})
- yield assert_fname, p.save(prefix)[0]
+ assert_fname(p.save(prefix)[0])
p = SlicePlot(ds, "x", "density")
p.annotate_scale(text_args={"font": 24})
- yield assert_raises, YTPlotCallbackError
+ assert_raises(YTPlotCallbackError)
with _cleanup_fname() as prefix:
ds = fake_amr_ds(fields = ("density",), geometry="spherical")
p = ProjectionPlot(ds, "r", "density")
p.annotate_scale()
- yield assert_raises, YTDataTypeUnsupported, p.save, prefix
+ assert_raises(YTDataTypeUnsupported, p.save, prefix)
p = ProjectionPlot(ds, "r", "density")
p.annotate_scale(coord_system="axis")
- yield assert_raises, YTDataTypeUnsupported, p.save, prefix
+ assert_raises(YTDataTypeUnsupported, p.save, prefix)
def test_line_callback():
with _cleanup_fname() as prefix:
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