[yt-svn] commit/yt: ngoldbaum: Ensure locally defined fields with physical units can still generate labels
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Mon Aug 29 08:45:08 PDT 2016
1 new commit in yt:
https://bitbucket.org/yt_analysis/yt/commits/e339dc97f667/
Changeset: e339dc97f667
Branch: yt
User: ngoldbaum
Date: 2016-08-28 14:51:28+00:00
Summary: Ensure locally defined fields with physical units can still generate labels
Affected #: 1 file
diff -r c941aa457bc3c9e43f3ab0ecafa82d2924a8e204 -r e339dc97f6672cc461078a780c05f535615b9e38 yt/fields/derived_field.py
--- a/yt/fields/derived_field.py
+++ b/yt/fields/derived_field.py
@@ -144,12 +144,18 @@
return dd
def get_units(self):
- u = Unit(self.units, registry=self.ds.unit_registry)
+ if self.ds is not None:
+ u = Unit(self.units, registry=self.ds.unit_registry)
+ else:
+ u = Unit(self.units)
return u.latex_representation()
def get_projected_units(self):
- u = Unit(self.units, registry=self.ds.unit_registry)*Unit('cm')
- return u.latex_representation()
+ if self.ds is not None:
+ u = Unit(self.units, registry=self.ds.unit_registry)
+ else:
+ u = Unit(self.units)
+ return (u*Unit('cm')).latex_representation()
def check_available(self, data):
"""
@@ -222,7 +228,10 @@
if projected:
raise NotImplementedError
else:
- units = Unit(self.units, registry=self.ds.unit_registry)
+ if self.ds is not None:
+ units = Unit(self.units, registry=self.ds.unit_registry)
+ else:
+ units = Unit(self.units)
# Add unit label
if not units.is_dimensionless:
data_label += r"\ \ (%s)" % (units.latex_representation())
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