[yt-svn] commit/yt: 2 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Mon Sep 1 07:46:15 PDT 2014
2 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/37c7b55bb7e5/
Changeset: 37c7b55bb7e5
Branch: yt
User: ngoldbaum
Date: 2014-09-01 05:07:45
Summary: Ensure projection weight fields are tuples. Add tests.
Affected #: 4 files
diff -r 28f21e2e39265d69c81a9c6c3647729b6f2133eb -r 37c7b55bb7e5852fb6956296c2b192693f6da13e yt/data_objects/construction_data_containers.py
--- a/yt/data_objects/construction_data_containers.py
+++ b/yt/data_objects/construction_data_containers.py
@@ -222,7 +222,6 @@
self.func = np.sum # for the future
else:
raise NotImplementedError(style)
- self.weight_field = weight_field
self._set_center(center)
if data_source is None: data_source = self.ds.all_data()
for k, v in data_source.field_parameters.items():
@@ -230,7 +229,10 @@
self._is_default_field_parameter(k):
self.set_field_parameter(k, v)
self.data_source = data_source
- self.weight_field = weight_field
+ if weight_field is None:
+ self.weight_field = weight_field
+ else:
+ self.weight_field = self._determine_fields(weight_field)[0]
self.get_data(field)
@property
diff -r 28f21e2e39265d69c81a9c6c3647729b6f2133eb -r 37c7b55bb7e5852fb6956296c2b192693f6da13e yt/data_objects/tests/test_projection.py
--- a/yt/data_objects/tests/test_projection.py
+++ b/yt/data_objects/tests/test_projection.py
@@ -45,7 +45,7 @@
for ax, an in enumerate("xyz"):
xax = ds.coordinates.x_axis[ax]
yax = ds.coordinates.y_axis[ax]
- for wf in ["density", None]:
+ for wf in ['density', ("gas", "density"), None]:
proj = ds.proj(["ones", "density"], ax, weight_field=wf)
yield assert_equal, proj["ones"].sum(), proj["ones"].size
yield assert_equal, proj["ones"].min(), 1.0
@@ -89,8 +89,13 @@
frb.bounds[2:]
yield assert_equal, frb[proj_field].info['center'], \
proj.center
- yield assert_equal, frb[proj_field].info['weight_field'], \
- wf
+ if wf is None:
+ yield assert_equal, \
+ frb[proj_field].info['weight_field'], wf
+ else:
+ yield assert_equal, \
+ frb[proj_field].info['weight_field'], \
+ proj.data_source._determine_fields(wf)[0]
# wf == None
yield assert_equal, wf, None
v1 = proj["density"].sum()
diff -r 28f21e2e39265d69c81a9c6c3647729b6f2133eb -r 37c7b55bb7e5852fb6956296c2b192693f6da13e yt/visualization/plot_container.py
--- a/yt/visualization/plot_container.py
+++ b/yt/visualization/plot_container.py
@@ -463,7 +463,7 @@
if type in ['Projection', 'OffAxisProjection']:
weight = self.data_source.weight_field
if weight is not None:
- weight = weight.replace(' ', '_')
+ weight = weight[1].replace(' ', '_')
if 'Cutting' in self.data_source.__class__.__name__:
type = 'OffAxisSlice'
for k, v in self.plots.iteritems():
@@ -475,8 +475,6 @@
# for cutting planes
n = "%s_%s_%s" % (name, type, k.replace(' ', '_'))
if weight:
- if isinstance(weight, tuple):
- weight = weight[1]
n += "_%s" % (weight)
names.append(v.save(n, mpl_kwargs))
return names
diff -r 28f21e2e39265d69c81a9c6c3647729b6f2133eb -r 37c7b55bb7e5852fb6956296c2b192693f6da13e yt/visualization/tests/test_plotwindow.py
--- a/yt/visualization/tests/test_plotwindow.py
+++ b/yt/visualization/tests/test_plotwindow.py
@@ -140,6 +140,11 @@
),
}
+WEIGHT_FIELDS = (
+ None,
+ 'density',
+ ('gas', 'density'),
+)
@requires_ds(M7)
def test_attributes():
@@ -233,6 +238,7 @@
projections = []
projections_ds = []
projections_c = []
+ projections_wf = []
projections_w = {}
for dim in range(3):
projections.append(ProjectionPlot(test_ds, dim, "density"))
@@ -244,11 +250,15 @@
for width in WIDTH_SPECS:
projections_w[width] = ProjectionPlot(test_ds, dim, 'density',
width=width)
+ for wf in WEIGHT_FIELDS:
+ projections_wf.append(ProjectionPlot(test_ds, dim, "density",
+ weight_field=wf))
cls.slices = [SlicePlot(test_ds, dim, "density") for dim in range(3)]
cls.projections = projections
cls.projections_ds = projections_ds
cls.projections_c = projections_c
+ cls.projections_wf = projections_wf
cls.projections_w = projections_w
cls.offaxis_slice = OffAxisSlicePlot(test_ds, normal, "density")
cls.offaxis_proj = OffAxisProjectionPlot(test_ds, normal, "density")
@@ -282,6 +292,10 @@
def test_projection_plot_c(self, dim):
self.projections_c[dim].save()
+ @parameterized.expand([(i, ) for i in range(len(WEIGHT_FIELDS))])
+ def test_projection_plot_wf(self, dim):
+ self.projections_wf[dim].save()
+
@parameterized.expand(
param.explicit((fname, ))
for fname in TEST_FLNMS)
https://bitbucket.org/yt_analysis/yt/commits/2c3d2e84074a/
Changeset: 2c3d2e84074a
Branch: yt
User: MatthewTurk
Date: 2014-09-01 16:46:06
Summary: Merged in ngoldbaum/yt (pull request #1178)
Ensure projection weight fields are tuples. Add tests.
Affected #: 4 files
diff -r d28bb26c3fb6c4a24ed1788db869522bf0e71380 -r 2c3d2e84074ac8260feb8f056b0720c3a7442e82 yt/data_objects/construction_data_containers.py
--- a/yt/data_objects/construction_data_containers.py
+++ b/yt/data_objects/construction_data_containers.py
@@ -222,7 +222,6 @@
self.func = np.sum # for the future
else:
raise NotImplementedError(style)
- self.weight_field = weight_field
self._set_center(center)
if data_source is None: data_source = self.ds.all_data()
for k, v in data_source.field_parameters.items():
@@ -230,7 +229,10 @@
self._is_default_field_parameter(k):
self.set_field_parameter(k, v)
self.data_source = data_source
- self.weight_field = weight_field
+ if weight_field is None:
+ self.weight_field = weight_field
+ else:
+ self.weight_field = self._determine_fields(weight_field)[0]
self.get_data(field)
@property
diff -r d28bb26c3fb6c4a24ed1788db869522bf0e71380 -r 2c3d2e84074ac8260feb8f056b0720c3a7442e82 yt/data_objects/tests/test_projection.py
--- a/yt/data_objects/tests/test_projection.py
+++ b/yt/data_objects/tests/test_projection.py
@@ -45,7 +45,7 @@
for ax, an in enumerate("xyz"):
xax = ds.coordinates.x_axis[ax]
yax = ds.coordinates.y_axis[ax]
- for wf in ["density", None]:
+ for wf in ['density', ("gas", "density"), None]:
proj = ds.proj(["ones", "density"], ax, weight_field=wf)
yield assert_equal, proj["ones"].sum(), proj["ones"].size
yield assert_equal, proj["ones"].min(), 1.0
@@ -89,8 +89,13 @@
frb.bounds[2:]
yield assert_equal, frb[proj_field].info['center'], \
proj.center
- yield assert_equal, frb[proj_field].info['weight_field'], \
- wf
+ if wf is None:
+ yield assert_equal, \
+ frb[proj_field].info['weight_field'], wf
+ else:
+ yield assert_equal, \
+ frb[proj_field].info['weight_field'], \
+ proj.data_source._determine_fields(wf)[0]
# wf == None
yield assert_equal, wf, None
v1 = proj["density"].sum()
diff -r d28bb26c3fb6c4a24ed1788db869522bf0e71380 -r 2c3d2e84074ac8260feb8f056b0720c3a7442e82 yt/visualization/plot_container.py
--- a/yt/visualization/plot_container.py
+++ b/yt/visualization/plot_container.py
@@ -463,7 +463,7 @@
if type in ['Projection', 'OffAxisProjection']:
weight = self.data_source.weight_field
if weight is not None:
- weight = weight.replace(' ', '_')
+ weight = weight[1].replace(' ', '_')
if 'Cutting' in self.data_source.__class__.__name__:
type = 'OffAxisSlice'
for k, v in self.plots.iteritems():
@@ -475,8 +475,6 @@
# for cutting planes
n = "%s_%s_%s" % (name, type, k.replace(' ', '_'))
if weight:
- if isinstance(weight, tuple):
- weight = weight[1]
n += "_%s" % (weight)
names.append(v.save(n, mpl_kwargs))
return names
diff -r d28bb26c3fb6c4a24ed1788db869522bf0e71380 -r 2c3d2e84074ac8260feb8f056b0720c3a7442e82 yt/visualization/tests/test_plotwindow.py
--- a/yt/visualization/tests/test_plotwindow.py
+++ b/yt/visualization/tests/test_plotwindow.py
@@ -140,6 +140,11 @@
),
}
+WEIGHT_FIELDS = (
+ None,
+ 'density',
+ ('gas', 'density'),
+)
@requires_ds(M7)
def test_attributes():
@@ -233,6 +238,7 @@
projections = []
projections_ds = []
projections_c = []
+ projections_wf = []
projections_w = {}
for dim in range(3):
projections.append(ProjectionPlot(test_ds, dim, "density"))
@@ -244,11 +250,15 @@
for width in WIDTH_SPECS:
projections_w[width] = ProjectionPlot(test_ds, dim, 'density',
width=width)
+ for wf in WEIGHT_FIELDS:
+ projections_wf.append(ProjectionPlot(test_ds, dim, "density",
+ weight_field=wf))
cls.slices = [SlicePlot(test_ds, dim, "density") for dim in range(3)]
cls.projections = projections
cls.projections_ds = projections_ds
cls.projections_c = projections_c
+ cls.projections_wf = projections_wf
cls.projections_w = projections_w
cls.offaxis_slice = OffAxisSlicePlot(test_ds, normal, "density")
cls.offaxis_proj = OffAxisProjectionPlot(test_ds, normal, "density")
@@ -282,6 +292,10 @@
def test_projection_plot_c(self, dim):
self.projections_c[dim].save()
+ @parameterized.expand([(i, ) for i in range(len(WEIGHT_FIELDS))])
+ def test_projection_plot_wf(self, dim):
+ self.projections_wf[dim].save()
+
@parameterized.expand(
param.explicit((fname, ))
for fname in TEST_FLNMS)
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