[yt-svn] commit/yt-3.0: 5 new changesets

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Mon Mar 18 11:20:29 PDT 2013


5 new commits in yt-3.0:

https://bitbucket.org/yt_analysis/yt-3.0/commits/23f418d40647/
changeset:   23f418d40647
branch:      yt-3.0
user:        MatthewTurk
date:        2013-03-15 22:26:38
summary:     First pass at adding particle type general identification.

This adds the ability to check for all types of particles when a bare particle
field is added to the fields.  This means "Something" with particle_type=True
will be checked against all particle_type values.  The fieldinfo entry will be
duplicated.

Unfortunately, as of right now, get_dependencies does not correctly pass things
through the __missing__ or __getitem__ calls.  That will be the next step.
affected #:  1 file

diff -r a71dffe4bc813fdadc506ccad9efb632e23dc843 -r 23f418d4064701b72c43f52d4d8cc22a89294e0c yt/geometry/geometry_handler.py
--- a/yt/geometry/geometry_handler.py
+++ b/yt/geometry/geometry_handler.py
@@ -159,16 +159,43 @@
                 self.parameter_file.field_info[field] = known_fields[field]
 
     def _setup_derived_fields(self):
+        fi = self.parameter_file.field_info
         self.derived_field_list = []
-        for field in self.parameter_file.field_info:
+        # First we construct our list of fields to check
+        fields_to_check = []
+        fields_to_allcheck = []
+        for field in fi:
+            finfo = fi[field]
+            # Explicitly defined
+            if isinstance(field, tuple):
+                fields_to_check.append(field)
+                continue
+            # This one is implicity defined for all particle or fluid types.
+            # So we check each.
+            if not finfo.particle_type:
+                fields_to_check.append(field)
+                continue
+            # We do a special case for 'all' later
+            new_fields = [(pt, field) for pt in
+                          self.parameter_file.particle_types]
+            fields_to_check += new_fields
+            fi.update( (new_field, fi[field]) for new_field in new_fields )
+            fields_to_allcheck.append(field)
+        for field in fields_to_check:
             try:
-                fd = self.parameter_file.field_info[field].get_dependencies(
-                            pf = self.parameter_file)
+                fd = fi[field].get_dependencies(pf = self.parameter_file)
                 self.parameter_file.field_dependencies[field] = fd
-            except:
+            except Exception as e:
                 continue
             available = np.all([f in self.field_list for f in fd.requested])
             if available: self.derived_field_list.append(field)
+        for base_field in fields_to_allcheck:
+            # Now we expand our field_info with the new fields
+            all_available = all(((pt, field) in self.derived_field_list
+                                 for pt in self.parameter_file.particle_types))
+            if all_available:
+                self.derived_field_list.append( ("all", field) )
+                fi["all", base_field] = fi[base_field]
         for field in self.field_list:
             if field not in self.derived_field_list:
                 self.derived_field_list.append(field)


https://bitbucket.org/yt_analysis/yt-3.0/commits/de15a182455b/
changeset:   de15a182455b
branch:      yt-3.0
user:        MatthewTurk
date:        2013-03-15 22:43:04
summary:     This will now correctly identify particle type fields as existing.
affected #:  1 file

diff -r 23f418d4064701b72c43f52d4d8cc22a89294e0c -r de15a182455b8f633b5498d3610d94afaade1ccd yt/geometry/geometry_handler.py
--- a/yt/geometry/geometry_handler.py
+++ b/yt/geometry/geometry_handler.py
@@ -187,8 +187,14 @@
                 self.parameter_file.field_dependencies[field] = fd
             except Exception as e:
                 continue
