[yt-svn] commit/yt: 11 new changesets

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Mon Nov 30 11:18:15 PST 2015


11 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/4bfdc036bd64/
Changeset:   4bfdc036bd64
Branch:      yt
User:        atmyers
Date:        2015-11-23 22:12:45+00:00
Summary:     Adding particle plot answer tests
Affected #:  2 files

diff -r 5b5389c150b9d9ae33a8e36b03f6626f78b8da53 -r 4bfdc036bd6415ea2005903fe500721f514c589a yt/utilities/answer_testing/framework.py
--- a/yt/utilities/answer_testing/framework.py
+++ b/yt/utilities/answer_testing/framework.py
@@ -51,6 +51,7 @@
 
 import matplotlib.image as mpimg
 import yt.visualization.plot_window as pw
+import yt.visualization.particle_plots as pp
 
 mylog = logging.getLogger('nose.plugins.answer-testing')
 run_big_data = False
@@ -353,7 +354,9 @@
         # plot_kwargs should be a dict
         if plot_type is None:
             raise RuntimeError('Must explicitly request a plot type')
-        cls = getattr(pw, plot_type)
+        cls = getattr(pw, plot_type, None)
+        if cls is None:
+            cls = getattr(pp, plot_type)
         plot = cls(*(ds, plot_axis, plot_field), **plot_kwargs)
         return plot
 

diff -r 5b5389c150b9d9ae33a8e36b03f6626f78b8da53 -r 4bfdc036bd6415ea2005903fe500721f514c589a yt/visualization/tests/test_particle_plot.py
--- a/yt/visualization/tests/test_particle_plot.py
+++ b/yt/visualization/tests/test_particle_plot.py
@@ -20,9 +20,14 @@
 from yt.data_objects.profiles import create_profile
 from yt.extern.parameterized import parameterized, param
 from yt.visualization.tests.test_plotwindow import \
-    assert_fname, WIDTH_SPECS
+    assert_fname, WIDTH_SPECS, ATTR_ARGS
 from yt.testing import \
     fake_particle_ds, assert_array_almost_equal
+from yt.utilities.answer_testing.framework import \
+    requires_ds, \
+    data_dir_load, \
+    PlotWindowAttributeTest, \
+    GenericImageTest
 from yt.visualization.api import \
     ParticleProjectionPlot, ParticlePhasePlot
 from yt.units.yt_array import YTArray
@@ -33,6 +38,12 @@
     from yt.config import ytcfg
     ytcfg["yt", "__withintesting"] = "True"
 
+#  override some of the plotwindow ATTR_ARGS
+ATTR_ARGS["set_cmap"] = [(('particle_mass', 'RdBu'), {}), 
+                         (('particle_mass', 'kamae'), {})]
+ATTR_ARGS["set_log"] = [(('particle_mass', False), {})]
+ATTR_ARGS["set_zlim"] = [(('particle_mass', 1e-25, 1e-23), {}),
+                         (('particle_mass', 1e-25, None), {'dynamic_range': 4})]
 
 TEST_FLNMS = [None, 'test', 'test.png', 'test.eps',
               'test.ps', 'test.pdf']
@@ -59,6 +70,62 @@
                  ['particle_mass', 'particle_ones'])]
 
 
+g30 = "IsolatedGalaxy/galaxy0030/galaxy0030"
+
+ at requires_ds(g30, big_data=True)
+def test_particle_projection_answers():
+    '''
+
+    This iterates over the all the plot modification functions in ATTR_ARGS.
+    Each time, it compares the images produced by ParticleProjectionPlot to 
+    the gold standard.
+    
+
+    '''
+
+    plot_field = 'particle_mass'
+    decimals = 3
+    ds = data_dir_load(g30)
+    for ax in 'xyz':
+        for attr_name in ATTR_ARGS.keys():
+            for args in ATTR_ARGS[attr_name]:
+                test = PlotWindowAttributeTest(ds, plot_field, ax, 
+                                               attr_name,
+                                               args, decimals, 
+                                               'ParticleProjectionPlot')
+                test_particle_projection_answers.__name__ = test.description
+                yield test
+
+
+ at requires_ds(g30, big_data=True)
+def test_particle_phase_answers():
+    '''
+
+    This iterates over the all the field name combinations in PHASE_FIELDS.
+    Each time, it compares the images produced by ParticlePhasePlot to 
+    the gold standard.
+    
+
+    '''
+
+    decimals = 3
+    ds = data_dir_load(g30)
+
+    for x_field, y_field, z_fields in PHASE_FIELDS:
+        p = ParticlePhasePlot(ds.all_data(),
+                              x_field,
+                              y_field,
+                              z_fields,
+                              x_bins=16,
+                              y_bins=16)
+
+        def prof_image_func(filename_prefix):
+            p.write_png(filename_prefix)
+            
+        test = GenericImageTest(ds, prof_image_func, decimals)
+        test_particle_phase_answers.__name__ = test.description
+
+
 class TestParticlePhasePlotSave(unittest.TestCase):
 
     @classmethod


https://bitbucket.org/yt_analysis/yt/commits/71c4409638b9/
Changeset:   71c4409638b9
Branch:      yt
User:        atmyers
Date:        2015-11-23 22:33:45+00:00
Summary:     copy this dictionary instead of modifying it
Affected #:  1 file

