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

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Mon Jul 31 08:35:35 PDT 2017


2 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/2b3dcc834186/
Changeset:   2b3dcc834186
User:        ngoldbaum
Date:        2017-07-28 16:54:57+00:00
Summary:     Restore support for visualizing YTSpatialPlotDataset instances
Affected #:  2 files

diff -r 71d0f9b7951cd8562f219d1a610d505a6d256873 -r 2b3dcc834186ada18b321a3ff233a25a7c082a00 yt/frontends/ytdata/tests/test_outputs.py
--- a/yt/frontends/ytdata/tests/test_outputs.py
+++ b/yt/frontends/ytdata/tests/test_outputs.py
@@ -26,7 +26,9 @@
     save_as_dataset
 from yt.testing import \
     assert_allclose_units, \
-    assert_equal
+    assert_equal, \
+    assert_fname, \
+    fake_random_ds
 from yt.utilities.answer_testing.framework import \
     requires_ds, \
     data_dir_load, \
@@ -34,6 +36,9 @@
 from yt.units.yt_array import \
     YTArray, \
     YTQuantity
+from yt.visualization.plot_window import \
+    SlicePlot, \
+    ProjectionPlot
 from yt.visualization.profile_plotter import \
     ProfilePlot, \
     PhasePlot
@@ -223,3 +228,33 @@
     yield YTDataFieldTest(full_fn, "density", geometric=False)
     os.chdir(curdir)
     shutil.rmtree(tmpdir)
+
+def test_plot_data():
+    tmpdir = tempfile.mkdtemp()
+    curdir = os.getcwd()
+    os.chdir(tmpdir)
+    ds = fake_random_ds(16)
+
+    plot = SlicePlot(ds, 'z', 'density')
+    plot.data_source.save_as_dataset('slice.h5')
+    ds_slice = load('slice.h5')
+    p = SlicePlot(ds_slice, 'z', 'density')
+    fn = p.save()
+    assert_fname(fn[0])
+
+    plot = ProjectionPlot(ds, 'z', 'density')
+    plot.data_source.save_as_dataset('proj.h5')
+    ds_proj = load('slice.h5')
+    p = ProjectionPlot(ds_proj, 'z', 'density')
+    fn = p.save()
+    assert_fname(fn[0])
+
+    plot = SlicePlot(ds, [1, 1, 1], 'density')
+    plot.data_source.save_as_dataset('oas.h5')
+    ds_oas = load('oas.h5')
+    p = SlicePlot(ds_oas, [1, 1, 1], 'density')
+    fn = p.save()
+    assert_fname(fn[0])
+
+    os.chdir(curdir)
+    shutil.rmtree(tmpdir)

diff -r 71d0f9b7951cd8562f219d1a610d505a6d256873 -r 2b3dcc834186ada18b321a3ff233a25a7c082a00 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -124,6 +124,11 @@
     return axes_unit
 
 def validate_mesh_fields(data_source, fields):
+    # this check doesn't make sense for ytdata plot datasets, which
+    # load mesh data as a particle field but nonetheless can still
+    # make plots with it
+    if isinstance(data_source.ds, YTSpatialPlotDataset):
+        return
     canonical_fields = data_source._determine_fields(fields)
     invalid_fields = []
     for field in canonical_fields:
@@ -1438,7 +1443,10 @@
             if proj.axis != ds.parameters["axis"]:
                 raise RuntimeError("Original projection axis is %s." %
                                    ds.parameters["axis"])
-            proj.weight_field = proj._determine_fields(weight_field)[0]
+            if weight_field is not None:
+                proj.weight_field = proj._determine_fields(weight_field)[0]
+            else:
+                proj.weight_field = weight_field
         else:
             proj = ds.proj(fields, axis, weight_field=weight_field,
                            center=center, data_source=data_source,
@@ -2060,4 +2068,4 @@
                                 fontsize=fontsize,
                                 field_parameters=field_parameters, 
                                 window_size=window_size, aspect=aspect,
-                                data_source=data_source)
\ No newline at end of file
+                                data_source=data_source)


