[Yt-svn] yt-commit r1202 - in trunk: tests yt yt/lagos

mturk at wrangler.dreamhost.com mturk at wrangler.dreamhost.com
Tue Mar 10 11:23:17 PDT 2009


Author: mturk
Date: Tue Mar 10 11:23:16 2009
New Revision: 1202
URL: http://yt.spacepope.org/changeset/1202

Log:
Merge back from hg:

  * __repr__ now defined for base data types, for pretty-printing
  * test for __repr__ added
  * recipes has an added comment
  * all_data method added to hierarchy, with optional max-finding for the center



Modified:
   trunk/tests/test_lagos.py
   trunk/yt/lagos/BaseDataTypes.py
   trunk/yt/lagos/HierarchyType.py
   trunk/yt/recipes.py

Modified: trunk/tests/test_lagos.py
==============================================================================
--- trunk/tests/test_lagos.py	(original)
+++ trunk/tests/test_lagos.py	Tue Mar 10 11:23:16 2009
@@ -193,6 +193,10 @@
     def setUp(self):
         LagosTestingBase.setUp(self)
 
+    def testRepr(self):
+        self.assertTrue(
+            ("%s" % self.data).startswith(self.data.__class__.__name__))
+
 class Data3DBase:
     def testProfileAccumulateMass(self):
         self.data.set_field_parameter("center",[0.5]*3)

Modified: trunk/yt/lagos/BaseDataTypes.py
==============================================================================
--- trunk/yt/lagos/BaseDataTypes.py	(original)
+++ trunk/yt/lagos/BaseDataTypes.py	Tue Mar 10 11:23:16 2009
@@ -246,6 +246,13 @@
                      [self.field_parameters])
         return (_reconstruct_object, args)
 
+    def __repr__(self):
+        # We'll do this the slow way to be clear what's going on
+        s = "%s (%s): " % (self.__class__.__name__, self.pf)
+        s += ", ".join(["%s=%s" % (i, getattr(self,i))
+                       for i in self._con_args])
+        return s
+
 class GridPropertiesMixin(object):
 
     def select_grids(self, level):
@@ -1493,6 +1500,14 @@
         else: tr = na.where(tr)
         return tr
 
+    def __repr__(self):
+        # We'll do this the slow way to be clear what's going on
+        s = "%s (%s): " % (self.__class__.__name__, self.pf)
+        s += ", ".join(["%s=%s" % (i, getattr(self,i))
+                       for i in self._con_args if i != "_indices"])
+        return s
+
+
 class InLineExtractedRegionBase(AMR3DData):
     """
     In-line extracted regions accept a base region and a set of field_cuts to

Modified: trunk/yt/lagos/HierarchyType.py
==============================================================================
--- trunk/yt/lagos/HierarchyType.py	(original)
+++ trunk/yt/lagos/HierarchyType.py	Tue Mar 10 11:23:16 2009
@@ -230,6 +230,13 @@
         self._add_object_class('extracted_region', "ExtractedRegion", ExtractedRegionBase, dd)
         self.object_types.sort()
 
+    def all_data(self, find_max=False):
+        pf = self.parameter_file
+        if find_max: c = self.find_max("Density")[1]
+        else: c = (pf["DomainRightEdge"] + pf["DomainLeftEdge"])/2.0
+        return self.region(c, 
+            pf["DomainLeftEdge"], pf["DomainRightEdge"])
+
     def _deserialize_hierarchy(self, harray):
         mylog.debug("Cached entry found.")
         self.gridDimensions[:] = harray[:,0:3]

Modified: trunk/yt/recipes.py
==============================================================================
--- trunk/yt/recipes.py	(original)
+++ trunk/yt/recipes.py	Tue Mar 10 11:23:16 2009
@@ -32,6 +32,10 @@
 from functools import wraps
 from yt.logger import ytLogger as mylog
 
+# These next couple functions are for 'fixing' arguments - accepting arguments
+# of a couple different types and styles, and trying to coerce them into what
+# we want.
+
 def _fix_pf(pf):
     if isinstance(pf, lagos.StaticOutput): return pf
     if os.path.exists("%s.hierarchy" % pf):



More information about the yt-svn mailing list