diff -r 4bfdc036bd6415ea2005903fe500721f514c589a -r 71c4409638b92ac864df677657a74463ecde35ba yt/visualization/tests/test_particle_plot.py
--- a/yt/visualization/tests/test_particle_plot.py
+++ b/yt/visualization/tests/test_particle_plot.py
@@ -39,11 +39,13 @@
     ytcfg["yt", "__withintesting"] = "True"
 
 #  override some of the plotwindow ATTR_ARGS
-ATTR_ARGS["set_cmap"] = [(('particle_mass', 'RdBu'), {}), 
-                         (('particle_mass', 'kamae'), {})]
-ATTR_ARGS["set_log"] = [(('particle_mass', False), {})]
-ATTR_ARGS["set_zlim"] = [(('particle_mass', 1e-25, 1e-23), {}),
-                         (('particle_mass', 1e-25, None), {'dynamic_range': 4})]
+PARTICLE_ATTR_ARGS = ATTR_ARGS.copy() 
+PARTICLE_ATTR_ARGS["set_cmap"] = [(('particle_mass', 'RdBu'), {}), 
+                                  (('particle_mass', 'kamae'), {})]
+PARTICLE_ATTR_ARGS["set_log"] = [(('particle_mass', False), {})]
+PARTICLE_ATTR_ARGS["set_zlim"] = [(('particle_mass', 1e-25, 1e-23), {}),
+                                  (('particle_mass', 1e-25, None), 
+                                   {'dynamic_range': 4})]
 
 TEST_FLNMS = [None, 'test', 'test.png', 'test.eps',
               'test.ps', 'test.pdf']
@@ -76,9 +78,9 @@
 def test_particle_projection_answers():
     '''
 
-    This iterates over the all the plot modification functions in ATTR_ARGS.
-    Each time, it compares the images produced by ParticleProjectionPlot to 
-    the gold standard.
+    This iterates over the all the plot modification functions in 
+    PARTICLE_ATTR_ARGS. Each time, it compares the images produced by 
+    ParticleProjectionPlot to the gold standard.
     
 
     '''
@@ -87,8 +89,8 @@
     decimals = 3
     ds = data_dir_load(g30)
     for ax in 'xyz':
