From 215a34f9e6aae493082e28812a799fa4fbffc76f Mon Sep 17 00:00:00 2001 From: Sadie Louise Bartholomew Date: Wed, 2 Mar 2022 14:12:09 +0000 Subject: [PATCH 1/3] Add tests for inspection for all domain constructs w/ lack of data --- cfdm/test/test_Domain.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/cfdm/test/test_Domain.py b/cfdm/test/test_Domain.py index bb6836c33e..fd8ec67623 100644 --- a/cfdm/test/test_Domain.py +++ b/cfdm/test/test_Domain.py @@ -29,6 +29,9 @@ def setUp(self): def test_Domain__repr__str__dump(self): """Test all means of Domain inspection.""" d = self.d + f = self.f + + t = f.construct("air_temperature standard_error") repr(d) str(d) @@ -42,9 +45,25 @@ def test_Domain__repr__str__dump(self): for title in (None, "title"): d.dump(display=False, _title=title) - # Test when dimension coordinate has no data d = d.copy() - t = d.construct("time") + + # Test when all constructs which can have data in fact have no data. + t = d.construct("time") # a dimension coordinate + t.del_data() + self.assertFalse(t.has_data()) + str(d) + + t = d.construct("latitude") # an auxiliary coordinate + t.del_data() + self.assertFalse(t.has_data()) + str(d) + + t = d.construct("measure:area") # a cell measure + t.del_data() + self.assertFalse(t.has_data()) + str(d) + + t = d.construct("surface_altitude") # a domain ancillary t.del_data() self.assertFalse(t.has_data()) str(d) From aa7ae13d7a82fb4384e695020906d81086b723c1 Mon Sep 17 00:00:00 2001 From: Sadie Louise Bartholomew Date: Wed, 2 Mar 2022 14:16:59 +0000 Subject: [PATCH 2/3] Consolidate inspection test for domain constructs w/o data --- cfdm/test/test_Domain.py | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/cfdm/test/test_Domain.py b/cfdm/test/test_Domain.py index fd8ec67623..59b3ed1bc3 100644 --- a/cfdm/test/test_Domain.py +++ b/cfdm/test/test_Domain.py @@ -29,9 +29,6 @@ def setUp(self): def test_Domain__repr__str__dump(self): """Test all means of Domain inspection.""" d = self.d - f = self.f - - t = f.construct("air_temperature standard_error") repr(d) str(d) @@ -45,28 +42,19 @@ def test_Domain__repr__str__dump(self): for title in (None, "title"): d.dump(display=False, _title=title) + # Test when any construct which can have data in fact has no data. d = d.copy() - - # Test when all constructs which can have data in fact have no data. - t = d.construct("time") # a dimension coordinate - t.del_data() - self.assertFalse(t.has_data()) - str(d) - - t = d.construct("latitude") # an auxiliary coordinate - t.del_data() - self.assertFalse(t.has_data()) - str(d) - - t = d.construct("measure:area") # a cell measure - t.del_data() - self.assertFalse(t.has_data()) - str(d) - - t = d.construct("surface_altitude") # a domain ancillary - t.del_data() - self.assertFalse(t.has_data()) - str(d) + for identity in [ + "time", # a dimension coordinate + "latitude", # an auxiliary coordinate + "measure:area", # a cell measure + "surface_altitude", # a domain ancillary + ]: + c = d.construct(identity) # get relevant construct, type as above + c.del_data() + self.assertFalse(c.has_data()) + str(d) + repr(d) def test_Domain__init__(self): """Test the Domain constructor and source keyword.""" From d7fc3b930bff94749c4077763482c9937380555f Mon Sep 17 00:00:00 2001 From: Sadie Louise Bartholomew Date: Wed, 2 Mar 2022 14:32:40 +0000 Subject: [PATCH 3/3] Add tests for inspection for all field constructs w/ lack of data --- cfdm/test/test_Field.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/cfdm/test/test_Field.py b/cfdm/test/test_Field.py index e0d1f1b906..56985ad63b 100644 --- a/cfdm/test/test_Field.py +++ b/cfdm/test/test_Field.py @@ -60,6 +60,21 @@ def test_Field__repr__str__dump_construct_type(self): self.assertIsInstance(f.dump(display=False), str) self.assertEqual(f.construct_type, "field") + # Test when any construct which can have data in fact has no data. + f = f.copy() + for identity in [ + "time", # a dimension coordinate + "latitude", # an auxiliary coordinate + "measure:area", # a cell measure + "surface_altitude", # a domain ancillary, + "air_temperature standard_error", # a field ancillary + ]: + c = f.construct(identity) # get relevant construct, type as above + c.del_data() + self.assertFalse(c.has_data()) + str(f) + repr(f) + def test_Field__init__(self): """Test the Field constructor and source keyword.""" cfdm.Field(source="qwerty")