-
Notifications
You must be signed in to change notification settings - Fork 300
Closed
Description
📰 Custom Issue
Running iris.tests.unit.fileformats.netcdf.test_Saver.Test_write.test_zlib() raises the following DeprecationWarning:
.../iris/fileformats/netcdf.py:2762: DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
contains_value = fill_value is not None and fill_value in data
This appears to stem from the fact that we are patching the netCDF4 module, which means that a MagicMock is passed as the fill_value.
Patching
iris/lib/iris/tests/unit/fileformats/netcdf/test_Saver.py
Lines 188 to 190 in 7fbc200
| api = self.patch("iris.fileformats.netcdf.netCDF4") | |
| with Saver("/dummy/path", "NETCDF4") as saver: | |
| saver.write(cube, zlib=True) |
Point of warning
iris/lib/iris/fileformats/netcdf.py
Lines 2759 to 2763 in 7fbc200
| def store(data, cf_var, fill_value): | |
| cf_var[:] = data | |
| is_masked = ma.is_masked(data) | |
| contains_value = fill_value is not None and fill_value in data | |
| return is_masked, contains_value |
To make sure the test continues to work, we will need to find a way for the MagicMock to be recognised as an appropriate value for Numpy elementwise comparison. But I have no idea how to do this when the MagicMock is coming from a patch!
rcomer