Skip to content

Commit

Permalink
Add import, update What's New, add test, and fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
djkirkham committed Oct 11, 2017
1 parent 703494c commit 2e6d116
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* When saving a cube or list of cubes, a fill value or list of fill values can be specified via a new `fill_value` argument. If a list is supplied, each fill value will be applied to each cube in turn. If a `fill_value` argument is not specified, the default fill value for the file format and the cube's data type will be used. Fill values are no longer taken from the cube's `data` attribute when it is a masked array.
* When saving a cube or list of cubes in netCDF, a fill value or list of fill values can be specified via a new `fill_value` argument. If a list is supplied, each fill value will be applied to each cube in turn. If a `fill_value` argument is not specified, the default fill value for the file format and the cube's data type will be used. Fill values are no longer taken from the cube's `data` attribute when it is a masked array.
1 change: 1 addition & 0 deletions lib/iris/fileformats/netcdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
from iris.aux_factory import HybridHeightFactory, HybridPressureFactory, \
OceanSigmaZFactory, OceanSigmaFactory, OceanSFactory, OceanSg1Factory, \
OceanSg2Factory
import iris.config
import iris.coord_systems
import iris.coords
import iris.cube
Expand Down
12 changes: 11 additions & 1 deletion lib/iris/tests/unit/fileformats/netcdf/test_Saver.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,8 @@ def test_mask_lazy_fill_value(self):
self.assertTrue(var[index].mask)

def test_mask_lazy_default_fill_value(self):
# Test that masked lazy data saves correctly when given a fill value.
# Test that masked lazy data saves correctly using the default fill
# value.
index = (1, 1)
cube = self._make_cube('>f4', masked_index=index, lazy=True)
with self._netCDF_var(cube) as var:
Expand Down Expand Up @@ -477,6 +478,15 @@ def test_masked_byte_default_fill_value(self):
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._warning_check('contains masked byte data', False):
with self._netCDF_var(cube, fill_value=fill_value):
pass


class _Common__check_attribute_compliance(object):
def setUp(self):
Expand Down
2 changes: 1 addition & 1 deletion lib/iris/tests/unit/fileformats/netcdf/test_save.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def test_None(self):
self.assertIs(None, kwargs['fill_value'])

def test_single(self):
# Test that when a signle value is passed as the fill_value argument,
# Test that when a single value is passed as the fill_value argument,
# that value is passed to each call to Saver.write
cubes = self._make_cubes()
fill_value = 12345.
Expand Down

0 comments on commit 2e6d116

Please sign in to comment.