-        for attr_name in ATTR_ARGS.keys():
-            for args in ATTR_ARGS[attr_name]:
+        for attr_name in PARTICLE_ATTR_ARGS.keys():
+            for args in PARTICLE_ATTR_ARGS[attr_name]:
                 test = PlotWindowAttributeTest(ds, plot_field, ax, 
                                                attr_name,
                                                args, decimals, 


https://bitbucket.org/yt_analysis/yt/commits/adfb999de680/
Changeset:   adfb999de680
Branch:      yt
User:        atmyers
Date:        2015-11-25 19:55:01+00:00
Summary:     Add new class for answer testing phase plot modification functions
Affected #:  1 file

diff -r 71c4409638b92ac864df677657a74463ecde35ba -r adfb999de680545aeedaf1bce91d03605a1fc3d3 yt/utilities/answer_testing/framework.py
--- a/yt/utilities/answer_testing/framework.py
+++ b/yt/utilities/answer_testing/framework.py
@@ -52,6 +52,7 @@
 import matplotlib.image as mpimg
 import yt.visualization.plot_window as pw
 import yt.visualization.particle_plots as pp
+from yt.visualization.profile_plotter import PhasePlot
 
 mylog = logging.getLogger('nose.plugins.answer-testing')
 run_big_data = False
@@ -350,7 +351,6 @@
 
     def create_plot(self, ds, plot_type, plot_field, plot_axis, plot_kwargs = None):
         # plot_type should be a string
-        # plot_args should be a tuple
         # plot_kwargs should be a dict
         if plot_type is None:
             raise RuntimeError('Must explicitly request a plot type')
@@ -743,6 +743,37 @@
     def compare(self, new_result, old_result):
         compare_image_lists(new_result, old_result, self.decimals)
 
+class PhasePlotAttributeTest(AnswerTestingTest):
+    _type_name = "PhasePlotAttribute"
+    _attrs = ('plot_type', 'plot_field', 'attr_name', 'attr_args')
+    def __init__(self, ds_fn, x_field, y_field, z_field, 
+                 attr_name, attr_args, decimals, plot_type='PhasePlot'):
+        super(PhasePlotAttributeTest, self).__init__(ds_fn)
+        self.data_source = self.ds.all_data()
+        self.plot_type = plot_type
+        self.x_field = x_field
+        self.y_field = y_field
+        self.z_field = z_field
+        self.plot_kwargs = {}
+        self.attr_name = attr_name
+        self.attr_args = attr_args
+        self.decimals = decimals
+
+    def run(self):
+        plot = PhasePlot(*(self.data_source, self.x_field, self.y_field, 
+                           self.z_field), **self.plot_kwargs)
+        attr = getattr(plot, self.attr_name)
+        attr(*self.attr_args[0], **self.attr_args[1])
+        tmpfd, tmpname = tempfile.mkstemp(suffix='.png')
+        os.close(tmpfd)
+        plot.save(name=tmpname)
+        image = mpimg.imread(tmpname)
+        os.remove(tmpname)
+        return [zlib.compress(image.dumps())]
+
+    def compare(self, new_result, old_result):
+        compare_image_lists(new_result, old_result, self.decimals)
+
 class GenericArrayTest(AnswerTestingTest):
     _type_name = "GenericArray"
     _attrs = ('array_func_name','args','kwargs')


https://bitbucket.org/yt_analysis/yt/commits/03617b498bed/
Changeset:   03617b498bed
Branch:      yt
User:        atmyers
Date:        2015-11-25 20:26:45+00:00
Summary:     adding a class that answer tests the modification methods for phase plots
Affected #:  2 files

diff -r adfb999de680545aeedaf1bce91d03605a1fc3d3 -r 03617b498beddc57ec718f8e92a312507ea5af62 yt/utilities/answer_testing/framework.py
--- a/yt/utilities/answer_testing/framework.py
+++ b/yt/utilities/answer_testing/framework.py
@@ -745,7 +745,8 @@
 
 class PhasePlotAttributeTest(AnswerTestingTest):
     _type_name = "PhasePlotAttribute"
-    _attrs = ('plot_type', 'plot_field', 'attr_name', 'attr_args')
+    _attrs = ('plot_type', 'x_field', 'y_field', 'z_field',
+              'attr_name', 'attr_args')
     def __init__(self, ds_fn, x_field, y_field, z_field, 
                  attr_name, attr_args, decimals, plot_type='PhasePlot'):
         super(PhasePlotAttributeTest, self).__init__(ds_fn)

diff -r adfb999de680545aeedaf1bce91d03605a1fc3d3 -r 03617b498beddc57ec718f8e92a312507ea5af62 yt/visualization/tests/test_profile_plots.py
--- a/yt/visualization/tests/test_profile_plots.py
+++ b/yt/visualization/tests/test_profile_plots.py
@@ -26,6 +26,46 @@
     ProfilePlot, PhasePlot
 from yt.visualization.tests.test_plotwindow import \
     assert_fname, TEST_FLNMS
+from yt.utilities.answer_testing.framework import \
+    PhasePlotAttributeTest, \
+    requires_ds, \
+    data_dir_load
+
+ATTR_ARGS = {"annotate_text": [(((5e-29, 5e7), "Hello YT"), {}), 
+                               (((5e-29, 5e7), "Hello YT"), {'color':'b'})],
+             
+             "set_title": [(('cell_mass', 'A phase plot.'), {})],
+             "set_log": [(('cell_mass', False), {})],
+             "set_unit": [(('cell_mass', 'Msun'), {})],
+             "set_xlim": [((1e-27, 1e-24), {})],
+             "set_ylim": [((1e2, 1e6), {})]}
+
+
+g30 = "IsolatedGalaxy/galaxy0030/galaxy0030"
+
+ at requires_ds(g30, big_data=True)
+def test_profile_attributes():
+    '''
+
+    This iterates over the all the plot modification functions in 
+    ATTR_ARGS. Each time, it compares the images produced by 
+    PhasePlot to the gold standard.
+    
+
+    '''
+
+    x_field = 'density'
+    y_field = 'temperature'
+    z_field = 'cell_mass'
+    decimals = 3
+    ds = data_dir_load(g30)
+    for ax in 'xyz':
+        for attr_name in ATTR_ARGS.keys():
+            for args in ATTR_ARGS[attr_name]:
+                test = PhasePlotAttributeTest(ds, x_field, y_field, z_field, 
+                                               attr_name, args, decimals)
+                test_profile_attributes.__name__ = test.description
+                yield test
 
 class TestProfilePlotSave(unittest.TestCase):
 


https://bitbucket.org/yt_analysis/yt/commits/532b25617aef/
Changeset:   532b25617aef
Branch:      yt
User:        atmyers
Date:        2015-11-25 20:27:35+00:00
Summary:     renaming
Affected #:  1 file

diff -r 03617b498beddc57ec718f8e92a312507ea5af62 -r 532b25617aef2681a57e988b6a4b998efd8623b9 yt/visualization/tests/test_profile_plots.py
--- a/yt/visualization/tests/test_profile_plots.py
+++ b/yt/visualization/tests/test_profile_plots.py
@@ -44,7 +44,7 @@
 g30 = "IsolatedGalaxy/galaxy0030/galaxy0030"
 
 @requires_ds(g30, big_data=True)
-def test_profile_attributes():
+def test_phase_plot_attributes():
     '''
 
     This iterates over the all the plot modification functions in 
@@ -64,7 +64,7 @@
             for args in ATTR_ARGS[attr_name]:
                 test = PhasePlotAttributeTest(ds, x_field, y_field, z_field, 
                                                attr_name, args, decimals)
-                test_profile_attributes.__name__ = test.description
+                test_phase_plot_attributes.__name__ = test.description
                 yield test
 
 class TestProfilePlotSave(unittest.TestCase):


https://bitbucket.org/yt_analysis/yt/commits/64315d133c41/
Changeset:   64315d133c41
Branch:      yt
User:        atmyers
Date:        2015-11-25 20:28:51+00:00
Summary:     another renaming
Affected #:  1 file

diff -r 532b25617aef2681a57e988b6a4b998efd8623b9 -r 64315d133c41ef03d720065b5b928862bdae31c3 yt/visualization/tests/test_particle_plot.py
--- a/yt/visualization/tests/test_particle_plot.py
+++ b/yt/visualization/tests/test_particle_plot.py
@@ -39,11 +39,11 @@
     ytcfg["yt", "__withintesting"] = "True"
 
 #  override some of the plotwindow ATTR_ARGS
-PARTICLE_ATTR_ARGS = ATTR_ARGS.copy() 
-PARTICLE_ATTR_ARGS["set_cmap"] = [(('particle_mass', 'RdBu'), {}), 
+PROJ_ATTR_ARGS = ATTR_ARGS.copy() 
+PROJ_ATTR_ARGS["set_cmap"] = [(('particle_mass', 'RdBu'), {}), 
                                   (('particle_mass', 'kamae'), {})]
-PARTICLE_ATTR_ARGS["set_log"] = [(('particle_mass', False), {})]
-PARTICLE_ATTR_ARGS["set_zlim"] = [(('particle_mass', 1e-25, 1e-23), {}),
+PROJ_ATTR_ARGS["set_log"] = [(('particle_mass', False), {})]
+PROJ_ATTR_ARGS["set_zlim"] = [(('particle_mass', 1e-25, 1e-23), {}),
                                   (('particle_mass', 1e-25, None), 
                                    {'dynamic_range': 4})]
 
@@ -79,7 +79,7 @@
     '''
 
     This iterates over the all the plot modification functions in 
-    PARTICLE_ATTR_ARGS. Each time, it compares the images produced by 
+    PROJ_ATTR_ARGS. Each time, it compares the images produced by 
     ParticleProjectionPlot to the gold standard.
     
 
@@ -89,8 +89,8 @@
     decimals = 3
     ds = data_dir_load(g30)
     for ax in 'xyz':
-        for attr_name in PARTICLE_ATTR_ARGS.keys():
-            for args in PARTICLE_ATTR_ARGS[attr_name]:
+        for attr_name in PROJ_ATTR_ARGS.keys():
+            for args in PROJ_ATTR_ARGS[attr_name]:
                 test = PlotWindowAttributeTest(ds, plot_field, ax, 
                                                attr_name,
                                                args, decimals, 


https://bitbucket.org/yt_analysis/yt/commits/2ea3e53100a2/
Changeset:   2ea3e53100a2
Branch:      yt
User:        atmyers
Date:        2015-11-25 21:03:15+00:00
Summary:     answer testing modifications for particle plots as well
Affected #:  2 files

diff -r 64315d133c41ef03d720065b5b928862bdae31c3 -r 2ea3e53100a2441271c4892fd904dc97084c78f0 yt/utilities/answer_testing/framework.py
--- a/yt/utilities/answer_testing/framework.py
+++ b/yt/utilities/answer_testing/framework.py
@@ -51,8 +51,8 @@
 
 import matplotlib.image as mpimg
 import yt.visualization.plot_window as pw
-import yt.visualization.particle_plots as pp
-from yt.visualization.profile_plotter import PhasePlot
+import yt.visualization.particle_plots as particle_plots
+import yt.visualization.profile_plotter as profile_plotter
 
 mylog = logging.getLogger('nose.plugins.answer-testing')
 run_big_data = False
@@ -356,7 +356,7 @@
             raise RuntimeError('Must explicitly request a plot type')
         cls = getattr(pw, plot_type, None)
         if cls is None:
-            cls = getattr(pp, plot_type)
+            cls = getattr(particle_plots, plot_type)
         plot = cls(*(ds, plot_axis, plot_field), **plot_kwargs)
         return plot
 
@@ -760,9 +760,21 @@
         self.attr_args = attr_args
         self.decimals = decimals
 
+    def create_plot(self, data_source, x_field, y_field, z_field, 
+                    plot_type, plot_kwargs=None):
+        # plot_type should be a string
+        # plot_kwargs should be a dict
+        if plot_type is None:
+            raise RuntimeError('Must explicitly request a plot type')
+        cls = getattr(profile_plotter, plot_type, None)
+        if cls is None:
+            cls = getattr(particle_plots, plot_type)
+        plot = cls(*(data_source, x_field, y_field, z_field), **plot_kwargs)
+        return plot
+
     def run(self):
-        plot = PhasePlot(*(self.data_source, self.x_field, self.y_field, 
-                           self.z_field), **self.plot_kwargs)
+        plot = self.create_plot(self.data_source, self.x_field, self.y_field,
+                                self.z_field, self.plot_type, self.plot_kwargs)
         attr = getattr(plot, self.attr_name)
         attr(*self.attr_args[0], **self.attr_args[1])
         tmpfd, tmpname = tempfile.mkstemp(suffix='.png')

diff -r 64315d133c41ef03d720065b5b928862bdae31c3 -r 2ea3e53100a2441271c4892fd904dc97084c78f0 yt/visualization/tests/test_particle_plot.py
--- a/yt/visualization/tests/test_particle_plot.py
+++ b/yt/visualization/tests/test_particle_plot.py
@@ -27,7 +27,7 @@
     requires_ds, \
     data_dir_load, \
     PlotWindowAttributeTest, \
-    GenericImageTest
+    PhasePlotAttributeTest
 from yt.visualization.api import \
     ParticleProjectionPlot, ParticlePhasePlot
 from yt.units.yt_array import YTArray
@@ -47,6 +47,14 @@
                                   (('particle_mass', 1e-25, None), 
                                    {'dynamic_range': 4})]
 
+PHASE_ATTR_ARGS = {"annotate_text": [(((5e-29, 5e7), "Hello YT"), {}), 
+                               (((5e-29, 5e7), "Hello YT"), {'color':'b'})],
+                   "set_title": [(('particle_mass', 'A phase plot.'), {})],
+                   "set_log": [(('particle_mass', False), {})],
+                   "set_unit": [(('particle_mass', 'Msun'), {})],
+                   "set_xlim": [((-4e7, 4e7), {})],
+                   "set_ylim": [((-4e7, 4e7), {})]}
+
 TEST_FLNMS = [None, 'test', 'test.png', 'test.eps',
               'test.ps', 'test.pdf']
 
@@ -113,20 +121,16 @@
     decimals = 3
     ds = data_dir_load(g30)
 
-    for x_field, y_field, z_fields in PHASE_FIELDS:
-        p = ParticlePhasePlot(ds.all_data(),
-                              x_field,
-                              y_field,
-                              z_fields,
-                              x_bins=16,
-                              y_bins=16)
-
-        def prof_image_func(filename_prefix):
-            p.write_png(filename_prefix)
-            
-        test = GenericImageTest(ds, prof_image_func, decimals)
-        test_particle_phase_answers.__name__ = test.description
-
+    x_field = 'particle_velocity_x'
+    y_field = 'particle_velocity_y'
+    z_field = 'particle_mass'
+    for attr_name in PHASE_ATTR_ARGS.keys():
+        for args in PHASE_ATTR_ARGS[attr_name]:
+            test = PhasePlotAttributeTest(ds, x_field, y_field, z_field,
+                                          attr_name, args, decimals)
+                
+            test_particle_phase_answers.__name__ = test.description
+            yield test
 
 class TestParticlePhasePlotSave(unittest.TestCase):
 


https://bitbucket.org/yt_analysis/yt/commits/3e0ac94cf623/
Changeset:   3e0ac94cf623
Branch:      yt
User:        atmyers
Date:        2015-11-25 21:32:40+00:00
Summary:     updating docstring
Affected #:  1 file

diff -r 2ea3e53100a2441271c4892fd904dc97084c78f0 -r 3e0ac94cf623707ef340ba57bbf38b447b999034 yt/visualization/tests/test_particle_plot.py
--- a/yt/visualization/tests/test_particle_plot.py
+++ b/yt/visualization/tests/test_particle_plot.py
@@ -111,10 +111,9 @@
 def test_particle_phase_answers():
     '''
 
-    This iterates over the all the field name combinations in PHASE_FIELDS.
-    Each time, it compares the images produced by ParticlePhasePlot to 
-    the gold standard.
-    
+    This iterates over the all the plot modification functions in 
+    PHASE_ATTR_ARGS. Each time, it compares the images produced by 
+    ParticlePhasePlot to the gold standard.
 
     '''
 


https://bitbucket.org/yt_analysis/yt/commits/f5dd5d9f54ba/
Changeset:   f5dd5d9f54ba
Branch:      yt
User:        atmyers
Date:        2015-11-25 21:59:19+00:00
Summary:     make sure we test these as ParticlePhasePlot
Affected #:  1 file

diff -r 3e0ac94cf623707ef340ba57bbf38b447b999034 -r f5dd5d9f54ba56f5741aa3dc5b04414967979220 yt/visualization/tests/test_particle_plot.py
--- a/yt/visualization/tests/test_particle_plot.py
+++ b/yt/visualization/tests/test_particle_plot.py
@@ -126,7 +126,8 @@
     for attr_name in PHASE_ATTR_ARGS.keys():
         for args in PHASE_ATTR_ARGS[attr_name]:
             test = PhasePlotAttributeTest(ds, x_field, y_field, z_field,
-                                          attr_name, args, decimals)
+                                          attr_name, args, decimals,
+                                          'ParticlePhasePlot')
                 
             test_particle_phase_answers.__name__ = test.description
             yield test


