[yt-svn] commit/yt: 2 new changesets

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Sun Aug 16 09:18:34 PDT 2015


2 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/7a4b04aefc57/
Changeset:   7a4b04aefc57
Branch:      yt
User:        ngoldbaum
Date:        2015-08-13 20:22:56+00:00
Summary:     Fix issue with gradient fields of unitless fields erroring out
Affected #:  1 file

diff -r 603eab147248f1a165778c76208906201eb7baae -r 7a4b04aefc57032e8fe42bad38817b6d1d4257b2 yt/fields/fluid_fields.py
--- a/yt/fields/fluid_fields.py
+++ b/yt/fields/fluid_fields.py
@@ -215,7 +215,11 @@
             return new_field
         return func
 
-    grad_units = "(%s) / cm" % field_units
+    if field_units != "":
+        grad_units = "(%s) / cm" % field_units
+    else:
+        grad_units = "1 / cm"
+
     for axi, ax in enumerate('xyz'):
         f = grad_func(axi, ax)
         registry.add_field((ftype, "%s_gradient_%s" % (fname, ax)),


https://bitbucket.org/yt_analysis/yt/commits/bc21601eb3e3/
Changeset:   bc21601eb3e3
Branch:      yt
User:        ngoldbaum
Date:        2015-08-13 20:28:07+00:00
Summary:     Add test for gradient field based on a unitless field
Affected #:  1 file

diff -r 7a4b04aefc57032e8fe42bad38817b6d1d4257b2 -r bc21601eb3e3d89810ca3b5e914797f934fe1ef8 yt/fields/tests/test_fields.py
--- a/yt/fields/tests/test_fields.py
+++ b/yt/fields/tests/test_fields.py
@@ -196,15 +196,23 @@
 
 def test_add_gradient_fields():
     gfields = base_ds.add_gradient_fields(("gas","density"))
+    gfields += base_ds.add_gradient_fields(("index", "ones"))
     field_list = [('gas', 'density_gradient_x'),
                   ('gas', 'density_gradient_y'),
                   ('gas', 'density_gradient_z'),
-                  ('gas', 'density_gradient_magnitude')]
+                  ('gas', 'density_gradient_magnitude'),
+                  ('index', 'ones_gradient_x'),
+                  ('index', 'ones_gradient_y'),
+                  ('index', 'ones_gradient_z'),
+                  ('index', 'ones_gradient_magnitude')]
     assert_equal(gfields, field_list)
     ad = base_ds.all_data()
     for field in field_list:
         ret = ad[field]
-        assert str(ret.units) == "g/cm**4"
+        if field[0] == 'gas':
+            assert str(ret.units) == "g/cm**4"
+        else:
+            assert str(ret.units) == "1/cm"
 
 def get_data(ds, field_name):
     # Need to create a new data object otherwise the errors we are

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