https://bitbucket.org/yt_analysis/yt/commits/a673272de688/
Changeset:   a673272de688
User:        ngoldbaum
Date:        2017-07-31 15:34:51+00:00
Summary:     Merge pull request #1514 from ngoldbaum/reloaded-slice

Restore support for visualizing YTSpatialPlotDataset instances. Fixes #1444
Affected #:  2 files

diff -r c3c7f4a6713b28483cfd74ec40e768a65adf9e4b -r a673272de688dee5a0fefa787adc001d5065c381 yt/frontends/ytdata/tests/test_outputs.py
--- a/yt/frontends/ytdata/tests/test_outputs.py
+++ b/yt/frontends/ytdata/tests/test_outputs.py
@@ -26,7 +26,9 @@
     save_as_dataset
 from yt.testing import \
     assert_allclose_units, \
-    assert_equal
+    assert_equal, \
+    assert_fname, \
+    fake_random_ds
 from yt.utilities.answer_testing.framework import \
     requires_ds, \
     data_dir_load, \
@@ -34,6 +36,9 @@
 from yt.units.yt_array import \
     YTArray, \
     YTQuantity
+from yt.visualization.plot_window import \
+    SlicePlot, \
+    ProjectionPlot
 from yt.visualization.profile_plotter import \
     ProfilePlot, \
     PhasePlot
@@ -223,3 +228,33 @@
     yield YTDataFieldTest(full_fn, "density", geometric=False)
     os.chdir(curdir)
     shutil.rmtree(tmpdir)
+
+def test_plot_data():
+    tmpdir = tempfile.mkdtemp()
+    curdir = os.getcwd()
+    os.chdir(tmpdir)
+    ds = fake_random_ds(16)
+
+    plot = SlicePlot(ds, 'z', 'density')
+    plot.data_source.save_as_dataset('slice.h5')
+    ds_slice = load('slice.h5')
+    p = SlicePlot(ds_slice, 'z', 'density')
+    fn = p.save()
+    assert_fname(fn[0])
+
+    plot = ProjectionPlot(ds, 'z', 'density')
+    plot.data_source.save_as_dataset('proj.h5')
+    ds_proj = load('slice.h5')
+    p = ProjectionPlot(ds_proj, 'z', 'density')
+    fn = p.save()
+    assert_fname(fn[0])
+
+    plot = SlicePlot(ds, [1, 1, 1], 'density')
+    plot.data_source.save_as_dataset('oas.h5')
+    ds_oas = load('oas.h5')
+    p = SlicePlot(ds_oas, [1, 1, 1], 'density')
+    fn = p.save()
+    assert_fname(fn[0])
+
+    os.chdir(curdir)
+    shutil.rmtree(tmpdir)

diff -r c3c7f4a6713b28483cfd74ec40e768a65adf9e4b -r a673272de688dee5a0fefa787adc001d5065c381 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -124,6 +124,11 @@
     return axes_unit
 
 def validate_mesh_fields(data_source, fields):
+    # this check doesn't make sense for ytdata plot datasets, which
+    # load mesh data as a particle field but nonetheless can still
+    # make plots with it
+    if isinstance(data_source.ds, YTSpatialPlotDataset):
+        return
     canonical_fields = data_source._determine_fields(fields)
     invalid_fields = []
     for field in canonical_fields:
@@ -1438,7 +1443,10 @@
             if proj.axis != ds.parameters["axis"]:
                 raise RuntimeError("Original projection axis is %s." %
                                    ds.parameters["axis"])
-            proj.weight_field = proj._determine_fields(weight_field)[0]
+            if weight_field is not None:
+                proj.weight_field = proj._determine_fields(weight_field)[0]
+            else:
+                proj.weight_field = weight_field
         else:
             proj = ds.proj(fields, axis, weight_field=weight_field,
                            center=center, data_source=data_source,
@@ -2060,4 +2068,4 @@
                                 fontsize=fontsize,
                                 field_parameters=field_parameters, 
                                 window_size=window_size, aspect=aspect,
-                                data_source=data_source)
\ No newline at end of file
+                                data_source=data_source)

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