[yt-svn] commit/yt: 3 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Mon Oct 5 11:12:55 PDT 2015
3 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/a7b344451d92/
Changeset: a7b344451d92
Branch: yt
User: ngoldbaum
Date: 2015-10-05 01:04:17+00:00
Summary: Refactor base units transformation to avoid expensive as_coeff_exponent() calls
Affected #: 1 file
diff -r b7afd79a9820e8605a1e73c5d3d7a077cae7fe96 -r a7b344451d9292b481472e35e1930b66a60d5626 yt/units/unit_object.py
--- a/yt/units/unit_object.py
+++ b/yt/units/unit_object.py
@@ -394,9 +394,13 @@
# Use sympy to factor the dimensions into base CGS unit symbols.
units = []
my_dims = self.dimensions.expand()
- for dim in base_units:
+ for factor in my_dims.as_ordered_factors():
+ dim = list(factor.free_symbols)[0]
unit_string = base_units[dim]
- power_string = "**(%s)" % my_dims.as_coeff_exponent(dim)[1]
+ if factor.is_Pow:
+ power_string = "**(%s)" % factor.as_base_exp()[1]
+ else:
+ power_string = ""
units.append("".join([unit_string, power_string]))
return " * ".join(units)
https://bitbucket.org/yt_analysis/yt/commits/1b39dc8353fa/
Changeset: 1b39dc8353fa
Branch: yt
User: ngoldbaum
Date: 2015-10-05 01:56:03+00:00
Summary: Avoid error when dealing with dimensionless units
Affected #: 2 files
diff -r a7b344451d9292b481472e35e1930b66a60d5626 -r 1b39dc8353faad40b8a600b5ed6fdd421000a5a2 yt/units/tests/test_ytarray.py
--- a/yt/units/tests/test_ytarray.py
+++ b/yt/units/tests/test_ytarray.py
@@ -467,6 +467,13 @@
yield assert_equal, str(em3.in_mks().units), 'kg/(m*s**2)'
yield assert_equal, str(em3.in_cgs().units), 'g/(cm*s**2)'
+ dimless = YTQuantity(1.0, "")
+ yield assert_equal, dimless.in_cgs(), dimless
+ yield assert_equal, dimless.in_cgs(), 1.0
+ yield assert_equal, dimless.in_mks(), dimless
+ yield assert_equal, dimless.in_mks(), 1.0
+ yield assert_equal, str(dimless.in_cgs().units), "dimensionless"
+
def test_temperature_conversions():
"""
Test conversions between various supported temperatue scales.
diff -r a7b344451d9292b481472e35e1930b66a60d5626 -r 1b39dc8353faad40b8a600b5ed6fdd421000a5a2 yt/units/unit_object.py
--- a/yt/units/unit_object.py
+++ b/yt/units/unit_object.py
@@ -394,6 +394,8 @@
# Use sympy to factor the dimensions into base CGS unit symbols.
units = []
my_dims = self.dimensions.expand()
+ if my_dims is dimensionless:
+ return ""
for factor in my_dims.as_ordered_factors():
dim = list(factor.free_symbols)[0]
unit_string = base_units[dim]
https://bitbucket.org/yt_analysis/yt/commits/e624dbb8e008/
Changeset: e624dbb8e008
Branch: yt
User: ngoldbaum
Date: 2015-10-05 18:12:41+00:00
Summary: Merged in ngoldbaum/yt (pull request #1782)
Refactor base units transformation to avoid expensive as_coeff_exponent() calls
Affected #: 2 files
diff -r 4cbd4de67d20e65e062507ed6fa0dee102ac9ea8 -r e624dbb8e008780dfae3293256b67802b9463f0e yt/units/tests/test_ytarray.py
--- a/yt/units/tests/test_ytarray.py
+++ b/yt/units/tests/test_ytarray.py
@@ -467,6 +467,13 @@
yield assert_equal, str(em3.in_mks().units), 'kg/(m*s**2)'
yield assert_equal, str(em3.in_cgs().units), 'g/(cm*s**2)'
+ dimless = YTQuantity(1.0, "")
+ yield assert_equal, dimless.in_cgs(), dimless
+ yield assert_equal, dimless.in_cgs(), 1.0
+ yield assert_equal, dimless.in_mks(), dimless
+ yield assert_equal, dimless.in_mks(), 1.0
+ yield assert_equal, str(dimless.in_cgs().units), "dimensionless"
+
def test_temperature_conversions():
"""
Test conversions between various supported temperatue scales.
diff -r 4cbd4de67d20e65e062507ed6fa0dee102ac9ea8 -r e624dbb8e008780dfae3293256b67802b9463f0e yt/units/unit_object.py
--- a/yt/units/unit_object.py
+++ b/yt/units/unit_object.py
@@ -394,9 +394,15 @@
# Use sympy to factor the dimensions into base CGS unit symbols.
units = []
my_dims = self.dimensions.expand()
- for dim in base_units:
+ if my_dims is dimensionless:
+ return ""
+ for factor in my_dims.as_ordered_factors():
+ dim = list(factor.free_symbols)[0]
unit_string = base_units[dim]
- power_string = "**(%s)" % my_dims.as_coeff_exponent(dim)[1]
+ if factor.is_Pow:
+ power_string = "**(%s)" % factor.as_base_exp()[1]
+ else:
+ power_string = ""
units.append("".join([unit_string, power_string]))
return " * ".join(units)
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