[yt-svn] commit/yt: 3 new changesets

Bitbucket commits-noreply at bitbucket.org
Tue Dec 20 13:53:50 PST 2011


3 new commits in yt:


https://bitbucket.org/yt_analysis/yt/changeset/343f22138249/
changeset:   343f22138249
branch:      yt
user:        MatthewTurk
date:        2011-12-19 18:47:16
summary:     Adding a set of minimal representation objects.
affected #:  3 files

diff -r 91c3e1596f38fca989299cdd177f9c686001a342 -r 343f22138249f20589942e31474df190215ca182 yt/data_objects/data_containers.py
--- a/yt/data_objects/data_containers.py
+++ b/yt/data_objects/data_containers.py
@@ -53,6 +53,8 @@
     TrilinearFieldInterpolator
 from yt.utilities.parameter_file_storage import \
     ParameterFileStore
+from yt.utilities.minimal_representation import \
+    MinimalProjectionData
 
 from .derived_quantities import DerivedQuantityCollection
 from .field_info_container import \
@@ -1645,6 +1647,10 @@
         self._refresh_data()
         if self._okay_to_serialize and self.serialize: self._serialize(node_name=self._node_name)
 
+    @property
+    def _min(self):
+        return MinimalProjectionData(self)
+
     def _convert_field_name(self, field):
         if field == "weight_field": return "weight_field_%s" % self._weight
         if field in self._key_fields: return field


diff -r 91c3e1596f38fca989299cdd177f9c686001a342 -r 343f22138249f20589942e31474df190215ca182 yt/data_objects/static_output.py
--- a/yt/data_objects/static_output.py
+++ b/yt/data_objects/static_output.py
@@ -37,6 +37,8 @@
     output_type_registry
 from yt.data_objects.field_info_container import \
     FieldInfoContainer, NullFunc
+from yt.utilities.minimal_representation import \
+    MinimalStaticOutput
 
 # We want to support the movie format in the future.
 # When such a thing comes to pass, I'll move all the stuff that is contant up
@@ -115,6 +117,10 @@
         except ImportError:
             return s.replace(";", "*")
 
+    @property
+    def _min(self):
+        return MinimalStaticOutput(self)
+
     @classmethod
     def _is_valid(cls, *args, **kwargs):
         return False


diff -r 91c3e1596f38fca989299cdd177f9c686001a342 -r 343f22138249f20589942e31474df190215ca182 yt/utilities/minimal_representation.py
--- /dev/null
+++ b/yt/utilities/minimal_representation.py
@@ -0,0 +1,91 @@
+"""
+Skeleton objects that represent a few fundamental yt data types.
+
+Author: Matthew Turk <matthewturk at gmail.com>
+Affiliation: Columbia University
+Homepage: http://yt-project.org/
+License:
+  Copyright (C) 2011 Matthew Turk.  All Rights Reserved.
+
+  This file is part of yt.
+
+  yt is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 3 of the License, or
+  (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+"""
+
+import abc
+
+class MinimalRepresentation(object):
+    __metaclass__ = abc.ABCMeta
+
+    def _update_attrs(self, obj, attr_list):
+        for attr in attr_list:
+            setattr(self, attr, getattr(obj, attr, None))
+        if hasattr(obj, "pf"):
+            obj.output_hash = obj.pf._hash()
+
+    def __init__(self, obj):
+        self._update_attrs(obj, self._attr_list)
+
+    @abc.abstractmethod
+    def _generate_post(self):
+        pass
+
+    @abc.abstractproperty
+    def _attr_list(self):
+        pass
+
+    def _return_filtered_object(self, attrs):
+        new_attrs = tuple(attr for attr in self._attr_list
+                          if attr not in attrs)
+        new_class = type('Filtered%s' % self.__class__.__name__,
+                         (FilteredRepresentation,),
+                         {'_attr_list': new_attrs})
+        return new_class(self)
+
+    @property
+    def _attrs(self):
+        return dict( ((attr, getattr(self, attr)) for attr in self._attr_list) )
+
+class FilteredRepresentation(MinimalRepresentation):
+    def _generate_post(self):
+        raise RuntimeError
+
+class MinimalStaticOutput(MinimalRepresentation):
+    _attr_list = ("dimensionality", "refine_by", "domain_dimensions",
+                  "current_time", "domain_left_edge", "domain_right_edge",
+                  "unique_identifier", "current_redshift",
+                  "cosmological_simulation", "omega_matter", "omega_lambda",
+                  "hubble_constant")
+
+    def _generate_post(self):
+        metadata = self._attrs
+        chunks = []
+        return metadata, chunks
+
+class MinimalMappableData(MinimalRepresentation):
+
+    weight = "None"
+    _attr_list = ("field_data", "field", "weight", "axis")
+
+    def _generate_post(self):
+        nobj = self._return_filtered_object("field_data")
+        metadata = nobj._attrs
+        chunks = [(arr, self.field_data[arr]) for arr in self.field_data]
+        return (metadata, chunks)
+
+class MinimalProjectionData(MinimalMappableData):
+
+    def __init__(self, obj):
+        self.type = "proj"
+        super(MinimalProjectionData, self).__init__(obj)



