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

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Fri Oct 13 18:30:48 PDT 2017


4 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/4747efc06a9b/
Changeset:   4747efc06a9b
User:        jzuhone
Date:        2017-09-21 16:37:09+00:00
Summary:     Fix set_unit so that it accepts field tuples
Affected #:  1 file

diff -r 6952560f1d68aee46a5910f0cafa287a01c98aa1 -r 4747efc06a9b46e09cb1c1dfbb2ff1ffa2e54acd yt/visualization/profile_plotter.py
--- a/yt/visualization/profile_plotter.py
+++ b/yt/visualization/profile_plotter.py
@@ -1235,12 +1235,12 @@
         new_unit : string or Unit object
            The name of the new unit.
         """
-        fields = [fd[1] for fd in self.profile.field_data]
-        if field == self.profile.x_field[1]:
+        fd = self.data_source._determine_fields(field)[0]
+        if fd == self.profile.x_field:
             self.profile.set_x_unit(unit)
-        elif field == self.profile.y_field[1]:
+        elif fd == self.profile.y_field:
             self.profile.set_y_unit(unit)
-        elif field in fields:
+        elif fd in self.profile.field_data.keys():
             self.profile.set_field_unit(field, unit)
             self.plots[field].zmin, self.plots[field].zmax = (None, None)
         else:


https://bitbucket.org/yt_analysis/yt/commits/9b4f22137ffb/
Changeset:   9b4f22137ffb
User:        jzuhone
Date:        2017-09-21 18:17:59+00:00
Summary:     Make the same changes for profile plots
Affected #:  1 file

diff -r 4747efc06a9b46e09cb1c1dfbb2ff1ffa2e54acd -r 9b4f22137ffb6b3e074ae57c1b4b2e4ab1baad49 yt/visualization/profile_plotter.py
--- a/yt/visualization/profile_plotter.py
+++ b/yt/visualization/profile_plotter.py
@@ -513,10 +513,11 @@
         new_unit : string or Unit object
            The name of the new unit.
         """
+        fd = self.profiles[0].data_source._determine_fields(field)[0]
         for profile in self.profiles:
-            if field == profile.x_field[1]:
+            if fd == profile.x_field:
                 profile.set_x_unit(unit)
-            elif field in self.profiles[0].field_map:
+            elif fd[1] in self.profiles[0].field_map:
                 profile.set_field_unit(field, unit)
             else:
                 raise KeyError("Field %s not in profile plot!" % (field))


https://bitbucket.org/yt_analysis/yt/commits/126ecc4d651d/
Changeset:   126ecc4d651d
User:        jzuhone
Date:        2017-09-26 21:21:23+00:00
Summary:     Some tests
Affected #:  2 files

diff -r 9b4f22137ffb6b3e074ae57c1b4b2e4ab1baad49 -r 126ecc4d651d81574160135373f66534f762b74e yt/visualization/tests/test_particle_plot.py
--- a/yt/visualization/tests/test_particle_plot.py
+++ b/yt/visualization/tests/test_particle_plot.py
@@ -264,6 +264,14 @@
     dybins = p.y_bins[1:] - p.y_bins[:-1]
     assert_allclose(dybins, dybins[0])
 
+ at requires_file(tgal)
+def test_set_units():
+    ds = load(tgal)
+    sp = ds.sphere("max", (1.0, "Mpc"))
+    pp = ParticlePhasePlot(sp, ("Gas", "density"), ("Gas", "temperature"), ("Gas", "particle_mass"))
+    # make sure we can set the units using the tuple without erroring out
+    pp.set_unit(("Gas", "particle_mass"), "Msun")
+
 class TestParticleProjectionPlotSave(unittest.TestCase):
 
     def setUp(self):

diff -r 9b4f22137ffb6b3e074ae57c1b4b2e4ab1baad49 -r 126ecc4d651d81574160135373f66534f762b74e yt/visualization/tests/test_profile_plots.py
--- a/yt/visualization/tests/test_profile_plots.py
+++ b/yt/visualization/tests/test_profile_plots.py
@@ -144,7 +144,7 @@
 
 @requires_file(ETC46)
 def test_profile_plot_multiple_field_multiple_plot():
