Skip to content

Commit 77a79d5

Browse files
committed
Fails test when a warning is raised for calling np.array() on an xr.DataArray
1 parent 86a573c commit 77a79d5

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

xarray/tests/test_dataarray.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7065,6 +7065,14 @@ def test_from_numpy(self) -> None:
70657065
np.testing.assert_equal(da.to_numpy(), np.array([1, 2, 3]))
70667066
np.testing.assert_equal(da["lat"].to_numpy(), np.array([4, 5, 6]))
70677067

7068+
def test_to_numpy(self) -> None:
7069+
arr = np.array([1, 2, 3])
7070+
da = xr.DataArray(arr, dims="x", coords={"lat": ("x", [4, 5, 6])})
7071+
7072+
with assert_no_warnings():
7073+
np.testing.assert_equal(np.asarray(da), arr)
7074+
np.testing.assert_equal(np.array(da), arr)
7075+
70687076
@requires_dask
70697077
def test_from_dask(self) -> None:
70707078
da = xr.DataArray([1, 2, 3], dims="x", coords={"lat": ("x", [4, 5, 6])})

0 commit comments

Comments
 (0)