[yt-svn] commit/yt: ngoldbaum: Merged in brittonsmith/yt (pull request #2087)

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Mon Mar 28 13:06:55 PDT 2016


1 new commit in yt:

https://bitbucket.org/yt_analysis/yt/commits/86db031f1f56/
Changeset:   86db031f1f56
Branch:      yt
User:        ngoldbaum
Date:        2016-03-28 20:06:49+00:00
Summary:     Merged in brittonsmith/yt (pull request #2087)

Making YTFieldTypeNotFound exception more informative. (closes #1027)
Affected #:  2 files

diff -r 61be4a106d8843629a48f23b27cc532a1e4ee91e -r 86db031f1f56a6f396d4440188707f1fdb8e6bfa yt/data_objects/data_containers.py
--- a/yt/data_objects/data_containers.py
+++ b/yt/data_objects/data_containers.py
@@ -1005,9 +1005,9 @@
             # these tests are really insufficient as a field type may be valid, and the
             # field name may be valid, but not the combination (field type, field name)
             if finfo.particle_type and ftype not in self.ds.particle_types:
-                raise YTFieldTypeNotFound(ftype)
+                raise YTFieldTypeNotFound(ftype, ds=self.ds)
             elif not finfo.particle_type and ftype not in self.ds.fluid_types:
-                raise YTFieldTypeNotFound(ftype)
+                raise YTFieldTypeNotFound(ftype, ds=self.ds)
             explicit_fields.append((ftype, fname))
         return explicit_fields
 

diff -r 61be4a106d8843629a48f23b27cc532a1e4ee91e -r 86db031f1f56a6f396d4440188707f1fdb8e6bfa yt/utilities/exceptions.py
--- a/yt/utilities/exceptions.py
+++ b/yt/utilities/exceptions.py
@@ -75,11 +75,18 @@
         return "Could field '%s' in %s could not be generated." % (self.fname, self.ds)
 
 class YTFieldTypeNotFound(YTException):
-    def __init__(self, fname):
-        self.fname = fname
+    def __init__(self, ftype, ds=None):
+        self.ftype = ftype
+        self.ds = ds
 
     def __str__(self):
-        return "Could not find field '%s'." % (self.fname)
+        if self.ds is not None and \
+          self.ftype in self.ds.particle_types:
+            return ("Could not find field type '%s'.  " +
+                    "This field type is a known particle type for this dataset.  " +
+                    "Try adding this field with particle_type=True.") % self.ftype
+        else:
+            return "Could not find field type '%s'." % (self.ftype)
 
 class YTSimulationNotIdentified(YTException):
     def __init__(self, sim_type):

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-svn-spacepope.org/attachments/20160328/a3cf65b5/attachment.htm>


More information about the yt-svn mailing list