diff --git a/tests/test_io_xarray.py b/tests/test_io_xarray.py index 57515a1f..fcd6fbd8 100644 --- a/tests/test_io_xarray.py +++ b/tests/test_io_xarray.py @@ -129,6 +129,8 @@ def test_xarray_reader_external_nodata(): data.attrs.update({"valid_min": arr.min(), "valid_max": arr.max()}) data.rio.write_crs("epsg:4326", inplace=True) + assert data.rio.nodata is None + with XarrayReader(data) as dst: info = dst.info() assert info.height == 180 @@ -141,18 +143,21 @@ def test_xarray_reader_external_nodata(): assert img.mask.all() assert img.data[0, 0, 0] == 0 assert img.data[0, 100, 100] + assert dst.input.rio.nodata is None # overwrite the nodata value to 0 img = dst.tile(0, 0, 1, nodata=0) assert not img.mask.all() # not all the mask value are set to 255 assert img.array.mask[0, 0, 0] # the top left pixel should be masked assert not img.array.mask[0, 100, 100] # pixel 100,100 shouldn't be masked + assert dst.input.rio.nodata is None # PART img = dst.part((-160, -80, 160, 80)) assert img.mask.all() assert img.data[0, 0, 0] == 0 assert img.data[0, 100, 100] + assert dst.input.rio.nodata is None # overwrite the nodata value to 0 img = dst.part((-160, -80, 160, 80), nodata=0) @@ -163,11 +168,13 @@ def test_xarray_reader_external_nodata(): # POINT pt = dst.point(-179, 89) assert pt.mask[0] == 255 + assert dst.input.rio.nodata is None # overwrite the nodata value to 0 pt = dst.point(-179, 89, nodata=0) assert pt.count == 1 assert pt.mask[0] == 0 + assert dst.input.rio.nodata is None feat = { "type": "Feature", @@ -191,12 +198,14 @@ def test_xarray_reader_external_nodata(): assert img.mask.all() assert img.data[0, 0, 0] == 0 assert img.data[0, 50, 100] + assert dst.input.rio.nodata is None # overwrite the nodata value to 0 img = dst.feature(feat, nodata=0) assert not img.mask.all() # not all the mask value are set to 255 assert img.array.mask[0, 0, 0] # the top left pixel should be masked assert not img.array.mask[0, 50, 100] # pixel 50,100 shouldn't be masked + assert dst.input.rio.nodata is None def test_xarray_reader_internal_nodata(): @@ -219,6 +228,7 @@ def test_xarray_reader_internal_nodata(): ) data.rio.write_crs("epsg:4326", inplace=True) + assert data.rio.nodata is not None with XarrayReader(data) as dst: # TILE