def test_number_of_percentiles(self):
        """
        Test that the plugin returns a cube with the expected number of
        percentiles.
        """
        expected = np.array([
            [
                [227.42273, 238.67273, 249.92273],
                [261.1727, 272.4227, 283.6727],
                [294.9227, 306.1727, 317.4227],
            ],
            [
                [229.48332, 240.73332, 251.98332],
                [263.2333, 274.4833, 285.7333],
                [296.9833, 308.2333, 319.4833],
            ],
            [
                [231.54391, 242.79391, 254.04391],
                [265.2939, 276.5439, 287.7939],
                [299.0439, 310.2939, 321.5439],
            ],
        ])

        result = Plugin().process(
            self.forecast_predictor,
            self.forecast_variance,
            self.cube,
            no_of_percentiles=self.no_of_percentiles,
        )

        self.assertEqual(len(result.coord("percentile").points),
                         self.no_of_percentiles)
        self.assertArrayAlmostEqual(expected, result.data, decimal=4)
    def test_list_of_percentiles(self):
        """
        Test that the plugin returns a cube with the expected percentiles
        when a specific list of percentiles is provided.
        """
        percentiles = [10, 50, 90]
        expected = np.array([
            [
                [225.56812, 236.81812, 248.06812],
                [259.3181, 270.5681, 281.8181],
                [293.0681, 304.3181, 315.5681],
            ],
            [
                [229.48332, 240.73332, 251.98332],
                [263.2333, 274.4833, 285.7333],
                [296.9833, 308.2333, 319.4833],
            ],
            [
                [233.39853, 244.64853, 255.89853],
                [267.1485, 278.3985, 289.6485],
                [300.8985, 312.1485, 323.3985],
            ],
        ])

        result = Plugin().process(
            self.forecast_predictor,
            self.forecast_variance,
            self.cube,
            percentiles=percentiles,
        )

        self.assertEqual(len(percentiles),
                         len(result.coord("percentile").points))
        self.assertArrayAlmostEqual(percentiles,
                                    result.coord("percentile").points)
        self.assertArrayAlmostEqual(expected, result.data, decimal=4)