def test_error_lat_lon(self): """Test the function fails when radius is not zero and grid is lat-lon.""" cube = self.cube_latlon plugin = PhaseChangeLevel(phase_change="snow-sleet", grid_point_radius=1) with self.assertRaisesRegex( ValueError, r"Unable to convert from 'Unit\('degrees'\)' to 'Unit\('metres'\)'.", ): plugin.find_max_in_nbhood_orography(cube)
def test_null(self): """Test the function does nothing when radius is zero.""" plugin = PhaseChangeLevel(phase_change="snow-sleet", grid_point_radius=0) expected_data = self.cube.data.copy() result = plugin.find_max_in_nbhood_orography(self.cube) self.assertArrayAlmostEqual(result.data, expected_data)
def test_null_lat_lon(self): """Test the function succeeds and does nothing when radius is zero and grid is lat-lon.""" cube = self.cube_latlon plugin = PhaseChangeLevel(phase_change="snow-sleet", grid_point_radius=0) expected_data = self.cube.data.copy() result = plugin.find_max_in_nbhood_orography(cube) self.assertArrayAlmostEqual(result.data, expected_data)
def test_basic(self): """Test the function does what it's meant to in a simple case.""" plugin = PhaseChangeLevel(phase_change="snow-sleet", grid_point_radius=1) result = plugin.find_max_in_nbhood_orography(self.cube) self.assertArrayAlmostEqual(result.data, self.expected_data)