@@ -186,7 +186,7 @@ def matches_any(self, predicate):
186186 return any (self .matches (predicate ))
187187
188188
189- def coord_comparison (* cubes , object_type = "coord" ):
189+ def coord_comparison (* cubes , object_get = None ):
190190 """
191191 Convenience function to help compare coordinates on one or more cubes
192192 by their metadata.
@@ -240,14 +240,12 @@ def coord_comparison(*cubes, object_type="coord"):
240240 print('All equal coordinates: ', result['equal'])
241241
242242 """
243- if object_type == "coord" :
244- all_coords = [cube .coords () for cube in cubes ]
245- elif object_type == "cell measure" :
246- all_coords = [cube .cell_measures () for cube in cubes ]
247- elif object_type == "ancillary variable" :
248- all_coords = [cube .ancillary_variables () for cube in cubes ]
249- else :
250- raise Exception
243+ if object_get is None :
244+ from iris .cube import Cube
245+
246+ object_get = Cube .coords
247+
248+ all_coords = [object_get (cube ) for cube in cubes ]
251249 grouped_coords = []
252250
253251 # set of coordinates id()s of coordinates which have been processed
@@ -341,31 +339,15 @@ def diff_shape_fn(cube, coord):
341339 # dimension on their respective cubes
342340 # (None -> group describes a different dimension)
343341 def diff_data_dim_fn (cube , coord ):
344- if object_type == "coord" :
345- return cube .coord_dims (coord ) != first_cube .coord_dims (
346- first_coord
347- )
348- elif object_type == "cell measure" :
349- return cube .cell_measure_dims (
350- coord
351- ) != first_cube .cell_measure_dims (first_coord )
352- elif object_type == "ancillary variable" :
353- return cube .ancillary_variable_dims (
354- coord
355- ) != first_cube .ancillary_variable_dims (first_coord )
342+ return coord .cube_dims (cube ) != first_coord .cube_dims (first_cube )
356343
357344 if coord_group .matches_any (diff_data_dim_fn ):
358345 different_data_dimension .add (coord_group )
359346
360347 # get all coordinate groups which don't describe a dimension
361348 # (None -> doesn't describe a dimension)
362349 def no_data_dim_fn (cube , coord ):
363- if object_type == "coord" :
364- return cube .coord_dims (coord ) == ()
365- elif object_type == "cell measure" :
366- return cube .cell_measure_dims (coord ) == ()
367- elif object_type == "ancillary variable" :
368- return cube .ancillary_variable_dims (coord ) == ()
350+ return coord .cube_dims (cube ) == ()
369351
370352 if coord_group .matches_all (no_data_dim_fn ):
371353 no_data_dimension .add (coord_group )
0 commit comments