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

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Mon Nov 30 11:31:46 PST 2015


6 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/f213ceee6357/
Changeset:   f213ceee6357
Branch:      yt
User:        dorislee0309
Date:        2015-11-26 03:52:19+00:00
Summary:     fixed casting error for float and int64 multiplication in sdf class
Affected #:  1 file

diff -r 03a54b627189e63eaee9f2bc1d4a36c3ab6b9637 -r f213ceee6357b0aa20b95a8da95ff240a4d15291 yt/frontends/sdf/data_structures.py
--- a/yt/frontends/sdf/data_structures.py
+++ b/yt/frontends/sdf/data_structures.py
@@ -15,10 +15,15 @@
 #-----------------------------------------------------------------------------
 
 
+import h5py
 import numpy as np
 import stat
+import weakref
+import struct
+import glob
 import time
 import os
+import types
 import sys
 import contextlib
 
@@ -27,8 +32,14 @@
     ParticleIndex
 from yt.data_objects.static_output import \
     Dataset, ParticleFile
+from yt.utilities.physical_ratios import \
+    cm_per_kpc, \
+    mass_sun_grams, \
+    sec_per_Gyr
 from .fields import \
     SDFFieldInfo
+from .io import \
+    IOHandlerSDF
 from yt.utilities.sdf import \
     SDFRead,\
     SDFIndex,\
@@ -105,8 +116,10 @@
 
     def _parse_parameter_file(self):
         if self.parameter_filename.startswith("http"):
+	    print "HTTPSDFREAD"
             sdf_class = HTTPSDFRead
         else:
+	    print "SDFREAD"
             sdf_class = SDFRead
         self.sdf_container = sdf_class(self.parameter_filename,
                                  header=self.sdf_header)
@@ -133,8 +146,8 @@
                     -self.parameters.get("R%s" % ax, R0) for ax in 'xyz'])
                 self.domain_right_edge = np.array([
                     +self.parameters.get("R%s" % ax, R0) for ax in 'xyz'])
-            self.domain_left_edge *= self.parameters.get("a", 1.0)
-            self.domain_right_edge *= self.parameters.get("a", 1.0)
+            self.domain_left_edge *= int(self.parameters.get("a", 1.0))
+            self.domain_right_edge *= int(self.parameters.get("a", 1.0))
 
         nz = 1 << self.over_refine_factor
         self.domain_dimensions = np.ones(3, "int32") * nz


https://bitbucket.org/yt_analysis/yt/commits/a812c8e6bbaf/
Changeset:   a812c8e6bbaf
Branch:      yt
User:        dorislee0309
Date:        2015-11-26 03:58:44+00:00
Summary:     fixed casting error for float and int64 multiplication in sdf class
Affected #:  1 file

diff -r f213ceee6357b0aa20b95a8da95ff240a4d15291 -r a812c8e6bbaf9586b5385571f40029bffd119b29 yt/frontends/sdf/data_structures.py
--- a/yt/frontends/sdf/data_structures.py
+++ b/yt/frontends/sdf/data_structures.py
@@ -116,10 +116,8 @@
 
     def _parse_parameter_file(self):
         if self.parameter_filename.startswith("http"):
-	    print "HTTPSDFREAD"
             sdf_class = HTTPSDFRead
         else:
-	    print "SDFREAD"
             sdf_class = SDFRead
         self.sdf_container = sdf_class(self.parameter_filename,
                                  header=self.sdf_header)


https://bitbucket.org/yt_analysis/yt/commits/2e3a9b236d04/
Changeset:   2e3a9b236d04
Branch:      yt
User:        dorislee0309
Date:        2015-11-26 04:07:56+00:00
Summary:     deleting unnecessary imports
Affected #:  1 file

diff -r a812c8e6bbaf9586b5385571f40029bffd119b29 -r 2e3a9b236d04586c076e137a576ba27696b11057 yt/frontends/sdf/data_structures.py
--- a/yt/frontends/sdf/data_structures.py
+++ b/yt/frontends/sdf/data_structures.py
@@ -15,15 +15,10 @@
 #-----------------------------------------------------------------------------
 
 
-import h5py
 import numpy as np
 import stat
-import weakref
-import struct
-import glob
 import time
 import os
-import types
 import sys
 import contextlib
 