-            available = np.all([f in self.field_list for f in fd.requested])
-            if available: self.derived_field_list.append(field)
+            missing = False
+            # This next bit checks that we can't somehow generate everything.
+            for f in fd.requested:
+                if f not in self.field_list and \
+                    (field[0], f) not in self.field_list:
+                    missing = True
+                    break
+            if not missing: self.derived_field_list.append(field)
         for base_field in fields_to_allcheck:
             # Now we expand our field_info with the new fields
             all_available = all(((pt, field) in self.derived_field_list


https://bitbucket.org/yt_analysis/yt-3.0/commits/0a386d47521d/
changeset:   0a386d47521d
branch:      yt-3.0
user:        MatthewTurk
date:        2013-03-15 23:12:28
summary:     This changeset finishes particle field detection and broadcasting.

These relatively simple fixes should fix how field dependencies are calculated
and applied during the course of reading IO.  The change in data_containers
actually corrects what I believe was a typo.  The change to static_output
enables "unknown" fields to be switched to whatever was requested last (this
means that requested data["particle_position_x"] from within a particle type'd
function will work) and the final fix updates field dependencies at
determination time to properly identify field types.
affected #:  3 files

diff -r de15a182455b8f633b5498d3610d94afaade1ccd -r 0a386d47521dea1964640bda426547557d49b6cd yt/data_objects/data_containers.py
--- a/yt/data_objects/data_containers.py
+++ b/yt/data_objects/data_containers.py
@@ -453,7 +453,7 @@
     def _identify_dependencies(self, fields_to_get):
         inspected = 0
         fields_to_get = fields_to_get[:]
-        for ftype, field in itertools.cycle(fields_to_get):
+        for field in itertools.cycle(fields_to_get):
             if inspected >= len(fields_to_get): break
             inspected += 1
             if field not in self.pf.field_dependencies: continue

diff -r de15a182455b8f633b5498d3610d94afaade1ccd -r 0a386d47521dea1964640bda426547557d49b6cd yt/data_objects/static_output.py
--- a/yt/data_objects/static_output.py
+++ b/yt/data_objects/static_output.py
@@ -251,6 +251,8 @@
     _last_freq = (None, None)
     _last_finfo = None
     def _get_field_info(self, ftype, fname):
+        if ftype == "unknown" and self._last_freq[0] != None:
+            ftype = self._last_freq[0]
         field = (ftype, fname)
         if field == self._last_freq or fname == self._last_freq[1]:
             return self._last_finfo

diff -r de15a182455b8f633b5498d3610d94afaade1ccd -r 0a386d47521dea1964640bda426547557d49b6cd yt/geometry/geometry_handler.py
--- a/yt/geometry/geometry_handler.py
+++ b/yt/geometry/geometry_handler.py
@@ -184,17 +184,23 @@
         for field in fields_to_check:
             try:
                 fd = fi[field].get_dependencies(pf = self.parameter_file)
-                self.parameter_file.field_dependencies[field] = fd
             except Exception as e:
                 continue
             missing = False
             # This next bit checks that we can't somehow generate everything.
+            # We also manually update the 'requested' attribute
+            requested = []
             for f in fd.requested:
-                if f not in self.field_list and \
-                    (field[0], f) not in self.field_list:
+                if (field[0], f) in self.field_list:
+                    requested.append( (field[0], f) )
+                elif f in self.field_list:
+                    requested.append( f )
+                else:
                     missing = True
                     break
             if not missing: self.derived_field_list.append(field)
+            fd.requested = set(requested)
+            self.parameter_file.field_dependencies[field] = fd
         for base_field in fields_to_allcheck:
             # Now we expand our field_info with the new fields
             all_available = all(((pt, field) in self.derived_field_list


https://bitbucket.org/yt_analysis/yt-3.0/commits/0a402c7eebb9/
changeset:   0a402c7eebb9
branch:      yt-3.0
user:        MatthewTurk
date:        2013-03-16 21:25:39
summary:     Adding ("gas",field) to field_dependencies for gas fields.

Also fix an __iter__ bug where the size of field_info changed over the
iteration.
affected #:  1 file

diff -r 0a386d47521dea1964640bda426547557d49b6cd -r 0a402c7eebb9c27ee1c91c9f480c0701d63a365d yt/geometry/geometry_handler.py
--- a/yt/geometry/geometry_handler.py
+++ b/yt/geometry/geometry_handler.py
@@ -164,6 +164,7 @@
         # First we construct our list of fields to check
         fields_to_check = []
         fields_to_allcheck = []
+        fields_to_add = []
         for field in fi:
             finfo = fi[field]
             # Explicitly defined
@@ -179,8 +180,10 @@
             new_fields = [(pt, field) for pt in
                           self.parameter_file.particle_types]
             fields_to_check += new_fields
-            fi.update( (new_field, fi[field]) for new_field in new_fields )
+            fields_to_add.extend( (new_field, fi[field]) for
+                                   new_field in new_fields )
             fields_to_allcheck.append(field)
+        fi.update(fields_to_add)
         for field in fields_to_check:
             try:
                 fd = fi[field].get_dependencies(pf = self.parameter_file)
@@ -201,6 +204,9 @@
             if not missing: self.derived_field_list.append(field)
             fd.requested = set(requested)
             self.parameter_file.field_dependencies[field] = fd
+            if not fi[field].particle_type and not isinstance(field, tuple):
+                # Manually hardcode to 'gas'
+                self.parameter_file.field_dependencies["gas", field] = fd
         for base_field in fields_to_allcheck:
             # Now we expand our field_info with the new fields
             all_available = all(((pt, field) in self.derived_field_list


https://bitbucket.org/yt_analysis/yt-3.0/commits/190abd27358b/
changeset:   190abd27358b
branch:      yt-3.0
user:        MatthewTurk
date:        2013-03-18 19:12:48
summary:     Adding an additional test that "gas" is accessible for fluid fields.
affected #:  1 file
Diff not available.

Repository URL: https://bitbucket.org/yt_analysis/yt-3.0/

--

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