https://bitbucket.org/yt_analysis/yt/changeset/47aa0662afad/
changeset:   47aa0662afad
branch:      yt
user:        MatthewTurk
date:        2011-12-19 19:05:22
summary:     Fixing up some things in the minimal representation module.
affected #:  1 file

diff -r 343f22138249f20589942e31474df190215ca182 -r 47aa0662afadee6864f96a53b7bfb91a3a544ddb yt/utilities/minimal_representation.py
--- a/yt/utilities/minimal_representation.py
+++ b/yt/utilities/minimal_representation.py
@@ -32,7 +32,7 @@
         for attr in attr_list:
             setattr(self, attr, getattr(obj, attr, None))
         if hasattr(obj, "pf"):
-            obj.output_hash = obj.pf._hash()
+            self.output_hash = obj.pf._hash()
 
     def __init__(self, obj):
         self._update_attrs(obj, self._attr_list)
@@ -64,10 +64,14 @@
 class MinimalStaticOutput(MinimalRepresentation):
     _attr_list = ("dimensionality", "refine_by", "domain_dimensions",
                   "current_time", "domain_left_edge", "domain_right_edge",
-                  "unique_identifier", "current_redshift",
+                  "unique_identifier", "current_redshift", "output_hash",
                   "cosmological_simulation", "omega_matter", "omega_lambda",
                   "hubble_constant")
 
+    def __init__(self, obj):
+        super(MinimalStaticOutput, self).__init__(obj)
+        self.output_hash = obj._hash()
+
     def _generate_post(self):
         metadata = self._attrs
         chunks = []
@@ -76,10 +80,10 @@
 class MinimalMappableData(MinimalRepresentation):
 
     weight = "None"
-    _attr_list = ("field_data", "field", "weight", "axis")
+    _attr_list = ("field_data", "field", "weight", "axis", "output_hash")
 
     def _generate_post(self):
-        nobj = self._return_filtered_object("field_data")
+        nobj = self._return_filtered_object(("field_data",))
         metadata = nobj._attrs
         chunks = [(arr, self.field_data[arr]) for arr in self.field_data]
         return (metadata, chunks)
@@ -87,5 +91,5 @@
 class MinimalProjectionData(MinimalMappableData):
 
     def __init__(self, obj):
+        super(MinimalProjectionData, self).__init__(obj)
         self.type = "proj"
-        super(MinimalProjectionData, self).__init__(obj)



https://bitbucket.org/yt_analysis/yt/changeset/6ed7167d3a34/
changeset:   6ed7167d3a34
branch:      yt
user:        MatthewTurk
date:        2011-12-20 11:52:05
summary:     A few more minor adjustments to the minimal representation model, including one
that generates the object as best it can from the metadata.
affected #:  3 files

diff -r 47aa0662afadee6864f96a53b7bfb91a3a544ddb -r 6ed7167d3a34e4a2e7e2e6b7e8bb95970098b4e8 yt/data_objects/data_containers.py
--- a/yt/data_objects/data_containers.py
+++ b/yt/data_objects/data_containers.py
@@ -1648,7 +1648,7 @@
         if self._okay_to_serialize and self.serialize: self._serialize(node_name=self._node_name)
 
     @property
-    def _min(self):
+    def _mrep(self):
         return MinimalProjectionData(self)
 
     def _convert_field_name(self, field):


diff -r 47aa0662afadee6864f96a53b7bfb91a3a544ddb -r 6ed7167d3a34e4a2e7e2e6b7e8bb95970098b4e8 yt/data_objects/static_output.py
--- a/yt/data_objects/static_output.py
+++ b/yt/data_objects/static_output.py
@@ -118,7 +118,7 @@
             return s.replace(";", "*")
 
     @property
-    def _min(self):
+    def _mrep(self):
         return MinimalStaticOutput(self)
 
     @classmethod


diff -r 47aa0662afadee6864f96a53b7bfb91a3a544ddb -r 6ed7167d3a34e4a2e7e2e6b7e8bb95970098b4e8 yt/utilities/minimal_representation.py
--- a/yt/utilities/minimal_representation.py
+++ b/yt/utilities/minimal_representation.py
@@ -25,6 +25,9 @@
 
 import abc
 
+class ContainerClass(object):
+    pass
+
 class MinimalRepresentation(object):
     __metaclass__ = abc.ABCMeta
 
@@ -57,6 +60,13 @@
     def _attrs(self):
         return dict( ((attr, getattr(self, attr)) for attr in self._attr_list) )
 
+    @classmethod
+    def _from_metadata(cls, metadata):
+        cc = ContainerClass()
+        for a, v in metadata.values():
+            setattr(cc, a, v)
+        return cls(cc)
+
 class FilteredRepresentation(MinimalRepresentation):
     def _generate_post(self):
         raise RuntimeError

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