def test_energy_ratio_by_chunks(self):
        x = pd.Series(range(90), index=range(90))
        param = [{"num_segments": 6, "segment_focus": i} for i in range(6)]
        output = energy_ratio_by_chunks(x=x, param=param)

        self.assertAlmostEqual(output[0][1], 0.0043, places=3)
        self.assertAlmostEqual(output[1][1], 0.0316, places=3)
        self.assertAlmostEqual(output[2][1], 0.0871, places=3)
        self.assertAlmostEqual(output[3][1], 0.1709, places=3)
        self.assertAlmostEqual(output[4][1], 0.2829, places=3)
        self.assertAlmostEqual(output[5][1], 0.4232, places=3)

        # Sum of the ratios should be 1.0
        sum = 0.0
        for name, dat in output:
            sum = sum + dat
        self.assertAlmostEqual(sum, 1.0)

        x = pd.Series(1, index=range(10))
        param = [{"num_segments": 3, "segment_focus": i} for i in range(3)]
        output = energy_ratio_by_chunks(x=x, param=param)

        self.assertAlmostEqual(output[0][1], 0.4, places=3)
        self.assertAlmostEqual(output[1][1], 0.3, places=3)
        self.assertAlmostEqual(output[2][1], 0.3, places=3)

        # Sum of the ratios should be 1.0
        sum = 0.0
        for name, dat in output:
            sum = sum + dat
        self.assertAlmostEqual(sum, 1.0)

        x = pd.Series(0, index=range(10))
        param = [{"num_segments": 3, "segment_focus": i} for i in range(3)]
        output = energy_ratio_by_chunks(x=x, param=param)
        self.assertIsNaN(output[0][1])
        self.assertIsNaN(output[1][1])
        self.assertIsNaN(output[2][1])