@@ -391,6 +391,42 @@ def test_Domain_create_regular(self):
391
391
np .allclose (latitude_specific .array - y_points_specific , 0 )
392
392
)
393
393
394
+ def test_Domain_del_construct (self ):
395
+ """Test the `del_construct` Domain method."""
396
+ # Test a field without cyclic axes. These are equivalent tests to those
397
+ # in the cfdm test suite, to check the behaviour is the same in cf.
398
+ d = self .d .copy ()
399
+
400
+ self .assertIsInstance (
401
+ d .del_construct ("dimensioncoordinate1" ), cf .DimensionCoordinate
402
+ )
403
+ self .assertIsInstance (
404
+ d .del_construct ("auxiliarycoordinate1" ), cf .AuxiliaryCoordinate
405
+ )
406
+ with self .assertRaises (ValueError ):
407
+ d .del_construct ("auxiliarycoordinate1" )
408
+
409
+ self .assertIsNone (
410
+ d .del_construct ("auxiliarycoordinate1" , default = None )
411
+ )
412
+
413
+ self .assertIsInstance (
414
+ d .del_construct ("measure:area" ), cf .CellMeasure
415
+ )
416
+
417
+ # Test a field with cyclic axes, to ensure the cyclic() set is
418
+ # updated accordingly if a cyclic axes is the one removed.
419
+ e = cf .example_field (2 ).domain # this has a cyclic axes 'domainaxis2'
420
+ # To delete a cyclic axes, must first delete this dimension coordinate
421
+ # because 'domainaxis2' spans it.
422
+ self .assertIsInstance (
423
+ e .del_construct ("dimensioncoordinate2" ), cf .DimensionCoordinate
424
+ )
425
+ self .assertEqual (e .cyclic (), set (("domainaxis2" ,)))
426
+ self .assertIsInstance (
427
+ e .del_construct ("domainaxis2" ), cf .DomainAxis
428
+ )
429
+ self .assertEqual (e .cyclic (), set ())
394
430
395
431
if __name__ == "__main__" :
396
432
print ("Run date:" , datetime .datetime .now ())
0 commit comments