[yt-svn] commit/yt: MatthewTurk: Merged in MatthewTurk/yt/yt-3.0 (pull request #892)
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Tue May 20 05:06:28 PDT 2014
1 new commit in yt:
https://bitbucket.org/yt_analysis/yt/commits/8057912c3b02/
Changeset: 8057912c3b02
Branch: yt-3.0
User: MatthewTurk
Date: 2014-05-20 14:06:21
Summary: Merged in MatthewTurk/yt/yt-3.0 (pull request #892)
Adding catches/checks for mixing cut region field types.
Affected #: 2 files
diff -r ee9a8bb2ae6e2a7d4c891bdd08871b4cb2626c90 -r 8057912c3b02f113b27afd252af5d21b4825757a yt/data_objects/selection_data_containers.py
--- a/yt/data_objects/selection_data_containers.py
+++ b/yt/data_objects/selection_data_containers.py
@@ -24,7 +24,10 @@
YTSelectionContainer1D, YTSelectionContainer2D, YTSelectionContainer3D
from yt.data_objects.derived_quantities import \
DerivedQuantityCollection
-from yt.utilities.exceptions import YTSphereTooSmall
+from yt.utilities.exceptions import \
+ YTSphereTooSmall, \
+ YTIllDefinedCutRegion, \
+ YTMixedCutRegion
from yt.utilities.linear_interpolators import TrilinearFieldInterpolator
from yt.utilities.minimal_representation import \
MinimalSliceData
@@ -683,6 +686,9 @@
self.base_object.get_data(fields)
ind = self._cond_ind
for field in fields:
+ f = self.base_object[field]
+ if f.shape != ind.shape:
+ raise YTMixedCutRegion(self.conditionals, field)
self.field_data[field] = self.base_object[field][ind]
@property
@@ -693,6 +699,8 @@
for cond in self.conditionals:
res = eval(cond)
if ind is None: ind = res
+ if ind.shape != res.shape:
+ raise YTIllDefinedCutRegion(self.conditionals)
np.logical_and(res, ind, ind)
return ind
diff -r ee9a8bb2ae6e2a7d4c891bdd08871b4cb2626c90 -r 8057912c3b02f113b27afd252af5d21b4825757a yt/utilities/exceptions.py
--- a/yt/utilities/exceptions.py
+++ b/yt/utilities/exceptions.py
@@ -377,3 +377,26 @@
r = """Position arrays must be length and shape (N,3).
But this one has %s and %s.""" % (self.dimensions, self.shape)
return r
+
+class YTIllDefinedCutRegion(Exception):
+ def __init__(self, conditions):
+ self.conditions = conditions
+
+ def __str__(self):
+ r = """Can't mix particle/discrete and fluid/mesh conditions or
+ quantities. Conditions specified:
+ """
+ r += "\n".join([c for c in self.conditions])
+ return r
+
+class YTMixedCutRegion(Exception):
+ def __init__(self, conditions, field):
+ self.conditions = conditions
+ self.field = field
+
+ def __str__(self):
+ r = """Can't mix particle/discrete and fluid/mesh conditions or
+ quantities. Field: %s and Conditions specified:
+ """ % (self.field,)
+ r += "\n".join([c for c in self.conditions])
+ return r
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