[Yt-svn] commit/yt: MatthewTurk: Changing the way hierarchies are instantiated to make it easier to load up a

Bitbucket commits-noreply at bitbucket.org
Wed Apr 13 10:34:23 PDT 2011


1 new changeset in yt:

http://bitbucket.org/yt_analysis/yt/changeset/98c999853f72/
changeset:   r4120:98c999853f72
branch:      yt
user:        MatthewTurk
date:        2011-04-13 19:33:54
summary:     Changing the way hierarchies are instantiated to make it easier to load up a
big directory of hierarchies in reason
affected #:  2 files (328 bytes)

--- a/yt/data_objects/static_output.py	Wed Apr 13 11:21:49 2011 -0400
+++ b/yt/data_objects/static_output.py	Wed Apr 13 13:33:54 2011 -0400
@@ -152,21 +152,16 @@
                key in self.parameters or \
                key in self.conversion_factors
 
-    def _get_hierarchy(self):
-        if self.__hierarchy == None:
+    _instantiated_hierarchy = None
+    @property
+    def hierarchy(self):
+        if self._instantiated_hierarchy == None:
             if self._hierarchy_class == None:
                 raise RuntimeError("You should not instantiate StaticOutput.")
-            self.__hierarchy = self._hierarchy_class(self, data_style=self.data_style)
-        return self.__hierarchy
-
-    def _set_hierarchy(self, newh):
-        if self.__hierarchy != None:
-            mylog.warning("Overriding hierarchy attribute!  This is probably unwise!")
-        self.__hierarchy = newh
-
-    __hierarchy = None
-    hierarchy = property(_get_hierarchy, _set_hierarchy)
-    h = property(_get_hierarchy, _set_hierarchy)
+            self._instantiated_hierarchy = self._hierarchy_class(
+                self, data_style=self.data_style)
+        return self._instantiated_hierarchy
+    h = hierarchy
 
     @parallel_root_only
     def print_key_parameters(self):


--- a/yt/gui/reason/extdirect_repl.py	Wed Apr 13 11:21:49 2011 -0400
+++ b/yt/gui/reason/extdirect_repl.py	Wed Apr 13 13:33:54 2011 -0400
@@ -344,16 +344,18 @@
         for fn, pf in sorted(_cached_pfs.items()):
             objs = []
             pf_varname = "_cached_pfs['%s']" % (fn)
-            fields = set(pf.h.field_list + pf.h.derived_field_list)
-            fields = list(fields)
-            fields.sort()
-            for i,obj in enumerate(pf.h.objects):
-                try:
-                    name = str(obj)
-                except ReferenceError:
-                    continue
-                objs.append(dict(name=name, type=obj._type_name,
-                                 varname = "%s.h.objects[%s]" % (pf_varname, i)))
+            fields = []
+            if pf._instantiated_hierarchy is not None: 
+                fields = set(pf.h.field_list + pf.h.derived_field_list)
+                fields = list(fields)
+                fields.sort()
+                for i,obj in enumerate(pf.h.objects):
+                    try:
+                        name = str(obj)
+                    except ReferenceError:
+                        continue
+                    objs.append(dict(name=name, type=obj._type_name,
+                                     varname = "%s.h.objects[%s]" % (pf_varname, i)))
             rv.append( dict(name = str(pf), objects = objs, filename=fn,
                             varname = pf_varname, field_list = fields) )
         return rv

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