Skip to content

Commit

Permalink
Remove more fill-value warnings tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
pp-mo committed Mar 13, 2024
1 parent 555e3a3 commit 7de5471
Showing 1 changed file with 0 additions and 71 deletions.
71 changes: 0 additions & 71 deletions lib/iris/tests/unit/fileformats/netcdf/saver/test_Saver.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
from iris.cube import Cube
from iris.fileformats.netcdf import Saver, _thread_safe_nc
import iris.tests.stock as stock
from iris.warnings import IrisMaskValueMatchWarning


class Test_write(tests.IrisTest):
Expand Down Expand Up @@ -548,76 +547,6 @@ def test_mask_default_fill_value(self):
self.assertNotIn("_FillValue", var.ncattrs())
self.assertTrue(var[index].mask)

def test_contains_fill_value_passed(self):
# Test that a warning is raised if the data contains the fill value.
cube = self._make_cube(">f4")
fill_value = 1
with self.assertWarnsRegex(
IrisMaskValueMatchWarning,
"contains unmasked data points equal to the fill-value",
):
with self._netCDF_var(cube, fill_value=fill_value):
pass

def test_contains_fill_value_byte(self):
# Test that a warning is raised if the data contains the fill value
# when it is of a byte type.
cube = self._make_cube(">i1")
fill_value = 1
with self.assertWarnsRegex(
IrisMaskValueMatchWarning,
"contains unmasked data points equal to the fill-value",
):
with self._netCDF_var(cube, fill_value=fill_value):
pass

def test_contains_default_fill_value(self):
# Test that a warning is raised if the data contains the default fill
# value if no fill_value argument is supplied.
cube = self._make_cube(">f4")
cube.data[0, 0] = _thread_safe_nc.default_fillvals["f4"]
with self.assertWarnsRegex(
IrisMaskValueMatchWarning,
"contains unmasked data points equal to the fill-value",
):
with self._netCDF_var(cube):
pass

def test_contains_default_fill_value_byte(self):
# Test that no warning is raised if the data contains the default fill
# value if no fill_value argument is supplied when the data is of a
# byte type.
cube = self._make_cube(">i1")
with self.assertNoWarningsRegexp(r"\(fill\|mask\)"):
with self._netCDF_var(cube):
pass

def test_contains_masked_fill_value(self):
# Test that no warning is raised if the data contains the fill_value at
# a masked point.
fill_value = 1
cube = self._make_cube(">f4", masked_value=fill_value)
with self.assertNoWarningsRegexp(r"\(fill\|mask\)"):
with self._netCDF_var(cube, fill_value=fill_value):
pass

def test_masked_byte_default_fill_value(self):
# Test that a warning is raised when saving masked byte data with no
# fill value supplied.
cube = self._make_cube(">i1", masked_value=1)
with self.assertNoWarningsRegexp(r"\(fill\|mask\)"):
with self._netCDF_var(cube):
pass

def test_masked_byte_fill_value_passed(self):
# Test that no warning is raised when saving masked byte data with a
# fill value supplied if the the data does not contain the fill_value.
fill_value = 100
cube = self._make_cube(">i1", masked_value=2)
with self.assertNoWarningsRegexp(r"\(fill\|mask\)"):
with self._netCDF_var(cube, fill_value=fill_value):
pass


class Test_cf_valid_var_name(tests.IrisTest):
def test_no_replacement(self):
Expand Down

0 comments on commit 7de5471

Please sign in to comment.