https://bitbucket.org/yt_analysis/yt/commits/fffbb3062e32/
Changeset:   fffbb3062e32
Branch:      yt
User:        atmyers
Date:        2015-11-25 22:32:19+00:00
Summary:     changing the precision of the image comparison tests to something tighter
Affected #:  5 files

diff -r f5dd5d9f54ba56f5741aa3dc5b04414967979220 -r fffbb3062e325faa7822cb0eac0da5432dda6a6c yt/analysis_modules/sunyaev_zeldovich/tests/test_projection.py
--- a/yt/analysis_modules/sunyaev_zeldovich/tests/test_projection.py
+++ b/yt/analysis_modules/sunyaev_zeldovich/tests/test_projection.py
@@ -127,7 +127,7 @@
     def onaxis_image_func(filename_prefix):
         szprj.write_png(filename_prefix)
     for test in [GenericArrayTest(ds, onaxis_array_func),
-                 GenericImageTest(ds, onaxis_image_func, 3)]:
+                 GenericImageTest(ds, onaxis_image_func, 12)]:
         test_M7_onaxis.__name__ = test.description
         yield test
 
@@ -142,6 +142,6 @@
     def offaxis_image_func(filename_prefix):
         szprj.write_png(filename_prefix)
     for test in [GenericArrayTest(ds, offaxis_array_func),
-                 GenericImageTest(ds, offaxis_image_func, 3)]:
+                 GenericImageTest(ds, offaxis_image_func, 12)]:
         test_M7_offaxis.__name__ = test.description
         yield test