-    ds = yt.load("enzo_tiny_cosmology/DD0046/DD0046")
+    ds = yt.load(ETC46)
     sphere = ds.sphere("max", (1.0, "Mpc"))
     profiles = []
     profiles.append(yt.create_profile(
@@ -160,3 +160,13 @@
     plot = yt.ProfilePlot.from_profiles(profiles)
     with tempfile.NamedTemporaryFile(suffix='png') as f:
         plot.save(name=f.name)
+
+ at requires_file(ETC46)
+def test_set_units():
+    ds = yt.load(ETC46)
+    sp = ds.sphere("max", (1.0, "Mpc"))
+    p1 = yt.ProfilePlot(sp, "radius", ("enzo", "Density"))
+    p2 = yt.PhasePlot(sp, ("enzo", "Density"), ("enzo", "Temperature"), "cell_mass")
+    # make sure we can set the units using the tuple without erroring out
+    p1.set_unit(("enzo", "Density"), "Msun/kpc**3")
+    p2.set_unit(("enzo", "Temperature"), "R")
\ No newline at end of file


https://bitbucket.org/yt_analysis/yt/commits/86308371c855/
Changeset:   86308371c855
User:        ngoldbaum
Date:        2017-10-14 01:30:37+00:00
Summary:     Merge pull request #1568 from jzuhone/fix_set_unit_pp

[bugfix] Allow for full field names in set_unit for phase and profile plots
Affected #:  3 files

diff -r 74079dda954fc8dcab2ff2fdb28bd6580c2befdd -r 86308371c855d637f2dbe206611d872705fb4290 yt/visualization/profile_plotter.py
--- a/yt/visualization/profile_plotter.py
+++ b/yt/visualization/profile_plotter.py
@@ -513,10 +513,11 @@
         new_unit : string or Unit object
            The name of the new unit.
         """
+        fd = self.profiles[0].data_source._determine_fields(field)[0]
         for profile in self.profiles:
-            if field == profile.x_field[1]:
+            if fd == profile.x_field:
                 profile.set_x_unit(unit)
-            elif field in self.profiles[0].field_map:
+            elif fd[1] in self.profiles[0].field_map:
                 profile.set_field_unit(field, unit)
             else:
                 raise KeyError("Field %s not in profile plot!" % (field))
@@ -1235,12 +1236,12 @@
         new_unit : string or Unit object
            The name of the new unit.
         """
-        fields = [fd[1] for fd in self.profile.field_data]
-        if field == self.profile.x_field[1]:
+        fd = self.data_source._determine_fields(field)[0]
+        if fd == self.profile.x_field:
             self.profile.set_x_unit(unit)
-        elif field == self.profile.y_field[1]:
+        elif fd == self.profile.y_field:
             self.profile.set_y_unit(unit)
-        elif field in fields:
+        elif fd in self.profile.field_data.keys():
             self.profile.set_field_unit(field, unit)
             self.plots[field].zmin, self.plots[field].zmax = (None, None)
         else:

diff -r 74079dda954fc8dcab2ff2fdb28bd6580c2befdd -r 86308371c855d637f2dbe206611d872705fb4290 yt/visualization/tests/test_particle_plot.py
--- a/yt/visualization/tests/test_particle_plot.py
+++ b/yt/visualization/tests/test_particle_plot.py
@@ -264,6 +264,14 @@
     dybins = p.y_bins[1:] - p.y_bins[:-1]
     assert_allclose(dybins, dybins[0])
 
+ at requires_file(tgal)
+def test_set_units():
+    ds = load(tgal)
+    sp = ds.sphere("max", (1.0, "Mpc"))
+    pp = ParticlePhasePlot(sp, ("Gas", "density"), ("Gas", "temperature"), ("Gas", "particle_mass"))
+    # make sure we can set the units using the tuple without erroring out
+    pp.set_unit(("Gas", "particle_mass"), "Msun")
+
 class TestParticleProjectionPlotSave(unittest.TestCase):
 
     def setUp(self):

diff -r 74079dda954fc8dcab2ff2fdb28bd6580c2befdd -r 86308371c855d637f2dbe206611d872705fb4290 yt/visualization/tests/test_profile_plots.py
--- a/yt/visualization/tests/test_profile_plots.py
+++ b/yt/visualization/tests/test_profile_plots.py
@@ -144,7 +144,7 @@
 
 @requires_file(ETC46)
 def test_profile_plot_multiple_field_multiple_plot():
-    ds = yt.load("enzo_tiny_cosmology/DD0046/DD0046")
+    ds = yt.load(ETC46)
     sphere = ds.sphere("max", (1.0, "Mpc"))
     profiles = []
     profiles.append(yt.create_profile(
@@ -160,3 +160,13 @@
     plot = yt.ProfilePlot.from_profiles(profiles)
     with tempfile.NamedTemporaryFile(suffix='png') as f:
         plot.save(name=f.name)
+
+ at requires_file(ETC46)
+def test_set_units():
+    ds = yt.load(ETC46)
+    sp = ds.sphere("max", (1.0, "Mpc"))
+    p1 = yt.ProfilePlot(sp, "radius", ("enzo", "Density"))
+    p2 = yt.PhasePlot(sp, ("enzo", "Density"), ("enzo", "Temperature"), "cell_mass")
+    # make sure we can set the units using the tuple without erroring out
+    p1.set_unit(("enzo", "Density"), "Msun/kpc**3")
+    p2.set_unit(("enzo", "Temperature"), "R")
\ No newline at end of file

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