@@ -32,14 +27,8 @@
     ParticleIndex
 from yt.data_objects.static_output import \
     Dataset, ParticleFile
-from yt.utilities.physical_ratios import \
-    cm_per_kpc, \
-    mass_sun_grams, \
-    sec_per_Gyr
 from .fields import \
     SDFFieldInfo
-from .io import \
-    IOHandlerSDF
 from yt.utilities.sdf import \
     SDFRead,\
     SDFIndex,\


https://bitbucket.org/yt_analysis/yt/commits/e26493b973e7/
Changeset:   e26493b973e7
Branch:      yt
User:        dorislee0309
Date:        2015-11-26 05:54:05+00:00
Summary:     defining dtype for domain_left_edge and domain_right_edge array
Affected #:  1 file

diff -r 2e3a9b236d04586c076e137a576ba27696b11057 -r e26493b973e770fc07f6951659e62668bd2b595b yt/frontends/sdf/data_structures.py
--- a/yt/frontends/sdf/data_structures.py
+++ b/yt/frontends/sdf/data_structures.py
@@ -125,17 +125,16 @@
         if None in (self.domain_left_edge, self.domain_right_edge):
             R0 = self.parameters['R0']
             if 'offset_center' in self.parameters and self.parameters['offset_center']:
-                self.domain_left_edge = np.array([0, 0, 0])
+                self.domain_left_edge = np.array([0, 0, 0],dtype=np.float64)
                 self.domain_right_edge = np.array([
-                 2.0 * self.parameters.get("R%s" % ax, R0) for ax in 'xyz'])
+                 2.0 * self.parameters.get("R%s" % ax, R0) for ax in 'xyz'],dtype=np.float64)
             else:
                 self.domain_left_edge = np.array([
-                    -self.parameters.get("R%s" % ax, R0) for ax in 'xyz'])
+                    -self.parameters.get("R%s" % ax, R0) for ax in 'xyz'],dtype=np.float64)
                 self.domain_right_edge = np.array([
-                    +self.parameters.get("R%s" % ax, R0) for ax in 'xyz'])
-            self.domain_left_edge *= int(self.parameters.get("a", 1.0))
-            self.domain_right_edge *= int(self.parameters.get("a", 1.0))
-
+                    +self.parameters.get("R%s" % ax, R0) for ax in 'xyz'],dtype=np.float64)
+	    self.domain_left_edge *= self.parameters.get("a", 1.0)
+	    self.domain_right_edge *= self.parameters.get("a", 1.0)
         nz = 1 << self.over_refine_factor
         self.domain_dimensions = np.ones(3, "int32") * nz
         if "do_periodic" in self.parameters and self.parameters["do_periodic"]:


https://bitbucket.org/yt_analysis/yt/commits/402bc55e4de8/
Changeset:   402bc55e4de8
Branch:      yt
User:        ngoldbaum
Date:        2015-11-30 19:29:54+00:00
Summary:     Fixing tab/spaces issues, breaking up long lines
Affected #:  1 file

diff -r e26493b973e770fc07f6951659e62668bd2b595b -r 402bc55e4de8acb23a61083886d08c762ca53f94 yt/frontends/sdf/data_structures.py
--- a/yt/frontends/sdf/data_structures.py
+++ b/yt/frontends/sdf/data_structures.py
@@ -125,16 +125,19 @@
         if None in (self.domain_left_edge, self.domain_right_edge):
             R0 = self.parameters['R0']
             if 'offset_center' in self.parameters and self.parameters['offset_center']:
-                self.domain_left_edge = np.array([0, 0, 0],dtype=np.float64)
+                self.domain_left_edge = np.array([0, 0, 0], dtype=np.float64)
                 self.domain_right_edge = np.array([
-                 2.0 * self.parameters.get("R%s" % ax, R0) for ax in 'xyz'],dtype=np.float64)
+                    2.0 * self.parameters.get("R%s" % ax, R0) for ax in 'xyz'],
+                    dtype=np.float64)
             else:
                 self.domain_left_edge = np.array([
-                    -self.parameters.get("R%s" % ax, R0) for ax in 'xyz'],dtype=np.float64)
+                    -self.parameters.get("R%s" % ax, R0) for ax in 'xyz'],
+                    dtype=np.float64)
                 self.domain_right_edge = np.array([
-                    +self.parameters.get("R%s" % ax, R0) for ax in 'xyz'],dtype=np.float64)
-	    self.domain_left_edge *= self.parameters.get("a", 1.0)
-	    self.domain_right_edge *= self.parameters.get("a", 1.0)
+                    +self.parameters.get("R%s" % ax, R0) for ax in 'xyz'],
+                    dtype=np.float64)
+            self.domain_left_edge *= self.parameters.get("a", 1.0)
+            self.domain_right_edge *= self.parameters.get("a", 1.0)
         nz = 1 << self.over_refine_factor
         self.domain_dimensions = np.ones(3, "int32") * nz
         if "do_periodic" in self.parameters and self.parameters["do_periodic"]:


