def test_only_one_post_processed_forecast_masked(self): """ Test no error is raised if only the post_processed_forecast is masked. """ self.post_processed_percentiles.data[:, 0, 0] = np.nan self.post_processed_percentiles.data = np.ma.masked_invalid( self.post_processed_percentiles.data) Plugin._check_input_cube_masks(self.post_processed_percentiles, self.raw_cube)
def test_consistent_masks(self): """Test no error is raised if the raw_forecast and post_processed_forecast have consistent masks. """ self.post_processed_percentiles.data[:, 0, 0] = np.nan self.post_processed_percentiles.data = np.ma.masked_invalid( self.post_processed_percentiles.data) self.raw_cube.data[:, 0, 0] = np.nan self.raw_cube.data = np.ma.masked_invalid(self.raw_cube.data) Plugin._check_input_cube_masks(self.post_processed_percentiles, self.raw_cube)
def test_only_raw_cube_masked(self): """ Test an error is raised if only the raw_cube is masked. """ self.raw_cube.data[:, 0, 0] = np.nan self.raw_cube.data = np.ma.masked_invalid(self.raw_cube.data) message = ( "The raw_forecast provided has a mask, but the post_processed_forecast " "isn't masked. The post_processed_forecast and the raw_forecast " "should have the same mask applied to them.") with self.assertRaisesRegex(ValueError, message): Plugin._check_input_cube_masks(self.post_processed_percentiles, self.raw_cube)
def test_raw_forecast_inconsistent_mask(self): """Test an error is raised if the raw_forecast has an inconsistent mask. """ self.post_processed_percentiles.data[:, 0, 0] = np.nan self.post_processed_percentiles.data = np.ma.masked_invalid( self.post_processed_percentiles.data) self.raw_cube.data[2, 0, 0] = np.nan self.raw_cube.data = np.ma.masked_invalid(self.raw_cube.data) message = ("The raw_forecast x-y slices do not all have the" " same mask as the post_processed_forecast.") with self.assertRaisesRegex(ValueError, message): Plugin._check_input_cube_masks(self.post_processed_percentiles, self.raw_cube)
def test_unmasked_data(self): """Test unmasked data does not raise any errors.""" Plugin._check_input_cube_masks(self.post_processed_percentiles, self.raw_cube)