[Yt-svn] yt-commit r1134 - in trunk: . yt/lagos

mturk at wrangler.dreamhost.com mturk at wrangler.dreamhost.com
Thu Jan 22 08:30:45 PST 2009


Author: mturk
Date: Thu Jan 22 08:30:42 2009
New Revision: 1134
URL: http://yt.spacepope.org/changeset/1134

Log:
Added __reduce__ method to parameter files and allowed non-iterable objects to be
returned from the hierarchy's load_object method.  Now raw profiles can be
pickled.  (Profiles from plot collections not yet.)


Modified:
   trunk/   (props changed)
   trunk/yt/lagos/HierarchyType.py
   trunk/yt/lagos/OutputTypes.py

Modified: trunk/yt/lagos/HierarchyType.py
==============================================================================
--- trunk/yt/lagos/HierarchyType.py	(original)
+++ trunk/yt/lagos/HierarchyType.py	Thu Jan 22 08:30:42 2009
@@ -176,7 +176,10 @@
         obj = self.get_data("/Objects", name)
         if obj is None:
             return
-        return cPickle.loads(obj.read())[1] # Just the object, not the pf
+        obj = cPickle.loads(obj.read())
+        if iterable(obj) and len(obj) == 2:
+            return obj[1] # Just the object, not the pf
+        return obj
 
     def get_data(self, node, name):
         """

Modified: trunk/yt/lagos/OutputTypes.py
==============================================================================
--- trunk/yt/lagos/OutputTypes.py	(original)
+++ trunk/yt/lagos/OutputTypes.py	Thu Jan 22 08:30:42 2009
@@ -73,6 +73,10 @@
         self._set_units()
         # These can be taken out if you so desire
 
+    def __reduce__(self):
+        args = (self._hash(),)
+        return (_reconstruct_pf, args)
+
     def __repr__(self):
         return self.basename
 
@@ -487,3 +491,7 @@
             self.conversion_factors["Time"] = 1.0
         for unit in mpc_conversion.keys():
             self.units[unit] = mpc_conversion[unit] / mpc_conversion["cm"]
+
+def _reconstruct_pf(*args, **kwargs):
+    pfs = ParameterFileStore()
+    pf = pfs.get_pf_hash(*args)



More information about the yt-svn mailing list