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

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Mon Sep 21 11:34:25 PDT 2015


1 new commit in yt:

https://bitbucket.org/yt_analysis/yt/commits/9acfe15f8b6a/
Changeset:   9acfe15f8b6a
Branch:      yt
User:        chummels
Date:        2015-09-21 18:34:13+00:00
Summary:     Merged in ngoldbaum/yt (pull request #1753)

[bugfix] fix code unit labels
Affected #:  2 files

diff -r 9b76efa712c65a3118ef2c6fb8e97defae53fc7e -r 9acfe15f8b6a998c7817e34706571437ff0eb8dc yt/units/tests/test_units.py
--- a/yt/units/tests/test_units.py
+++ b/yt/units/tests/test_units.py
@@ -454,7 +454,7 @@
     assert_raises(InvalidUnitOperation, operator.mul, u1, u2)
     assert_raises(InvalidUnitOperation, operator.truediv, u1, u2)
 
-def test_comoving_labels():
+def test_comoving_and_code_unit_labels():
     ds = fake_random_ds(64, nprocs=1)
 
     # create a fake comoving unit
@@ -464,3 +464,10 @@
     test_unit = Unit('Mpccm', registry=ds.unit_registry)
     assert_almost_equal(test_unit.base_value, cm_per_mpc/3)
     assert_equal(test_unit.latex_repr, r'\rm{Mpc}/(1+z)')
+
+    test_unit = Unit('code_mass', registry=ds.unit_registry)
+    assert_equal(test_unit.latex_repr, '\\rm{code\\ mass}')
+
+    test_unit = Unit('code_mass/code_length**3', registry=ds.unit_registry)
+    assert_equal(test_unit.latex_repr,
+                 '\\frac{\\rm{code\\ mass}}{\\rm{code\\ length}^{3}}')

diff -r 9b76efa712c65a3118ef2c6fb8e97defae53fc7e -r 9acfe15f8b6a998c7817e34706571437ff0eb8dc yt/units/unit_registry.py
--- a/yt/units/unit_registry.py
+++ b/yt/units/unit_registry.py
@@ -63,7 +63,7 @@
 
         if tex_repr is None:
             # make educated guess that will look nice in most cases
-            tex_repr = r"\rm{" + symbol + "}"
+            tex_repr = r"\rm{" + symbol.replace('_', '\ ') + "}"
 
         # Add to lut
         self.lut.update({symbol: (base_value, dimensions, offset, tex_repr)})

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