Skip to content

Commit adfd243

Browse files
committed
Check xarray conversion does not copy, in a way which supports older versions of xarray.
1 parent b74d4ed commit adfd243

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

tests/unit/xarray/test_to_xarray.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
import dask.array as da
1313
import numpy as np
1414
import pytest
15+
1516
from ncdata import NcData, NcDimension, NcVariable
1617
from ncdata.xarray import to_xarray
17-
1818
from tests import MonitoredArray
1919

2020

@@ -61,7 +61,10 @@ def test_real_nocopy():
6161

6262
# Check that the data content is the *SAME ARRAY*
6363
xr_data = xrds.variables["var_x"]._data
64-
assert xr_data is real_numpy_data
64+
# There may be a wrapper object, for some versions of xarray,
65+
# so test by modifying the original + check that the result tracks it.
66+
real_numpy_data[-1] = 777
67+
assert np.all(xr_data == real_numpy_data)
6568

6669

6770
@pytest.mark.parametrize("scaleandoffset", ["WITHscaling", "NOscaling"])

0 commit comments

Comments
 (0)