Skip to content

Commit

Permalink
Add unit tests for new is_model_blended function.
Browse files Browse the repository at this point in the history
  • Loading branch information
bayliffe committed Feb 14, 2022
1 parent 402580c commit 317843a
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions improver_tests/utilities/test_cube_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
check_cube_coordinates,
check_for_x_and_y_axes,
find_dimension_coordinate_mismatch,
is_model_blended,
spatial_coords_match,
)

Expand Down Expand Up @@ -301,5 +302,29 @@ def test_unmatching_y(self):
self.assertFalse(result)


class Test_is_model_blended(unittest.TestCase):

"""Test is_model_blended behaves as expected."""

def setUp(self):
"""Set up a cube."""
data = np.ones((1, 5, 5), dtype=np.float32)
cube = set_up_variable_cube(
data, "precipitation_amount", "kg m^-2", "equalarea",
)
self.cube_without = cube
blend_time = cube.coord("forecast_reference_time").copy()
blend_time.rename("blend_time")
self.cube_with = cube.copy()
self.cube_with.add_aux_coord(blend_time)

def test_basic(self):
"""Test correct result is returned for cube with and without a
blend_time coordinate."""

self.assertFalse(is_model_blended(self.cube_without))
self.assertTrue(is_model_blended(self.cube_with))


if __name__ == "__main__":
unittest.main()

0 comments on commit 317843a

Please sign in to comment.