diff -r f5dd5d9f54ba56f5741aa3dc5b04414967979220 -r fffbb3062e325faa7822cb0eac0da5432dda6a6c yt/visualization/tests/test_particle_plot.py
--- a/yt/visualization/tests/test_particle_plot.py
+++ b/yt/visualization/tests/test_particle_plot.py
@@ -94,7 +94,7 @@
     '''
 
     plot_field = 'particle_mass'
-    decimals = 3
+    decimals = 12
     ds = data_dir_load(g30)
     for ax in 'xyz':
         for attr_name in PROJ_ATTR_ARGS.keys():
@@ -117,7 +117,7 @@
 
     '''
 
-    decimals = 3
+    decimals = 12
     ds = data_dir_load(g30)
 
     x_field = 'particle_velocity_x'

diff -r f5dd5d9f54ba56f5741aa3dc5b04414967979220 -r fffbb3062e325faa7822cb0eac0da5432dda6a6c yt/visualization/tests/test_plotwindow.py
--- a/yt/visualization/tests/test_plotwindow.py
+++ b/yt/visualization/tests/test_plotwindow.py
@@ -182,7 +182,7 @@
 def test_attributes():
     """Test plot member functions that aren't callbacks"""
     plot_field = 'density'
-    decimals = 3
+    decimals = 12
 
     ds = data_dir_load(M7)
     for ax in 'xyz':
