From e485f610a63984b5a8b2bbc53c5ebfdc72f3c820 Mon Sep 17 00:00:00 2001 From: David Hassell Date: Tue, 3 May 2022 18:40:18 +0100 Subject: [PATCH 1/2] Data.compressed_array test --- cf/test/test_Data.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/cf/test/test_Data.py b/cf/test/test_Data.py index 82141080ec..35b64e64c9 100644 --- a/cf/test/test_Data.py +++ b/cf/test/test_Data.py @@ -2891,9 +2891,6 @@ def test_Data_where(self): self.assertTrue((e.array == a).all()) def test_Data__init__compression(self): - if self.test_only and inspect.stack()[0][3] not in self.test_only: - return - import cfdm # Ragged @@ -3911,6 +3908,19 @@ def test_Data_rtol(self): self.assertEqual(d._rtol, 0.001) + def test_Data_compressed_array(self): + import cfdm + + f = cfdm.read("DSG_timeSeries_contiguous.nc")[0] + f = f.data + d = cf.Data(cf.RaggedContiguousArray(source=f.source())) + self.assertTrue((d.compressed_array == f.compressed_array).all()) + + d = cf.Data([1, 2, 3], 'm') + with self.assertRaises(Exception): + d.compressed_array + + if __name__ == "__main__": print("Run date:", datetime.datetime.now()) cf.environment() From ed4da01d8996e04055289efb8cb9477c8d056367 Mon Sep 17 00:00:00 2001 From: David Hassell Date: Wed, 4 May 2022 18:35:00 +0100 Subject: [PATCH 2/2] Data.compressed_array test --- cf/data/data.py | 2 +- cf/data/mixin/deprecations.py | 2 +- cf/functions.py | 2 +- cf/test/test_Data.py | 12 ++++++++---- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/cf/data/data.py b/cf/data/data.py index 102fc02c64..0859aac06c 100644 --- a/cf/data/data.py +++ b/cf/data/data.py @@ -10844,7 +10844,7 @@ def to_memory(self): "'Data.to_memory' is not available. " "Consider using 'Data.persist' instead." ) - + @daskified(_DASKIFIED_VERBOSE) @_deprecated_kwarg_check("i") @_inplace_enabled(default=False) diff --git a/cf/data/mixin/deprecations.py b/cf/data/mixin/deprecations.py index 0e3491a6db..45a17bfbe5 100644 --- a/cf/data/mixin/deprecations.py +++ b/cf/data/mixin/deprecations.py @@ -710,7 +710,7 @@ def to_disk(self): version="TODODASK", removed_at="5.0.0", ) # pragma: no cover - + @staticmethod def seterr(all=None, divide=None, over=None, under=None, invalid=None): """Set how floating-point errors in the results of arithmetic diff --git a/cf/functions.py b/cf/functions.py index a35e95940a..32eeba6e30 100644 --- a/cf/functions.py +++ b/cf/functions.py @@ -3225,7 +3225,7 @@ def _DEPRECATION_ERROR_ATTRIBUTE( ): if removed_at: removed_at = f" and will be removed at version {removed_at}" - + raise DeprecationError( f"{instance.__class__.__name__} attribute {attribute!r} has been " f"deprecated at version {version} and will be removed at version " diff --git a/cf/test/test_Data.py b/cf/test/test_Data.py index efc8319d85..38039f4656 100644 --- a/cf/test/test_Data.py +++ b/cf/test/test_Data.py @@ -3923,7 +3923,6 @@ def test_Data_rtol(self): cf.rtol(0.001) self.assertEqual(d._rtol, 0.001) - def test_Data_compressed_array(self): import cfdm @@ -3932,11 +3931,16 @@ def test_Data_compressed_array(self): d = cf.Data(cf.RaggedContiguousArray(source=f.source())) self.assertTrue((d.compressed_array == f.compressed_array).all()) - d = cf.Data([1, 2, 3], 'm') + d = cf.Data([1, 2, 3], "m") with self.assertRaises(Exception): d.compressed_array - - + + # TODO: when cfdm>1.9.0.3 is released (i.e. a release that + # includes https://github.com/NCAS-CMS/cfdm/pull/184), + # we can replace the loose "(Exception)" with the tight + # "(ValueError)" + + if __name__ == "__main__": print("Run date:", datetime.datetime.now()) cf.environment()