[yt-svn] commit/yt: xarthisius: Merged in MatthewTurk/yt (pull request #1530)
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Tue Jul 14 06:33:51 PDT 2015
1 new commit in yt:
https://bitbucket.org/yt_analysis/yt/commits/b7b8cdbad250/
Changeset: b7b8cdbad250
Branch: yt
User: xarthisius
Date: 2015-07-14 13:33:37+00:00
Summary: Merged in MatthewTurk/yt (pull request #1530)
Add callback answer tests
Affected #: 3 files
diff -r c014ad925d83b6f1a7d2124cd941861a87e20d19 -r b7b8cdbad2505dea1391bddbe3ab6e5d65f2e9b6 yt/utilities/answer_testing/framework.py
--- a/yt/utilities/answer_testing/framework.py
+++ b/yt/utilities/answer_testing/framework.py
@@ -662,9 +662,11 @@
class PlotWindowAttributeTest(AnswerTestingTest):
_type_name = "PlotWindowAttribute"
- _attrs = ('plot_type', 'plot_field', 'plot_axis', 'attr_name', 'attr_args')
+ _attrs = ('plot_type', 'plot_field', 'plot_axis', 'attr_name', 'attr_args',
+ 'callback_id')
def __init__(self, ds_fn, plot_field, plot_axis, attr_name, attr_args,
- decimals, plot_type = 'SlicePlot'):
+ decimals, plot_type = 'SlicePlot', callback_id = "",
+ callback_runners = None):
super(PlotWindowAttributeTest, self).__init__(ds_fn)
self.plot_type = plot_type
self.plot_field = plot_field
@@ -673,10 +675,18 @@
self.attr_name = attr_name
self.attr_args = attr_args
self.decimals = decimals
+ # callback_id is so that we don't have to hash the actual callbacks
+ # run, but instead we call them something
+ self.callback_id = callback_id
+ if callback_runners is None:
+ callback_runners = []
+ self.callback_runners = callback_runners
def run(self):
plot = self.create_plot(self.ds, self.plot_type, self.plot_field,
self.plot_axis, self.plot_kwargs)
+ for r in self.callback_runners:
+ r(self, plot)
attr = getattr(plot, self.attr_name)
attr(*self.attr_args[0], **self.attr_args[1])
tmpfd, tmpname = tempfile.mkstemp(suffix='.png')
diff -r c014ad925d83b6f1a7d2124cd941861a87e20d19 -r b7b8cdbad2505dea1391bddbe3ab6e5d65f2e9b6 yt/visualization/tests/test_plotwindow.py
--- a/yt/visualization/tests/test_plotwindow.py
+++ b/yt/visualization/tests/test_plotwindow.py
@@ -152,6 +152,28 @@
'mip'
)
+def simple_contour(test_obj, plot):
+ plot.annotate_contour(test_obj.plot_field)
+
+def simple_velocity(test_obj, plot):
+ plot.annotate_velocity()
+
+def simple_streamlines(test_obj, plot):
+ ax = test_obj.plot_axis
+ xax = test_obj.ds.coordinates.x_axis[ax]
+ yax = test_obj.ds.coordinates.y_axis[ax]
+ xn = test_obj.ds.coordinates.axis_name[xax]
+ yn = test_obj.ds.coordinates.axis_name[yax]
+ plot.annotate_streamlines("velocity_%s" % xn,
+ "velocity_%s" % yn)
+
+CALLBACK_TESTS = (
+ ("simple_contour", (simple_contour,)),
+ ("simple_velocity", (simple_velocity,)),
+ #("simple_streamlines", (simple_streamlines,)),
+ #("simple_all", (simple_contour, simple_velocity, simple_streamlines)),
+)
+
@requires_ds(M7)
def test_attributes():
"""Test plot member functions that aren't callbacks"""
@@ -166,6 +188,9 @@
args, decimals)
test_attributes.__name__ = test.description
yield test
+ for n, r in CALLBACK_TESTS:
+ yield PlotWindowAttributeTest(ds, plot_field, ax, attr_name,
+ args, decimals, callback_id=n, callback_runners=r)
@requires_ds(WT)
@@ -179,6 +204,9 @@
for args in ATTR_ARGS[attr_name]:
yield PlotWindowAttributeTest(ds, plot_field, ax, attr_name,
args, decimals)
+ for n, r in CALLBACK_TESTS:
+ yield PlotWindowAttributeTest(ds, plot_field, ax, attr_name,
+ args, decimals, callback_id=n, callback_runners=r)
class TestHideAxesColorbar(unittest.TestCase):
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