@@ -200,7 +200,7 @@
 @requires_ds(WT)
 def test_attributes_wt():
     plot_field = 'density'
-    decimals = 3
+    decimals = 12
 
     ds = data_dir_load(WT)
     ax = 'z'

diff -r f5dd5d9f54ba56f5741aa3dc5b04414967979220 -r fffbb3062e325faa7822cb0eac0da5432dda6a6c yt/visualization/tests/test_profile_plots.py
--- a/yt/visualization/tests/test_profile_plots.py
+++ b/yt/visualization/tests/test_profile_plots.py
@@ -57,7 +57,7 @@
     x_field = 'density'
     y_field = 'temperature'
     z_field = 'cell_mass'
-    decimals = 3
+    decimals = 12
     ds = data_dir_load(g30)
     for ax in 'xyz':
         for attr_name in ATTR_ARGS.keys():

diff -r f5dd5d9f54ba56f5741aa3dc5b04414967979220 -r fffbb3062e325faa7822cb0eac0da5432dda6a6c yt/visualization/volume_rendering/tests/test_vr_orientation.py
--- a/yt/visualization/volume_rendering/tests/test_vr_orientation.py
+++ b/yt/visualization/volume_rendering/tests/test_vr_orientation.py
@@ -107,7 +107,7 @@
 
     n_frames = 5
     theta = np.pi / n_frames
-    decimals = 3
+    decimals = 12
 
     for lens_type in ['plane-parallel', 'perspective']:
         frame = 0


https://bitbucket.org/yt_analysis/yt/commits/5cbfdce0652c/
Changeset:   5cbfdce0652c
Branch:      yt
User:        jzuhone
Date:        2015-11-30 19:17:56+00:00
Summary:     Merged in atmyers/yt (pull request #1883)

Better plot tests
Affected #:  6 files

diff -r 66152c77e32c81c8bce0506a67f9a192302f8623 -r 5cbfdce0652c5ec40b6d52404f03895b2f901ae6 yt/analysis_modules/sunyaev_zeldovich/tests/test_projection.py
--- a/yt/analysis_modules/sunyaev_zeldovich/tests/test_projection.py
+++ b/yt/analysis_modules/sunyaev_zeldovich/tests/test_projection.py
@@ -127,7 +127,7 @@
     def onaxis_image_func(filename_prefix):
         szprj.write_png(filename_prefix)
     for test in [GenericArrayTest(ds, onaxis_array_func),
-                 GenericImageTest(ds, onaxis_image_func, 3)]:
+                 GenericImageTest(ds, onaxis_image_func, 12)]:
         test_M7_onaxis.__name__ = test.description
         yield test
 
@@ -142,6 +142,6 @@
     def offaxis_image_func(filename_prefix):
         szprj.write_png(filename_prefix)
     for test in [GenericArrayTest(ds, offaxis_array_func),
-                 GenericImageTest(ds, offaxis_image_func, 3)]:
+                 GenericImageTest(ds, offaxis_image_func, 12)]:
         test_M7_offaxis.__name__ = test.description
         yield test

diff -r 66152c77e32c81c8bce0506a67f9a192302f8623 -r 5cbfdce0652c5ec40b6d52404f03895b2f901ae6 yt/utilities/answer_testing/framework.py
--- a/yt/utilities/answer_testing/framework.py
+++ b/yt/utilities/answer_testing/framework.py
@@ -51,6 +51,8 @@
 
 import matplotlib.image as mpimg
 import yt.visualization.plot_window as pw
+import yt.visualization.particle_plots as particle_plots
+import yt.visualization.profile_plotter as profile_plotter
 
 mylog = logging.getLogger('nose.plugins.answer-testing')
 run_big_data = False
@@ -349,11 +351,12 @@
 
     def create_plot(self, ds, plot_type, plot_field, plot_axis, plot_kwargs = None):
         # plot_type should be a string
