diff --git a/docs/iris/src/whatsnew/contributions_2.3.0/newfeature_2019-Sep-27_cell_measure_integer_data.txt b/docs/iris/src/whatsnew/contributions_2.3.0/newfeature_2019-Sep-27_cell_measure_integer_data.txt new file mode 100644 index 0000000000..0a32b863dc --- /dev/null +++ b/docs/iris/src/whatsnew/contributions_2.3.0/newfeature_2019-Sep-27_cell_measure_integer_data.txt @@ -0,0 +1 @@ +* Loading CellMeasures with non-float values is now supported. diff --git a/lib/iris/coords.py b/lib/iris/coords.py index 527239c651..052093a784 100644 --- a/lib/iris/coords.py +++ b/lib/iris/coords.py @@ -2077,13 +2077,13 @@ def __init__(self, data, standard_name=None, long_name=None, Kwargs: * standard_name: - CF standard name of the coordinate. + CF standard name of the cell measure. * long_name: - Descriptive name of the coordinate. + Descriptive name of the cell measure. * var_name: - The netCDF variable name for the coordinate. + The netCDF variable name for the cell measure. * units - The :class:`~cf_units.Unit` of the coordinate's values. + The :class:`~cf_units.Unit` of the cell measure's values. Can be a string, which will be converted to a Unit object. * attributes A dictionary containing other CF and user-defined attributes. @@ -2092,16 +2092,16 @@ def __init__(self, data, standard_name=None, long_name=None, are the only valid entries. """ - #: CF standard name of the quantity that the coordinate represents. + #: CF standard name of the quantity that the cell measure represents. self.standard_name = standard_name - #: Descriptive name of the coordinate. + #: Descriptive name of the cell measure. self.long_name = long_name - #: The netCDF variable name for the coordinate. + #: The netCDF variable name for the cell measure. self.var_name = var_name - #: Unit of the quantity that the coordinate represents. + #: Unit of the quantity that the cell measure represents. self.units = units #: Other attributes, including user specified attributes that @@ -2131,11 +2131,6 @@ def data(self, data): if data is None: raise ValueError('The data payload of a CellMeasure may not be ' 'None; it must be a numpy array or equivalent.') - if _lazy.is_lazy_data(data) and data.dtype.kind in 'biu': - # Non-floating cell measures are not valid up to CF v1.7 - msg = ('Cannot create cell measure with lazy data of type {}, as ' - 'integer types are not currently supported.') - raise ValueError(msg.format(data.dtype)) if data.shape == (): # If we have a scalar value, promote the shape from () to (1,). # NOTE: this way also *realises* it. Don't think that matters. diff --git a/lib/iris/tests/unit/coords/test_CellMeasure.py b/lib/iris/tests/unit/coords/test_CellMeasure.py index 109357aabc..f408f81abf 100644 --- a/lib/iris/tests/unit/coords/test_CellMeasure.py +++ b/lib/iris/tests/unit/coords/test_CellMeasure.py @@ -1,4 +1,4 @@ -# (C) British Crown Copyright 2015 - 2018, Met Office +# (C) British Crown Copyright 2015 - 2019, Met Office # # This file is part of Iris. # @@ -72,18 +72,6 @@ def test_set_data__lazy(self): self.measure.data = new_vals self.assertArrayEqual(self.measure.data, new_vals) - def test_set_data__int__lazy(self): - new_vals = as_lazy_data(np.array((1, 2, 3, 4), dtype=np.int32)) - exp_emsg = "Cannot create cell measure with lazy data of type int32" - with self.assertRaisesRegexp(ValueError, exp_emsg): - self.measure.data = new_vals - - def test_set_data__uint__lazy(self): - new_vals = as_lazy_data(np.array((1, 2, 3, 4), dtype=np.uint32)) - exp_emsg = "Cannot create cell measure with lazy data of type uint32" - with self.assertRaisesRegexp(ValueError, exp_emsg): - self.measure.data = new_vals - def test_data_different_shape(self): new_vals = np.array((1., 2., 3.)) msg = 'New data shape must match existing data shape.'