Beispiel #1
0
 def test_percentiles_weights_none(self):
     """Test it works for percentiles with weights set to None."""
     coord = "time"
     plugin = WeightedBlendAcrossWholeDimension(coord, 'weighted_mean')
     weights = None
     perc_cube = percentile_cube()
     result = plugin.process(perc_cube, weights)
     expected_result_array = np.reshape(BLENDED_PERCENTILE_DATA1, (6, 2, 2))
     self.assertArrayAlmostEqual(result.data, expected_result_array)
Beispiel #2
0
 def test_percentiles_different_coordinate_orders(self):
     """Test the result of the percentile aggregation is the same
     regardless of the coordinate order in the input cube. Most
     importantly, the result should be the same regardless of on which
     side of the collapsing coordinate the percentile coordinate falls."""
     coord = "time"
     plugin = WeightedBlendAcrossWholeDimension(coord, 'weighted_mean')
     weights = None
     percentile_leading = percentile_cube()
     time_leading = percentile_cube()
     time_leading.transpose([1, 0, 2, 3])
     result_percentile_leading = plugin.process(percentile_leading, weights)
     result_time_leading = plugin.process(time_leading, weights)
     expected_result_array = np.reshape(BLENDED_PERCENTILE_DATA1, (6, 2, 2))
     self.assertArrayAlmostEqual(result_percentile_leading.data,
                                 expected_result_array)
     self.assertArrayAlmostEqual(result_time_leading.data,
                                 expected_result_array)
Beispiel #3
0
 def test_fails_more_than_one_perc_coord(self):
     """Test it raises a Value Error if more than one percentile coord."""
     coord = "time"
     plugin = WeightedBlendAcrossWholeDimension(coord, 'weighted_mean')
     new_cube = percentile_cube()
     new_cube.add_aux_coord(
         AuxCoord([10.0], long_name="percentile_over_dummy"))
     msg = ('There should only be one percentile coord ' 'on the cube.')
     with self.assertRaisesRegexp(ValueError, msg):
         plugin.process(new_cube)