Skip to content

Commit

Permalink
assert_identical half way in ufuncs
Browse files Browse the repository at this point in the history
  • Loading branch information
max-sixty committed Jan 14, 2018
1 parent 39ba845 commit ee4443e
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions xarray/tests/test_ufuncs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@
assert_equal)



class TestOps(TestCase):
def assertIdentical(self, a, b):
def assert_identical(self, a, b):
assert type(a) is type(b) or (float(a) == float(b))
try:
assert a.identical(b), (a, b)
Expand All @@ -29,7 +28,7 @@ def test_unary(self):
xr.DataArray([0, 0], dims='x'),
xr.Dataset({'y': ('x', [0, 0])})]
for a in args:
self.assertIdentical(a + 1, xu.cos(a))
self.assert_identical(a + 1, xu.cos(a))

def test_binary(self):
args = [0,
Expand All @@ -39,10 +38,10 @@ def test_binary(self):
xr.Dataset({'y': ('x', [0, 0])})]
for n, t1 in enumerate(args):
for t2 in args[n:]:
self.assertIdentical(t2 + 1, xu.maximum(t1, t2 + 1))
self.assertIdentical(t2 + 1, xu.maximum(t2, t1 + 1))
self.assertIdentical(t2 + 1, xu.maximum(t1 + 1, t2))
self.assertIdentical(t2 + 1, xu.maximum(t2 + 1, t1))
self.assert_identical(t2 + 1, xu.maximum(t1, t2 + 1))
self.assert_identical(t2 + 1, xu.maximum(t2, t1 + 1))
self.assert_identical(t2 + 1, xu.maximum(t1 + 1, t2))
self.assert_identical(t2 + 1, xu.maximum(t2 + 1, t1))

def test_groupby(self):
ds = xr.Dataset({'a': ('x', [0, 0, 0])}, {'c': ('x', [0, 0, 1])})
Expand All @@ -68,4 +67,4 @@ def test_groupby(self):
def test_pickle(self):
a = 1.0
cos_pickled = pickle.loads(pickle.dumps(xu.cos))
self.assertIdentical(cos_pickled(a), xu.cos(a))
self.assert_identical(cos_pickled(a), xu.cos(a))

0 comments on commit ee4443e

Please sign in to comment.