https://bitbucket.org/yt_analysis/yt/commits/64675f402d50/
Changeset:   64675f402d50
Branch:      yt
User:        ngoldbaum
Date:        2015-11-30 19:31:03+00:00
Summary:     Merging
Affected #:  9 files

diff -r 402bc55e4de8acb23a61083886d08c762ca53f94 -r 64675f402d50709159e5400b0a64873f2fc7400a 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 402bc55e4de8acb23a61083886d08c762ca53f94 -r 64675f402d50709159e5400b0a64873f2fc7400a yt/data_objects/data_containers.py
--- a/yt/data_objects/data_containers.py
+++ b/yt/data_objects/data_containers.py
@@ -712,7 +712,27 @@
         raise NotImplementedError
 
     def ptp(self, field):
-        raise NotImplementedError
+        r"""Compute the range of values (maximum - minimum) of a field.
+
+        This will, in a parallel-aware fashion, compute the "peak-to-peak" of
+        the given field.
+
+        Parameters
+        ----------
+        field : string or tuple of strings
+            The field to average.
+
+        Returns
+        -------
+        Scalar
+
+        Examples
+        --------
+
+        >>> rho_range = reg.ptp("density")
+        """
+        ex = self._compute_extrema(field)
+        return ex[1] - ex[0]
 
     def hist(self, field, weight = None, bins = None):
         raise NotImplementedError

diff -r 402bc55e4de8acb23a61083886d08c762ca53f94 -r 64675f402d50709159e5400b0a64873f2fc7400a yt/data_objects/tests/test_numpy_ops.py
--- a/yt/data_objects/tests/test_numpy_ops.py
+++ b/yt/data_objects/tests/test_numpy_ops.py
@@ -73,6 +73,9 @@
         q = ad.max("density").v
         yield assert_equal, q, ad["density"].max()
 
+        ptp = ad.ptp("density").v
+        yield assert_equal, ptp, ad["density"].max() - ad["density"].min()
+
         p = ad.max("density", axis=1)
         p1 = ds.proj("density", 1, data_source=ad, method="mip")
         yield assert_equal, p["density"], p1["density"]

diff -r 402bc55e4de8acb23a61083886d08c762ca53f94 -r 64675f402d50709159e5400b0a64873f2fc7400a yt/fields/derived_field.py
--- a/yt/fields/derived_field.py
+++ b/yt/fields/derived_field.py
@@ -88,8 +88,6 @@
         self.display_field = display_field
         self.particle_type = particle_type
         self.vector_field = vector_field
-        if output_units is None: output_units = units
-        self.output_units = output_units
 
         self._function = function
 
@@ -112,6 +110,9 @@
             raise FieldUnitsError("Cannot handle units '%s' (type %s)." \
                                   "Please provide a string or Unit " \
                                   "object." % (units, type(units)) )
+        if output_units is None:
+            output_units = self.units
+        self.output_units = output_units
 
     def _copy_def(self):
         dd = {}

diff -r 402bc55e4de8acb23a61083886d08c762ca53f94 -r 64675f402d50709159e5400b0a64873f2fc7400a 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 402bc55e4de8acb23a61083886d08c762ca53f94 -r 64675f402d50709159e5400b0a64873f2fc7400a 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 402bc55e4de8acb23a61083886d08c762ca53f94 -r 64675f402d50709159e5400b0a64873f2fc7400a 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 402bc55e4de8acb23a61083886d08c762ca53f94 -r 64675f402d50709159e5400b0a64873f2fc7400a 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 402bc55e4de8acb23a61083886d08c762ca53f94 -r 64675f402d50709159e5400b0a64873f2fc7400a 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