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

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Thu Mar 27 06:17:56 PDT 2014


3 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/23b0dbbb8299/
Changeset:   23b0dbbb8299
Branch:      yt-3.0
User:        MatthewTurk
Date:        2014-03-26 17:03:18
Summary:     This makes things a bit smarter when setting units.

Fixes #818 and also some other subtle bugs with field overriding.  Particle
unions and unspecified fields in stream were getting confused with field units
overrides.  This sets it up to use the field info units unless they are
explicitly overriddden.
Affected #:  2 files

diff -r cf406118daf0c426c651e2b906e6da8d4cb013d4 -r 23b0dbbb82990a95eca5874faad1d67bb21ea73e yt/data_objects/static_output.py
--- a/yt/data_objects/static_output.py
+++ b/yt/data_objects/static_output.py
@@ -368,7 +368,11 @@
         for field in fields:
             units = set([])
             for s in union:
-                units.add(self.field_units.get((s, field), ""))
+                # First we check our existing fields for units
+                funits = self._get_field_info(s, field).units
+                # Then we override with field_units settings.
+                funits = self.field_units.get((s, field), funits)
+                units.add(funits)
             if len(units) == 1:
                 self.field_units[union.name, field] = list(units)[0]
         self.particle_types += (union.name,)

diff -r cf406118daf0c426c651e2b906e6da8d4cb013d4 -r 23b0dbbb82990a95eca5874faad1d67bb21ea73e yt/frontends/stream/data_structures.py
--- a/yt/frontends/stream/data_structures.py
+++ b/yt/frontends/stream/data_structures.py
@@ -498,6 +498,14 @@
             raise RuntimeError
         new_data[new_field] = data[field]
         field_units[new_field] = field_units.pop(field)
+        known_fields = StreamFieldInfo.known_particle_fields \
+                     + StreamFieldInfo.known_other_fields
+        # We do not want to override any of the known ones, if it's not
+        # overridden here.
+        if new_field == ("all", "particle_position_x"): raise RuntimeError
+        if any(f[0] == new_field[1] for f in known_fields) and \
+           field_units[new_field] == "":
+            field_units.pop(new_field)
     data = new_data
     return field_units, data
 


https://bitbucket.org/yt_analysis/yt/commits/593f5bd2fe26/
Changeset:   593f5bd2fe26
Branch:      yt-3.0
User:        MatthewTurk
Date:        2014-03-27 13:50:39
Summary:     We no longer need this as we are more deliberate about unit setting.
Affected #:  2 files

diff -r 23b0dbbb82990a95eca5874faad1d67bb21ea73e -r 593f5bd2fe2644b19219bd8e1fb825154ea82cc4 yt/frontends/stream/data_structures.py
--- a/yt/frontends/stream/data_structures.py
+++ b/yt/frontends/stream/data_structures.py
@@ -502,7 +502,6 @@
                      + StreamFieldInfo.known_other_fields
         # We do not want to override any of the known ones, if it's not
         # overridden here.
-        if new_field == ("all", "particle_position_x"): raise RuntimeError
         if any(f[0] == new_field[1] for f in known_fields) and \
            field_units[new_field] == "":
             field_units.pop(new_field)

diff -r 23b0dbbb82990a95eca5874faad1d67bb21ea73e -r 593f5bd2fe2644b19219bd8e1fb825154ea82cc4 yt/frontends/stream/io.py
--- a/yt/frontends/stream/io.py
+++ b/yt/frontends/stream/io.py
@@ -52,13 +52,7 @@
             raise NotImplementedError
         rv = {}
         for field in fields:
-            ftype, fname = field
-            try:
-                field_units = self.field_units[fname]
-            except KeyError:
-                field_units = self.field_units[field]
-            rv[field] = self.pf.arr(np.empty(size, dtype="float64"),
-                                    field_units)
+            rv[field] = self.pf.arr(np.empty(size, dtype="float64"))
         ng = sum(len(c.objs) for c in chunks)
         mylog.debug("Reading %s cells of %s fields in %s blocks",
                     size, [f2 for f1, f2 in fields], ng)


https://bitbucket.org/yt_analysis/yt/commits/728161e61e53/
Changeset:   728161e61e53
Branch:      yt-3.0
User:        xarthisius
Date:        2014-03-27 14:17:48
Summary:     Merged in MatthewTurk/yt/yt-3.0 (pull request #770)

This makes things a bit smarter when setting units.
Affected #:  3 files

diff -r 3a11f1dfd9699f172b1ff73697dacd11302fdd2a -r 728161e61e539c92b1d47755d7a10c6358cc0d13 yt/data_objects/static_output.py
--- a/yt/data_objects/static_output.py
+++ b/yt/data_objects/static_output.py
@@ -368,7 +368,11 @@
         for field in fields:
             units = set([])
             for s in union:
-                units.add(self.field_units.get((s, field), ""))
+                # First we check our existing fields for units
+                funits = self._get_field_info(s, field).units
+                # Then we override with field_units settings.
+                funits = self.field_units.get((s, field), funits)
+                units.add(funits)
             if len(units) == 1:
                 self.field_units[union.name, field] = list(units)[0]
         self.particle_types += (union.name,)

diff -r 3a11f1dfd9699f172b1ff73697dacd11302fdd2a -r 728161e61e539c92b1d47755d7a10c6358cc0d13 yt/frontends/stream/data_structures.py
--- a/yt/frontends/stream/data_structures.py
+++ b/yt/frontends/stream/data_structures.py
@@ -498,6 +498,13 @@
             raise RuntimeError
         new_data[new_field] = data[field]
         field_units[new_field] = field_units.pop(field)
+        known_fields = StreamFieldInfo.known_particle_fields \
+                     + StreamFieldInfo.known_other_fields
+        # We do not want to override any of the known ones, if it's not
+        # overridden here.
+        if any(f[0] == new_field[1] for f in known_fields) and \
+           field_units[new_field] == "":
+            field_units.pop(new_field)
     data = new_data
     return field_units, data
 

diff -r 3a11f1dfd9699f172b1ff73697dacd11302fdd2a -r 728161e61e539c92b1d47755d7a10c6358cc0d13 yt/frontends/stream/io.py
--- a/yt/frontends/stream/io.py
+++ b/yt/frontends/stream/io.py
@@ -52,13 +52,7 @@
             raise NotImplementedError
         rv = {}
         for field in fields:
-            ftype, fname = field
-            try:
-                field_units = self.field_units[fname]
-            except KeyError:
-                field_units = self.field_units[field]
-            rv[field] = self.pf.arr(np.empty(size, dtype="float64"),
-                                    field_units)
+            rv[field] = self.pf.arr(np.empty(size, dtype="float64"))
         ng = sum(len(c.objs) for c in chunks)
         mylog.debug("Reading %s cells of %s fields in %s blocks",
                     size, [f2 for f1, f2 in fields], ng)

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