[yt-svn] commit/yt: jzuhone: Merged in brittonsmith/yt (pull request #1847)

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Mon Nov 9 11:24:18 PST 2015


1 new commit in yt:

https://bitbucket.org/yt_analysis/yt/commits/2c9a4580995c/
Changeset:   2c9a4580995c
Branch:      yt
User:        jzuhone
Date:        2015-11-09 19:23:46+00:00
Summary:     Merged in brittonsmith/yt (pull request #1847)

[bugfix] Make array_like_field return same units as get_data.
Affected #:  2 files

diff -r ce128db22c39c0e0e7ecaa0d1e1d69a2e91ea315 -r 2c9a4580995c344711843eef2ec1f06749c2f423 yt/fields/tests/test_fields.py
--- a/yt/fields/tests/test_fields.py
+++ b/yt/fields/tests/test_fields.py
@@ -15,6 +15,7 @@
 from yt.frontends.stream.fields import \
     StreamFieldInfo
 from yt.units.yt_array import \
+    array_like_field, \
     YTArray, YTQuantity
 from yt.utilities.exceptions import \
     YTFieldUnitError, \
@@ -264,9 +265,17 @@
     assert_equal(str(ad['dimensionless_explicit'].units), 'dimensionless')
     assert_raises(YTFieldUnitError, get_data, ds, 'dimensionful')
 
+def test_array_like_field():
+    ds = fake_random_ds(4, particles=64)
+    ad = ds.all_data()
+    u1 = ad["particle_mass"].units
+    u2 = array_like_field(ad, 1., ("all", "particle_mass")).units
+    assert u1 == u2
+
 if __name__ == "__main__":
     setup()
     for t in test_all_fields():
         t()
     test_add_deposited_particle_field()
     test_add_field_unit_semantics()
+    test_array_like_field()

diff -r ce128db22c39c0e0e7ecaa0d1e1d69a2e91ea315 -r 2c9a4580995c344711843eef2ec1f06749c2f423 yt/units/yt_array.py
--- a/yt/units/yt_array.py
+++ b/yt/units/yt_array.py
@@ -1375,9 +1375,9 @@
 def array_like_field(data, x, field):
     field = data._determine_fields(field)[0]
     if isinstance(field, tuple):
-        units = data.ds._get_field_info(field[0],field[1]).units
+        units = data.ds._get_field_info(field[0],field[1]).output_units
     else:
-        units = data.ds._get_field_info(field).units
+        units = data.ds._get_field_info(field).output_units
     if isinstance(x, YTArray):
         arr = copy.deepcopy(x)
         arr.convert_to_units(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