Пример #1
0
    def test_fourier_smooth_one(self):
        """
        Test the fourier smoothing function, with data one input.

        .. todo:: 

            Test with and without Numpy in the same interpreter
              session; We must get the exact same result!

        """
        # No change should happen with a 'width' of 1.0.
        data = list(DATA_ONE)
        x = smooth_utils.fourier_smooth(data, 1.0)
        self.assertEqual(data, x)

        # Smooth by two frames.
        data = list(DATA_ONE)
        x = smooth_utils.fourier_smooth(data, 2.0)
        same_value = True
        for i, v in enumerate(x):
            if data[i] != v:
                same_value = False
                break
        self.assertIs(same_value, False)
        return
Пример #2
0
    def test_fourier_smooth_four(self):
        """
        Test the fourier smoothing function, with data four input.

        .. todo::

            Test with and without Numpy in the same interpreter
              session; We must get the exact same result!

        """
        # Smooth and negate DATA_ONE.
        data = list(DATA_ONE)
        x = smooth_utils.fourier_smooth(data, 2.0)
        x_neg = [n * -1.0 for n in x]

        # Smooth DATA_FOUR by two frames, it must match DATA_ONE after
        # it was smoothed and negated.
        data = list(DATA_FOUR)
        y = smooth_utils.fourier_smooth(data, 2.0)
        self.assertEqual(x_neg, y)
        same_value = True
        for i, v in enumerate(y):
            if x_neg[i] != v:
                same_value = False
                break
        self.assertIs(same_value, True)
        return
Пример #3
0
    def test_fourier_smooth_two(self):
        """
        Test the fourier smoothing function, with data input two
        """
        # No change should happen with a 'width' of 1.0.
        data = list(DATA_TWO)
        x = smooth_utils.fourier_smooth(data, 1.0, filtr='box')
        self.assertEqual(data, x)

        data = list(DATA_TWO)
        x = smooth_utils.fourier_smooth(data, 1.0, filtr='triangle')
        self.assertEqual(data, x)

        data = list(DATA_TWO)
        x = smooth_utils.fourier_smooth(data, 1.0, filtr='fourier')
        self.assertEqual(data, x)

        # Smooth by two frames.
        data = list(DATA_TWO)
        x = smooth_utils.fourier_smooth(data, 2.0, filtr='box')
        data = [
            0.0,
            0.3333333333333333,
            0.3333333333333333,
            0.3333333333333333,
            0.0,
        ]
        for a, b in zip(list(x), data):
            self.assertAlmostEqual(a, b)

        data = list(DATA_TWO)
        x = smooth_utils.fourier_smooth(data, 2.0, filtr='triangle')
        data = [
            0.0,
            0.2,
            0.6,
            0.2,
            0.0,
        ]
        for a, b in zip(list(x), data):
            self.assertAlmostEqual(a, b)

        data = list(DATA_TWO)
        x = smooth_utils.fourier_smooth(data, 2.0, filtr='gaussian')
        data = [
            0.0,
            0.27406862,
            0.45186276,
            0.27406862,
            0.0,
        ]
        for a, b in zip(list(x), data):
            self.assertAlmostEqual(a, b)
        return