-        # plot_args should be a tuple
         # plot_kwargs should be a dict
         if plot_type is None:
             raise RuntimeError('Must explicitly request a plot type')
-        cls = getattr(pw, plot_type)
+        cls = getattr(pw, plot_type, None)
+        if cls is None:
+            cls = getattr(particle_plots, plot_type)
         plot = cls(*(ds, plot_axis, plot_field), **plot_kwargs)
         return plot
 
@@ -740,6 +743,50 @@
     def compare(self, new_result, old_result):
         compare_image_lists(new_result, old_result, self.decimals)
 
+class PhasePlotAttributeTest(AnswerTestingTest):
+    _type_name = "PhasePlotAttribute"
+    _attrs = ('plot_type', 'x_field', 'y_field', 'z_field',
+              'attr_name', 'attr_args')
+    def __init__(self, ds_fn, x_field, y_field, z_field, 
+                 attr_name, attr_args, decimals, plot_type='PhasePlot'):
+        super(PhasePlotAttributeTest, self).__init__(ds_fn)
+        self.data_source = self.ds.all_data()
+        self.plot_type = plot_type
+        self.x_field = x_field
+        self.y_field = y_field
+        self.z_field = z_field
+        self.plot_kwargs = {}
+        self.attr_name = attr_name
+        self.attr_args = attr_args
+        self.decimals = decimals
+
+    def create_plot(self, data_source, x_field, y_field, z_field, 
+                    plot_type, plot_kwargs=None):
+        # plot_type should be a string
+        # plot_kwargs should be a dict
+        if plot_type is None:
+            raise RuntimeError('Must explicitly request a plot type')
+        cls = getattr(profile_plotter, plot_type, None)
+        if cls is None:
+            cls = getattr(particle_plots, plot_type)
+        plot = cls(*(data_source, x_field, y_field, z_field), **plot_kwargs)
+        return plot
+
+    def run(self):
+        plot = self.create_plot(self.data_source, self.x_field, self.y_field,
+                                self.z_field, self.plot_type, self.plot_kwargs)
+        attr = getattr(plot, self.attr_name)
+        attr(*self.attr_args[0], **self.attr_args[1])
+        tmpfd, tmpname = tempfile.mkstemp(suffix='.png')
+        os.close(tmpfd)
+        plot.save(name=tmpname)
+        image = mpimg.imread(tmpname)
+        os.remove(tmpname)
+        return [zlib.compress(image.dumps())]
+
+    def compare(self, new_result, old_result):
+        compare_image_lists(new_result, old_result, self.decimals)
+
 class GenericArrayTest(AnswerTestingTest):
     _type_name = "GenericArray"
     _attrs = ('array_func_name','args','kwargs')

diff -r 66152c77e32c81c8bce0506a67f9a192302f8623 -r 5cbfdce0652c5ec40b6d52404f03895b2f901ae6 yt/visualization/tests/test_particle_plot.py
--- a/yt/visualization/tests/test_particle_plot.py
+++ b/yt/visualization/tests/test_particle_plot.py
@@ -20,9 +20,14 @@
 from yt.data_objects.profiles import create_profile
 from yt.extern.parameterized import parameterized, param
 from yt.visualization.tests.test_plotwindow import \
-    assert_fname, WIDTH_SPECS
+    assert_fname, WIDTH_SPECS, ATTR_ARGS
 from yt.testing import \
     fake_particle_ds, assert_array_almost_equal
+from yt.utilities.answer_testing.framework import \
+    requires_ds, \
+    data_dir_load, \
+    PlotWindowAttributeTest, \
+    PhasePlotAttributeTest
 from yt.visualization.api import \
     ParticleProjectionPlot, ParticlePhasePlot
 from yt.units.yt_array import YTArray
@@ -33,6 +38,22 @@
     from yt.config import ytcfg
     ytcfg["yt", "__withintesting"] = "True"
 
+#  override some of the plotwindow ATTR_ARGS
+PROJ_ATTR_ARGS = ATTR_ARGS.copy() 
+PROJ_ATTR_ARGS["set_cmap"] = [(('particle_mass', 'RdBu'), {}), 
+                                  (('particle_mass', 'kamae'), {})]
+PROJ_ATTR_ARGS["set_log"] = [(('particle_mass', False), {})]
+PROJ_ATTR_ARGS["set_zlim"] = [(('particle_mass', 1e-25, 1e-23), {}),
+                                  (('particle_mass', 1e-25, None), 
+                                   {'dynamic_range': 4})]
+
+PHASE_ATTR_ARGS = {"annotate_text": [(((5e-29, 5e7), "Hello YT"), {}), 
+                               (((5e-29, 5e7), "Hello YT"), {'color':'b'})],
+                   "set_title": [(('particle_mass', 'A phase plot.'), {})],
+                   "set_log": [(('particle_mass', False), {})],
+                   "set_unit": [(('particle_mass', 'Msun'), {})],
+                   "set_xlim": [((-4e7, 4e7), {})],
+                   "set_ylim": [((-4e7, 4e7), {})]}
 
 TEST_FLNMS = [None, 'test', 'test.png', 'test.eps',
               'test.ps', 'test.pdf']
@@ -59,6 +80,58 @@
                  ['particle_mass', 'particle_ones'])]
 
 
