def test_fails_perc_coord_not_dim(self):
     """Test it raises a Value Error if percentile coord not a dim."""
     plugin = WeightedBlendAcrossWholeDimension(self.coord)
     new_cube = self.cube.copy()
     new_cube.add_aux_coord(AuxCoord([10.0], long_name="percentile"))
     msg = "The percentile coord must be a dimension " "of the cube."
     with self.assertRaisesRegex(ValueError, msg):
         plugin.check_percentile_coord(new_cube)
예제 #2
0
 def test_fails_percentile_data_max_mode(self):
     """Test a Value Error is raised if the maximum mode is applied to
     percentile data."""
     coord = "forecast_reference_time"
     plugin = WeightedBlendAcrossWholeDimension(coord, 'weighted_maximum')
     new_cube = percentile_cube()
     msg = ('The "weighted_maximum" mode is not supported for percentile '
            'data.')
     with self.assertRaisesRegex(ValueError, msg):
         plugin.check_percentile_coord(new_cube)
예제 #3
0
 def test_fails_perc_coord_not_dim(self):
     """Test it raises a Value Error if percentile coord not a dim."""
     coord = "forecast_reference_time"
     plugin = WeightedBlendAcrossWholeDimension(coord, 'weighted_mean')
     new_cube = self.cube.copy()
     new_cube.add_aux_coord(
         AuxCoord([10.0], long_name="percentile_over_time"))
     msg = ('The percentile coord must be a dimension ' 'of the cube.')
     with self.assertRaisesRegex(ValueError, msg):
         plugin.check_percentile_coord(new_cube)
 def test_fails_only_one_percentile_value(self):
     """Test it raises a Value Error if there is only one percentile."""
     plugin = WeightedBlendAcrossWholeDimension(self.coord)
     new_cube = Cube([[0.0]])
     new_cube.add_dim_coord(DimCoord([10.0], long_name="percentile"), 0)
     new_cube.add_dim_coord(
         DimCoord([10.0], long_name="forecast_reference_time"), 1)
     msg = ("Percentile coordinate does not have enough points"
            " in order to blend. Must have at least 2 percentiles.")
     with self.assertRaisesRegex(ValueError, msg):
         plugin.check_percentile_coord(new_cube)
 def test_basic(self):
     """Tests the basic use of check_percentile_coord"""
     expected = DimCoord(
         np.array([0.0, 20.0], dtype="float32"),
         standard_name=None,
         units="%",
         long_name="percentile",
     )
     cube = self.perc_cube[:2]
     x = WeightedBlendAcrossWholeDimension.check_percentile_coord(cube)
     self.assertEqual(x, expected)
예제 #6
0
 def test_basic(self):
     """Tests the basic use of check_percentile_coord"""
     cube = self.perc_cube[:2]
     self.assertTrue(WeightedBlendAcrossWholeDimension.check_percentile_coord(cube))