Skip to content

Commit fcb8175

Browse files
authored
defer to numpy for the expected result (#7875)
* simplify the test for unary funcs * use `full_like` to construct the expected result * Revert "use `full_like` to construct the expected result" This reverts commit a14aeb5.
1 parent f45eb73 commit fcb8175

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

xarray/tests/test_ufuncs.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import pytest
55

66
import xarray as xr
7-
from xarray.tests import assert_array_equal, mock
7+
from xarray.tests import assert_allclose, assert_array_equal, mock
88
from xarray.tests import assert_identical as assert_identical_
99

1010

@@ -16,16 +16,16 @@ def assert_identical(a, b):
1616
assert_array_equal(a, b)
1717

1818

19-
def test_unary():
20-
args = [
21-
0,
22-
np.zeros(2),
19+
@pytest.mark.parametrize(
20+
"a",
21+
[
2322
xr.Variable(["x"], [0, 0]),
2423
xr.DataArray([0, 0], dims="x"),
2524
xr.Dataset({"y": ("x", [0, 0])}),
26-
]
27-
for a in args:
28-
assert_identical(a + 1, np.cos(a))
25+
],
26+
)
27+
def test_unary(a):
28+
assert_allclose(a + 1, np.cos(a))
2929

3030

3131
def test_binary():

0 commit comments

Comments
 (0)