+g30 = "IsolatedGalaxy/galaxy0030/galaxy0030"
+
+ at requires_ds(g30, big_data=True)
+def test_particle_projection_answers():
+    '''
+
+    This iterates over the all the plot modification functions in 
+    PROJ_ATTR_ARGS. Each time, it compares the images produced by 
+    ParticleProjectionPlot to the gold standard.
+    
+
+    '''
+
+    plot_field = 'particle_mass'
+    decimals = 12
+    ds = data_dir_load(g30)
+    for ax in 'xyz':
+        for attr_name in PROJ_ATTR_ARGS.keys():
+            for args in PROJ_ATTR_ARGS[attr_name]:
+                test = PlotWindowAttributeTest(ds, plot_field, ax, 
+                                               attr_name,
+                                               args, decimals, 
+                                               'ParticleProjectionPlot')
+                test_particle_projection_answers.__name__ = test.description
+                yield test
+
+
+ at requires_ds(g30, big_data=True)
+def test_particle_phase_answers():
+    '''
+
+    This iterates over the all the plot modification functions in 
+    PHASE_ATTR_ARGS. Each time, it compares the images produced by 
+    ParticlePhasePlot to the gold standard.
+
+    '''
+
+    decimals = 12
+    ds = data_dir_load(g30)
+
+    x_field = 'particle_velocity_x'
+    y_field = 'particle_velocity_y'
+    z_field = 'particle_mass'
+    for attr_name in PHASE_ATTR_ARGS.keys():
+        for args in PHASE_ATTR_ARGS[attr_name]:
+            test = PhasePlotAttributeTest(ds, x_field, y_field, z_field,
+                                          attr_name, args, decimals,
+                                          'ParticlePhasePlot')
+                
+            test_particle_phase_answers.__name__ = test.description
+            yield test
+
 class TestParticlePhasePlotSave(unittest.TestCase):
 
     @classmethod

diff -r 66152c77e32c81c8bce0506a67f9a192302f8623 -r 5cbfdce0652c5ec40b6d52404f03895b2f901ae6 yt/visualization/tests/test_plotwindow.py
--- a/yt/visualization/tests/test_plotwindow.py
+++ b/yt/visualization/tests/test_plotwindow.py
@@ -182,7 +182,7 @@
 def test_attributes():
     """Test plot member functions that aren't callbacks"""
     plot_field = 'density'
-    decimals = 3
+    decimals = 12
 
     ds = data_dir_load(M7)
     for ax in 'xyz':
@@ -200,7 +200,7 @@
 @requires_ds(WT)
 def test_attributes_wt():
     plot_field = 'density'
-    decimals = 3
+    decimals = 12
 
     ds = data_dir_load(WT)
     ax = 'z'

diff -r 66152c77e32c81c8bce0506a67f9a192302f8623 -r 5cbfdce0652c5ec40b6d52404f03895b2f901ae6 yt/visualization/tests/test_profile_plots.py
--- a/yt/visualization/tests/test_profile_plots.py
+++ b/yt/visualization/tests/test_profile_plots.py
@@ -26,6 +26,46 @@
     ProfilePlot, PhasePlot
 from yt.visualization.tests.test_plotwindow import \
     assert_fname, TEST_FLNMS
+from yt.utilities.answer_testing.framework import \
+    PhasePlotAttributeTest, \
+    requires_ds, \
+    data_dir_load
+
+ATTR_ARGS = {"annotate_text": [(((5e-29, 5e7), "Hello YT"), {}), 
+                               (((5e-29, 5e7), "Hello YT"), {'color':'b'})],
+             
+             "set_title": [(('cell_mass', 'A phase plot.'), {})],
+             "set_log": [(('cell_mass', False), {})],
+             "set_unit": [(('cell_mass', 'Msun'), {})],
+             "set_xlim": [((1e-27, 1e-24), {})],
+             "set_ylim": [((1e2, 1e6), {})]}
+
+
+g30 = "IsolatedGalaxy/galaxy0030/galaxy0030"
+
+ at requires_ds(g30, big_data=True)
+def test_phase_plot_attributes():
+    '''
+
+    This iterates over the all the plot modification functions in 
+    ATTR_ARGS. Each time, it compares the images produced by 
+    PhasePlot to the gold standard.
+    
+
+    '''
+
+    x_field = 'density'
+    y_field = 'temperature'
+    z_field = 'cell_mass'
+    decimals = 12
+    ds = data_dir_load(g30)
+    for ax in 'xyz':
+        for attr_name in ATTR_ARGS.keys():
+            for args in ATTR_ARGS[attr_name]:
+                test = PhasePlotAttributeTest(ds, x_field, y_field, z_field, 
+                                               attr_name, args, decimals)
+                test_phase_plot_attributes.__name__ = test.description
+                yield test
 
 class TestProfilePlotSave(unittest.TestCase):
 

diff -r 66152c77e32c81c8bce0506a67f9a192302f8623 -r 5cbfdce0652c5ec40b6d52404f03895b2f901ae6 yt/visualization/volume_rendering/tests/test_vr_orientation.py
--- a/yt/visualization/volume_rendering/tests/test_vr_orientation.py
+++ b/yt/visualization/volume_rendering/tests/test_vr_orientation.py
@@ -107,7 +107,7 @@
 
     n_frames = 5
     theta = np.pi / n_frames
-    decimals = 3
+    decimals = 12
 
     for lens_type in ['plane-parallel', 'perspective']:
         frame = 0

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