diff --git a/cf/data/data.py b/cf/data/data.py index 882799ee1e..8aecf29ca4 100644 --- a/cf/data/data.py +++ b/cf/data/data.py @@ -2378,6 +2378,8 @@ def persist(self, inplace=False): **Examples** + TODODASK + """ d = _inplace_enabled_define_and_cleanup(self) @@ -8254,28 +8256,24 @@ def second(self): """ return YMDhms(self, "second") + @daskified(_DASKIFIED_VERBOSE) @_inplace_enabled(default=False) def uncompress(self, inplace=False): - """Uncompress the underlying data. - - Compression saves space by identifying and removing unwanted - missing data. Such compression techniques store the data more - efficiently and result in no precision loss. + """Uncompress the data. - Whether or not the data is compressed does not alter its - functionality nor external appearance. + Only affects data that is compressed by convention, i.e. - Data that is already uncompressed will be returned uncompressed. + * Ragged arrays for discrete sampling geometries (DSG) and + simple geometry cell definitions. - The following type of compression are available: + * Compression by gathering. - * Ragged arrays for discrete sampling geometries (DSG). Three - different types of ragged array representation are - supported. + * Compression by coordinate subsampling. - .. - - * Compression by gathering. + Data that is already uncompressed is returned + unchanged. Whether the data is compressed or not does not + alter its functionality nor external appearance, but may + affect how the data are written to a dataset on disk. .. versionadded:: 3.0.6 @@ -8288,7 +8286,7 @@ def uncompress(self, inplace=False): :Returns: `Data` or `None` - The uncompressed data, or `None` of the operation was + The uncompressed data, or `None` if the operation was in-place. **Examples** @@ -8301,20 +8299,8 @@ def uncompress(self, inplace=False): """ d = _inplace_enabled_define_and_cleanup(self) - - if not d.get_compression_type(): - if inplace: - d = None - return d - - config = d.partition_configuration(readonly=False) - - for partition in d.partitions.matrix.flat: - partition.open(config) - _ = partition.array - partition.close() - - d._del_Array(None) + if d.get_compression_type(): + d._del_Array(None) return d diff --git a/cf/test/test_Data.py b/cf/test/test_Data.py index 51a2705445..205f91b74c 100644 --- a/cf/test/test_Data.py +++ b/cf/test/test_Data.py @@ -3835,6 +3835,20 @@ def test_Data_tolist(self): self.assertEqual(e, np.array(x).tolist()) self.assertTrue(d.equals(cf.Data(e))) + def test_Data_uncompress(self): + import cfdm + + f = cfdm.read("DSG_timeSeries_contiguous.nc")[0] + a = f.data.array + d = cf.Data(cf.RaggedContiguousArray(source=f.data.source())) + + self.assertTrue(d.get_compression_type()) + self.assertTrue((d.array == a).all()) + + self.assertIsNone(d.uncompress(inplace=True)) + self.assertFalse(d.get_compression_type()) + self.assertTrue((d.array == a).all()) + def test_Data_data(self): for d in [ cf.Data(1),