[yt-svn] commit/yt: MatthewTurk: Merged in ngoldbaum/yt (pull request #1999)

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Wed Feb 24 09:31:12 PST 2016


1 new commit in yt:

https://bitbucket.org/yt_analysis/yt/commits/737f924d071e/
Changeset:   737f924d071e
Branch:      yt
User:        MatthewTurk
Date:        2016-02-24 17:31:07+00:00
Summary:     Merged in ngoldbaum/yt (pull request #1999)

Ensure DerivedField instances can create code unit symbols
Affected #:  2 files

diff -r ba82b89be0dbd9b6535a83589000948579e8ef57 -r 737f924d071e578fff7e5d756502b8260f1b84c4 yt/fields/derived_field.py
--- a/yt/fields/derived_field.py
+++ b/yt/fields/derived_field.py
@@ -80,7 +80,8 @@
     def __init__(self, name, function, units=None,
                  take_log=True, validators=None,
                  particle_type=False, vector_field=False, display_field=True,
-                 not_in_all=False, display_name=None, output_units = None):
+                 not_in_all=False, display_name=None, output_units=None,
+                 ds=None):
         self.name = name
         self.take_log = take_log
         self.display_name = display_name
@@ -88,6 +89,7 @@
         self.display_field = display_field
         self.particle_type = particle_type
         self.vector_field = vector_field
+        self.ds = ds
 
         self._function = function
 
@@ -128,11 +130,11 @@
         return dd
 
     def get_units(self):
-        u = Unit(self.units)
+        u = Unit(self.units, registry=self.ds.unit_registry)
         return u.latex_representation()
 
     def get_projected_units(self):
-        u = Unit(self.units)*Unit('cm')
+        u = Unit(self.units, registry=self.ds.unit_registry)*Unit('cm')
         return u.latex_representation()
 
     def check_available(self, data):
@@ -206,7 +208,7 @@
         if projected:
             raise NotImplementedError
         else:
-            units = Unit(self.units)
+            units = Unit(self.units, registry=self.ds.unit_registry)
         # Add unit label
         if not units.is_dimensionless:
             data_label += r"\ \ (%s)" % (units.latex_representation())

diff -r ba82b89be0dbd9b6535a83589000948579e8ef57 -r 737f924d071e578fff7e5d756502b8260f1b84c4 yt/fields/field_info_container.py
--- a/yt/fields/field_info_container.py
+++ b/yt/fields/field_info_container.py
@@ -240,6 +240,7 @@
         # the derived field and exit. If used as a decorator, function will
         # be None. In that case, we return a function that will be applied
         # to the function that the decorator is applied to.
+        kwargs.setdefault('ds', self.ds)
         if function is None:
             def create_function(f):
                 self[name] = DerivedField(name, f, **kwargs)
@@ -274,6 +275,7 @@
         return loaded, unavailable
 
     def add_output_field(self, name, **kwargs):
+        kwargs.setdefault('ds', self.ds)
         self[name] = DerivedField(name, NullFunc, **kwargs)
 
     def alias(self, alias_name, original_name, units = None):

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