[yt-svn] commit/yt: 3 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Wed Jun 15 11:05:11 PDT 2016
3 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/233a130db656/
Changeset: 233a130db656
Branch: yt
User: ngoldbaum
Date: 2016-06-13 18:03:05+00:00
Summary: only return early from comparison validation if base values are equal
Affected #: 1 file
diff -r 124453298c78e4c52a575398ec927c4da21d7192 -r 233a130db65648d0598a3b0d97603b0729b4034d yt/units/yt_array.py
--- a/yt/units/yt_array.py
+++ b/yt/units/yt_array.py
@@ -167,7 +167,8 @@
# Check that other is a YTArray.
if hasattr(other, 'units'):
if this.units.expr is other.units.expr:
- return other
+ if this.units.base_value == other.units.base_value:
+ return other
if not this.units.same_dimensions_as(other.units):
raise YTUnitOperationError(op_string, this.units, other.units)
return other.in_units(this.units)
https://bitbucket.org/yt_analysis/yt/commits/cdf56f84e6e8/
Changeset: cdf56f84e6e8
Branch: yt
User: ngoldbaum
Date: 2016-06-13 18:20:07+00:00
Summary: add a test for code units coming from different datasets
Affected #: 1 file
diff -r 233a130db65648d0598a3b0d97603b0729b4034d -r cdf56f84e6e863d20696705a4ecc8ada1a410f16 yt/units/tests/test_ytarray.py
--- a/yt/units/tests/test_ytarray.py
+++ b/yt/units/tests/test_ytarray.py
@@ -626,6 +626,29 @@
new_length = fix_length(length, ds=ds)
yield assert_equal, YTQuantity(10, 'cm'), new_length
+def test_code_unit_combinations():
+ """
+ Test comparing code units coming from different datasets
+ """
+ ds1 = fake_random_ds(64, nprocs=1, length_unit=1)
+ ds2 = fake_random_ds(64, nprocs=1, length_unit=10)
+
+ q1 = ds1.quan(1, 'code_length')
+ q2 = ds2.quan(1, 'code_length')
+
+ assert_equal(10*q1, q2)
+ assert_equal(q1/q2, 0.1)
+ assert_true(q1 < q2)
+ assert_true(q2 > q1)
+ assert_true(not bool(q1 > q2))
+ assert_true(not bool(q2 < q1))
+ assert_true(q1 != q2)
+ assert_true(not bool(q1 == q2))
+
+ assert_equal((q1 + q2).in_cgs().value, 11)
+ assert_equal((q2 + q1).in_cgs().value, 11)
+ assert_equal((q1 - q2).in_cgs().value, -9)
+ assert_equal((q2 - q1).in_cgs().value, 9)
def test_ytarray_pickle():
ds = fake_random_ds(64, nprocs=1)
https://bitbucket.org/yt_analysis/yt/commits/e2dc99037c2b/
Changeset: e2dc99037c2b
Branch: yt
User: atmyers
Date: 2016-06-15 18:04:47+00:00
Summary: Merged in ngoldbaum/yt (pull request #2227)
only return early from comparison validation if base values are equal
Affected #: 2 files
diff -r 7c6daf8417b1be008dfa2d7b95a385b449921f4b -r e2dc99037c2b849f54fbed597aadee63806f672f yt/units/tests/test_ytarray.py
--- a/yt/units/tests/test_ytarray.py
+++ b/yt/units/tests/test_ytarray.py
@@ -626,6 +626,29 @@
new_length = fix_length(length, ds=ds)
yield assert_equal, YTQuantity(10, 'cm'), new_length
+def test_code_unit_combinations():
+ """
+ Test comparing code units coming from different datasets
+ """
+ ds1 = fake_random_ds(64, nprocs=1, length_unit=1)
+ ds2 = fake_random_ds(64, nprocs=1, length_unit=10)
+
+ q1 = ds1.quan(1, 'code_length')
+ q2 = ds2.quan(1, 'code_length')
+
+ assert_equal(10*q1, q2)
+ assert_equal(q1/q2, 0.1)
+ assert_true(q1 < q2)
+ assert_true(q2 > q1)
+ assert_true(not bool(q1 > q2))
+ assert_true(not bool(q2 < q1))
+ assert_true(q1 != q2)
+ assert_true(not bool(q1 == q2))
+
+ assert_equal((q1 + q2).in_cgs().value, 11)
+ assert_equal((q2 + q1).in_cgs().value, 11)
+ assert_equal((q1 - q2).in_cgs().value, -9)
+ assert_equal((q2 - q1).in_cgs().value, 9)
def test_ytarray_pickle():
ds = fake_random_ds(64, nprocs=1)
diff -r 7c6daf8417b1be008dfa2d7b95a385b449921f4b -r e2dc99037c2b849f54fbed597aadee63806f672f yt/units/yt_array.py
--- a/yt/units/yt_array.py
+++ b/yt/units/yt_array.py
@@ -167,7 +167,8 @@
# Check that other is a YTArray.
if hasattr(other, 'units'):
if this.units.expr is other.units.expr:
- return other
+ if this.units.base_value == other.units.base_value:
+ return other
if not this.units.same_dimensions_as(other.units):
raise YTUnitOperationError(op_string, this.units, other.units)
return other.in_units(this.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